base mod created
This commit is contained in:
@@ -0,0 +1,371 @@
|
||||
package net.minecraft.network;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.network.handshake.client.C00Handshake;
|
||||
import net.minecraft.network.login.client.CPacketEncryptionResponse;
|
||||
import net.minecraft.network.login.client.CPacketLoginStart;
|
||||
import net.minecraft.network.login.server.SPacketEnableCompression;
|
||||
import net.minecraft.network.login.server.SPacketEncryptionRequest;
|
||||
import net.minecraft.network.login.server.SPacketLoginSuccess;
|
||||
import net.minecraft.network.play.client.CPacketAnimation;
|
||||
import net.minecraft.network.play.client.CPacketChatMessage;
|
||||
import net.minecraft.network.play.client.CPacketClickWindow;
|
||||
import net.minecraft.network.play.client.CPacketClientSettings;
|
||||
import net.minecraft.network.play.client.CPacketClientStatus;
|
||||
import net.minecraft.network.play.client.CPacketCloseWindow;
|
||||
import net.minecraft.network.play.client.CPacketConfirmTeleport;
|
||||
import net.minecraft.network.play.client.CPacketConfirmTransaction;
|
||||
import net.minecraft.network.play.client.CPacketCreativeInventoryAction;
|
||||
import net.minecraft.network.play.client.CPacketCustomPayload;
|
||||
import net.minecraft.network.play.client.CPacketEnchantItem;
|
||||
import net.minecraft.network.play.client.CPacketEntityAction;
|
||||
import net.minecraft.network.play.client.CPacketHeldItemChange;
|
||||
import net.minecraft.network.play.client.CPacketInput;
|
||||
import net.minecraft.network.play.client.CPacketKeepAlive;
|
||||
import net.minecraft.network.play.client.CPacketPlaceRecipe;
|
||||
import net.minecraft.network.play.client.CPacketPlayer;
|
||||
import net.minecraft.network.play.client.CPacketPlayerAbilities;
|
||||
import net.minecraft.network.play.client.CPacketPlayerDigging;
|
||||
import net.minecraft.network.play.client.CPacketPlayerTryUseItem;
|
||||
import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock;
|
||||
import net.minecraft.network.play.client.CPacketRecipeInfo;
|
||||
import net.minecraft.network.play.client.CPacketResourcePackStatus;
|
||||
import net.minecraft.network.play.client.CPacketSeenAdvancements;
|
||||
import net.minecraft.network.play.client.CPacketSpectate;
|
||||
import net.minecraft.network.play.client.CPacketSteerBoat;
|
||||
import net.minecraft.network.play.client.CPacketTabComplete;
|
||||
import net.minecraft.network.play.client.CPacketUpdateSign;
|
||||
import net.minecraft.network.play.client.CPacketUseEntity;
|
||||
import net.minecraft.network.play.client.CPacketVehicleMove;
|
||||
import net.minecraft.network.play.server.SPacketAdvancementInfo;
|
||||
import net.minecraft.network.play.server.SPacketAnimation;
|
||||
import net.minecraft.network.play.server.SPacketBlockAction;
|
||||
import net.minecraft.network.play.server.SPacketBlockBreakAnim;
|
||||
import net.minecraft.network.play.server.SPacketBlockChange;
|
||||
import net.minecraft.network.play.server.SPacketCamera;
|
||||
import net.minecraft.network.play.server.SPacketChangeGameState;
|
||||
import net.minecraft.network.play.server.SPacketChat;
|
||||
import net.minecraft.network.play.server.SPacketChunkData;
|
||||
import net.minecraft.network.play.server.SPacketCloseWindow;
|
||||
import net.minecraft.network.play.server.SPacketCollectItem;
|
||||
import net.minecraft.network.play.server.SPacketCombatEvent;
|
||||
import net.minecraft.network.play.server.SPacketConfirmTransaction;
|
||||
import net.minecraft.network.play.server.SPacketCooldown;
|
||||
import net.minecraft.network.play.server.SPacketCustomPayload;
|
||||
import net.minecraft.network.play.server.SPacketCustomSound;
|
||||
import net.minecraft.network.play.server.SPacketDestroyEntities;
|
||||
import net.minecraft.network.play.server.SPacketDisconnect;
|
||||
import net.minecraft.network.play.server.SPacketDisplayObjective;
|
||||
import net.minecraft.network.play.server.SPacketEffect;
|
||||
import net.minecraft.network.play.server.SPacketEntity;
|
||||
import net.minecraft.network.play.server.SPacketEntityAttach;
|
||||
import net.minecraft.network.play.server.SPacketEntityEffect;
|
||||
import net.minecraft.network.play.server.SPacketEntityEquipment;
|
||||
import net.minecraft.network.play.server.SPacketEntityHeadLook;
|
||||
import net.minecraft.network.play.server.SPacketEntityMetadata;
|
||||
import net.minecraft.network.play.server.SPacketEntityProperties;
|
||||
import net.minecraft.network.play.server.SPacketEntityStatus;
|
||||
import net.minecraft.network.play.server.SPacketEntityTeleport;
|
||||
import net.minecraft.network.play.server.SPacketEntityVelocity;
|
||||
import net.minecraft.network.play.server.SPacketExplosion;
|
||||
import net.minecraft.network.play.server.SPacketHeldItemChange;
|
||||
import net.minecraft.network.play.server.SPacketJoinGame;
|
||||
import net.minecraft.network.play.server.SPacketKeepAlive;
|
||||
import net.minecraft.network.play.server.SPacketMaps;
|
||||
import net.minecraft.network.play.server.SPacketMoveVehicle;
|
||||
import net.minecraft.network.play.server.SPacketMultiBlockChange;
|
||||
import net.minecraft.network.play.server.SPacketOpenWindow;
|
||||
import net.minecraft.network.play.server.SPacketParticles;
|
||||
import net.minecraft.network.play.server.SPacketPlaceGhostRecipe;
|
||||
import net.minecraft.network.play.server.SPacketPlayerAbilities;
|
||||
import net.minecraft.network.play.server.SPacketPlayerListHeaderFooter;
|
||||
import net.minecraft.network.play.server.SPacketPlayerListItem;
|
||||
import net.minecraft.network.play.server.SPacketPlayerPosLook;
|
||||
import net.minecraft.network.play.server.SPacketRecipeBook;
|
||||
import net.minecraft.network.play.server.SPacketRemoveEntityEffect;
|
||||
import net.minecraft.network.play.server.SPacketResourcePackSend;
|
||||
import net.minecraft.network.play.server.SPacketRespawn;
|
||||
import net.minecraft.network.play.server.SPacketScoreboardObjective;
|
||||
import net.minecraft.network.play.server.SPacketSelectAdvancementsTab;
|
||||
import net.minecraft.network.play.server.SPacketServerDifficulty;
|
||||
import net.minecraft.network.play.server.SPacketSetExperience;
|
||||
import net.minecraft.network.play.server.SPacketSetPassengers;
|
||||
import net.minecraft.network.play.server.SPacketSetSlot;
|
||||
import net.minecraft.network.play.server.SPacketSignEditorOpen;
|
||||
import net.minecraft.network.play.server.SPacketSoundEffect;
|
||||
import net.minecraft.network.play.server.SPacketSpawnExperienceOrb;
|
||||
import net.minecraft.network.play.server.SPacketSpawnGlobalEntity;
|
||||
import net.minecraft.network.play.server.SPacketSpawnMob;
|
||||
import net.minecraft.network.play.server.SPacketSpawnObject;
|
||||
import net.minecraft.network.play.server.SPacketSpawnPainting;
|
||||
import net.minecraft.network.play.server.SPacketSpawnPlayer;
|
||||
import net.minecraft.network.play.server.SPacketSpawnPosition;
|
||||
import net.minecraft.network.play.server.SPacketStatistics;
|
||||
import net.minecraft.network.play.server.SPacketTabComplete;
|
||||
import net.minecraft.network.play.server.SPacketTeams;
|
||||
import net.minecraft.network.play.server.SPacketTimeUpdate;
|
||||
import net.minecraft.network.play.server.SPacketTitle;
|
||||
import net.minecraft.network.play.server.SPacketUnloadChunk;
|
||||
import net.minecraft.network.play.server.SPacketUpdateBossInfo;
|
||||
import net.minecraft.network.play.server.SPacketUpdateHealth;
|
||||
import net.minecraft.network.play.server.SPacketUpdateScore;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.network.play.server.SPacketUseBed;
|
||||
import net.minecraft.network.play.server.SPacketWindowItems;
|
||||
import net.minecraft.network.play.server.SPacketWindowProperty;
|
||||
import net.minecraft.network.play.server.SPacketWorldBorder;
|
||||
import net.minecraft.network.status.client.CPacketPing;
|
||||
import net.minecraft.network.status.client.CPacketServerQuery;
|
||||
import net.minecraft.network.status.server.SPacketPong;
|
||||
import net.minecraft.network.status.server.SPacketServerInfo;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
public enum EnumConnectionState
|
||||
{
|
||||
HANDSHAKING(-1)
|
||||
{
|
||||
{
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C00Handshake.class);
|
||||
}
|
||||
},
|
||||
PLAY(0)
|
||||
{
|
||||
{
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketSpawnObject.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketSpawnExperienceOrb.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketSpawnGlobalEntity.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketSpawnMob.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketSpawnPainting.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketSpawnPlayer.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketAnimation.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketStatistics.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketBlockBreakAnim.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketUpdateTileEntity.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketBlockAction.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketBlockChange.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketUpdateBossInfo.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketServerDifficulty.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketTabComplete.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketChat.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketMultiBlockChange.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketConfirmTransaction.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketCloseWindow.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketOpenWindow.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketWindowItems.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketWindowProperty.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketSetSlot.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketCooldown.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketCustomPayload.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketCustomSound.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketDisconnect.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketEntityStatus.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketExplosion.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketUnloadChunk.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketChangeGameState.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketKeepAlive.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketChunkData.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketEffect.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketParticles.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketJoinGame.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketMaps.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketEntity.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketEntity.S15PacketEntityRelMove.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketEntity.S17PacketEntityLookMove.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketEntity.S16PacketEntityLook.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketMoveVehicle.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketSignEditorOpen.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketPlaceGhostRecipe.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketPlayerAbilities.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketCombatEvent.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketPlayerListItem.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketPlayerPosLook.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketUseBed.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketRecipeBook.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketDestroyEntities.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketRemoveEntityEffect.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketResourcePackSend.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketRespawn.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketEntityHeadLook.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketSelectAdvancementsTab.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketWorldBorder.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketCamera.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketHeldItemChange.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketDisplayObjective.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketEntityMetadata.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketEntityAttach.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketEntityVelocity.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketEntityEquipment.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketSetExperience.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketUpdateHealth.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketScoreboardObjective.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketSetPassengers.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketTeams.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketUpdateScore.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketSpawnPosition.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketTimeUpdate.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketTitle.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketSoundEffect.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketPlayerListHeaderFooter.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketCollectItem.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketEntityTeleport.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketAdvancementInfo.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketEntityProperties.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketEntityEffect.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketConfirmTeleport.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketTabComplete.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketChatMessage.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketClientStatus.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketClientSettings.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketConfirmTransaction.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketEnchantItem.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketClickWindow.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketCloseWindow.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketCustomPayload.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketUseEntity.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketKeepAlive.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketPlayer.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketPlayer.Position.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketPlayer.PositionRotation.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketPlayer.Rotation.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketVehicleMove.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketSteerBoat.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketPlaceRecipe.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketPlayerAbilities.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketPlayerDigging.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketEntityAction.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketInput.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketRecipeInfo.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketResourcePackStatus.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketSeenAdvancements.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketHeldItemChange.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketCreativeInventoryAction.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketUpdateSign.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketAnimation.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketSpectate.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketPlayerTryUseItemOnBlock.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketPlayerTryUseItem.class);
|
||||
}
|
||||
},
|
||||
STATUS(1)
|
||||
{
|
||||
{
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketServerQuery.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketServerInfo.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketPing.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketPong.class);
|
||||
}
|
||||
},
|
||||
LOGIN(2)
|
||||
{
|
||||
{
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, net.minecraft.network.login.server.SPacketDisconnect.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketEncryptionRequest.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketLoginSuccess.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, SPacketEnableCompression.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketLoginStart.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, CPacketEncryptionResponse.class);
|
||||
}
|
||||
};
|
||||
|
||||
private static final EnumConnectionState[] STATES_BY_ID = new EnumConnectionState[4];
|
||||
private static final Map < Class <? extends Packet<? >> , EnumConnectionState > STATES_BY_CLASS = Maps. < Class <? extends Packet<? >> , EnumConnectionState > newHashMap();
|
||||
private final int id;
|
||||
private final Map < EnumPacketDirection, BiMap < Integer, Class <? extends Packet<? >>> > directionMaps;
|
||||
|
||||
private EnumConnectionState(int protocolId)
|
||||
{
|
||||
this.directionMaps = Maps.newEnumMap(EnumPacketDirection.class);
|
||||
this.id = protocolId;
|
||||
}
|
||||
|
||||
protected EnumConnectionState registerPacket(EnumPacketDirection direction, Class <? extends Packet<? >> packetClass)
|
||||
{
|
||||
BiMap < Integer, Class <? extends Packet<? >>> bimap = (BiMap)this.directionMaps.get(direction);
|
||||
|
||||
if (bimap == null)
|
||||
{
|
||||
bimap = HashBiMap. < Integer, Class <? extends Packet<? >>> create();
|
||||
this.directionMaps.put(direction, bimap);
|
||||
}
|
||||
|
||||
if (bimap.containsValue(packetClass))
|
||||
{
|
||||
String s = direction + " packet " + packetClass + " is already known to ID " + bimap.inverse().get(packetClass);
|
||||
LogManager.getLogger().fatal(s);
|
||||
throw new IllegalArgumentException(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
bimap.put(Integer.valueOf(bimap.size()), packetClass);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getPacketId(EnumPacketDirection direction, Packet<?> packetIn) throws Exception
|
||||
{
|
||||
return (Integer)((BiMap)this.directionMaps.get(direction)).inverse().get(packetIn.getClass());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Packet<?> getPacket(EnumPacketDirection direction, int packetId) throws InstantiationException, IllegalAccessException
|
||||
{
|
||||
Class <? extends Packet<? >> oclass = (Class)((BiMap)this.directionMaps.get(direction)).get(Integer.valueOf(packetId));
|
||||
return oclass == null ? null : (Packet)oclass.newInstance();
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public static EnumConnectionState getById(int stateId)
|
||||
{
|
||||
return stateId >= -1 && stateId <= 2 ? STATES_BY_ID[stateId - -1] : null;
|
||||
}
|
||||
|
||||
public static EnumConnectionState getFromPacket(Packet<?> packetIn)
|
||||
{
|
||||
return STATES_BY_CLASS.get(packetIn.getClass());
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
for (EnumConnectionState enumconnectionstate : values())
|
||||
{
|
||||
int i = enumconnectionstate.getId();
|
||||
|
||||
if (i < -1 || i > 2)
|
||||
{
|
||||
throw new Error("Invalid protocol ID " + Integer.toString(i));
|
||||
}
|
||||
|
||||
STATES_BY_ID[i - -1] = enumconnectionstate;
|
||||
|
||||
for (EnumPacketDirection enumpacketdirection : enumconnectionstate.directionMaps.keySet())
|
||||
{
|
||||
for (Class <? extends Packet<? >> oclass : enumconnectionstate.directionMaps.get(enumpacketdirection).values())
|
||||
{
|
||||
if (STATES_BY_CLASS.containsKey(oclass) && STATES_BY_CLASS.get(oclass) != enumconnectionstate)
|
||||
{
|
||||
throw new Error("Packet " + oclass + " is already assigned to protocol " + STATES_BY_CLASS.get(oclass) + " - can't reassign to " + enumconnectionstate);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
oclass.newInstance();
|
||||
}
|
||||
catch (Throwable var10)
|
||||
{
|
||||
throw new Error("Packet " + oclass + " fails instantiation checks! " + oclass);
|
||||
}
|
||||
|
||||
STATES_BY_CLASS.put(oclass, enumconnectionstate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package net.minecraft.network;
|
||||
|
||||
public enum EnumPacketDirection
|
||||
{
|
||||
SERVERBOUND,
|
||||
CLIENTBOUND;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package net.minecraft.network;
|
||||
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public interface INetHandler
|
||||
{
|
||||
/**
|
||||
* Invoked when disconnecting, the parameter is a ChatComponent describing the reason for termination
|
||||
*/
|
||||
void onDisconnect(ITextComponent reason);
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package net.minecraft.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class LegacyPingHandler extends ChannelInboundHandlerAdapter
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private final NetworkSystem networkSystem;
|
||||
|
||||
public LegacyPingHandler(NetworkSystem networkSystemIn)
|
||||
{
|
||||
this.networkSystem = networkSystemIn;
|
||||
}
|
||||
|
||||
public void channelRead(ChannelHandlerContext p_channelRead_1_, Object p_channelRead_2_) throws Exception
|
||||
{
|
||||
ByteBuf bytebuf = (ByteBuf)p_channelRead_2_;
|
||||
bytebuf.markReaderIndex();
|
||||
boolean flag = true;
|
||||
|
||||
try
|
||||
{
|
||||
if (bytebuf.readUnsignedByte() == 254)
|
||||
{
|
||||
InetSocketAddress inetsocketaddress = (InetSocketAddress)p_channelRead_1_.channel().remoteAddress();
|
||||
MinecraftServer minecraftserver = this.networkSystem.getServer();
|
||||
int i = bytebuf.readableBytes();
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
LOGGER.debug("Ping: (<1.3.x) from {}:{}", inetsocketaddress.getAddress(), Integer.valueOf(inetsocketaddress.getPort()));
|
||||
String s2 = String.format("%s\u00a7%d\u00a7%d", minecraftserver.getMOTD(), minecraftserver.getCurrentPlayerCount(), minecraftserver.getMaxPlayers());
|
||||
this.writeAndFlush(p_channelRead_1_, this.getStringBuffer(s2));
|
||||
break;
|
||||
case 1:
|
||||
|
||||
if (bytebuf.readUnsignedByte() != 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LOGGER.debug("Ping: (1.4-1.5.x) from {}:{}", inetsocketaddress.getAddress(), Integer.valueOf(inetsocketaddress.getPort()));
|
||||
String s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", Integer.valueOf(127), minecraftserver.getMinecraftVersion(), minecraftserver.getMOTD(), minecraftserver.getCurrentPlayerCount(), minecraftserver.getMaxPlayers());
|
||||
this.writeAndFlush(p_channelRead_1_, this.getStringBuffer(s));
|
||||
break;
|
||||
default:
|
||||
boolean flag1 = bytebuf.readUnsignedByte() == 1;
|
||||
flag1 = flag1 & bytebuf.readUnsignedByte() == 250;
|
||||
flag1 = flag1 & "MC|PingHost".equals(new String(bytebuf.readBytes(bytebuf.readShort() * 2).array(), StandardCharsets.UTF_16BE));
|
||||
int j = bytebuf.readUnsignedShort();
|
||||
flag1 = flag1 & bytebuf.readUnsignedByte() >= 73;
|
||||
flag1 = flag1 & 3 + bytebuf.readBytes(bytebuf.readShort() * 2).array().length + 4 == j;
|
||||
flag1 = flag1 & bytebuf.readInt() <= 65535;
|
||||
flag1 = flag1 & bytebuf.readableBytes() == 0;
|
||||
|
||||
if (!flag1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LOGGER.debug("Ping: (1.6) from {}:{}", inetsocketaddress.getAddress(), Integer.valueOf(inetsocketaddress.getPort()));
|
||||
String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", Integer.valueOf(127), minecraftserver.getMinecraftVersion(), minecraftserver.getMOTD(), minecraftserver.getCurrentPlayerCount(), minecraftserver.getMaxPlayers());
|
||||
ByteBuf bytebuf1 = this.getStringBuffer(s1);
|
||||
|
||||
try
|
||||
{
|
||||
this.writeAndFlush(p_channelRead_1_, bytebuf1);
|
||||
}
|
||||
finally
|
||||
{
|
||||
bytebuf1.release();
|
||||
}
|
||||
}
|
||||
|
||||
bytebuf.release();
|
||||
flag = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (RuntimeException var21)
|
||||
{
|
||||
return;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
bytebuf.resetReaderIndex();
|
||||
p_channelRead_1_.channel().pipeline().remove("legacy_query");
|
||||
p_channelRead_1_.fireChannelRead(p_channelRead_2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void writeAndFlush(ChannelHandlerContext ctx, ByteBuf data)
|
||||
{
|
||||
ctx.pipeline().firstContext().writeAndFlush(data).addListener(ChannelFutureListener.CLOSE);
|
||||
}
|
||||
|
||||
private ByteBuf getStringBuffer(String string)
|
||||
{
|
||||
ByteBuf bytebuf = Unpooled.buffer();
|
||||
bytebuf.writeByte(255);
|
||||
char[] achar = string.toCharArray();
|
||||
bytebuf.writeShort(achar.length);
|
||||
|
||||
for (char c0 : achar)
|
||||
{
|
||||
bytebuf.writeChar(c0);
|
||||
}
|
||||
|
||||
return bytebuf;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,61 @@
|
||||
package net.minecraft.network;
|
||||
|
||||
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;
|
||||
import java.util.List;
|
||||
import java.util.zip.DataFormatException;
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
public class NettyCompressionDecoder extends ByteToMessageDecoder
|
||||
{
|
||||
private final Inflater inflater;
|
||||
private int threshold;
|
||||
|
||||
public NettyCompressionDecoder(int thresholdIn)
|
||||
{
|
||||
this.threshold = thresholdIn;
|
||||
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.readVarInt();
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
p_decode_3_.add(packetbuffer.readBytes(packetbuffer.readableBytes()));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i < this.threshold)
|
||||
{
|
||||
throw new DecoderException("Badly compressed packet - size of " + i + " is below server threshold of " + this.threshold);
|
||||
}
|
||||
|
||||
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 setCompressionThreshold(int thresholdIn)
|
||||
{
|
||||
this.threshold = thresholdIn;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package net.minecraft.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
import java.util.zip.Deflater;
|
||||
|
||||
public class NettyCompressionEncoder extends MessageToByteEncoder<ByteBuf>
|
||||
{
|
||||
private final byte[] buffer = new byte[8192];
|
||||
private final Deflater deflater;
|
||||
private int threshold;
|
||||
|
||||
public NettyCompressionEncoder(int thresholdIn)
|
||||
{
|
||||
this.threshold = thresholdIn;
|
||||
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.threshold)
|
||||
{
|
||||
packetbuffer.writeVarInt(0);
|
||||
packetbuffer.writeBytes(p_encode_2_);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] abyte = new byte[i];
|
||||
p_encode_2_.readBytes(abyte);
|
||||
packetbuffer.writeVarInt(abyte.length);
|
||||
this.deflater.setInput(abyte, 0, i);
|
||||
this.deflater.finish();
|
||||
|
||||
while (!this.deflater.finished())
|
||||
{
|
||||
int j = this.deflater.deflate(this.buffer);
|
||||
packetbuffer.writeBytes(this.buffer, 0, j);
|
||||
}
|
||||
|
||||
this.deflater.reset();
|
||||
}
|
||||
}
|
||||
|
||||
public void setCompressionThreshold(int thresholdIn)
|
||||
{
|
||||
this.threshold = thresholdIn;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package net.minecraft.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToMessageDecoder;
|
||||
import java.util.List;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.ShortBufferException;
|
||||
|
||||
public class NettyEncryptingDecoder extends MessageToMessageDecoder<ByteBuf>
|
||||
{
|
||||
private final NettyEncryptionTranslator decryptionCodec;
|
||||
|
||||
public NettyEncryptingDecoder(Cipher cipher)
|
||||
{
|
||||
this.decryptionCodec = new NettyEncryptionTranslator(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.decryptionCodec.decipher(p_decode_1_, p_decode_2_));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package net.minecraft.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.ShortBufferException;
|
||||
|
||||
public class NettyEncryptingEncoder extends MessageToByteEncoder<ByteBuf>
|
||||
{
|
||||
private final NettyEncryptionTranslator encryptionCodec;
|
||||
|
||||
public NettyEncryptingEncoder(Cipher cipher)
|
||||
{
|
||||
this.encryptionCodec = new NettyEncryptionTranslator(cipher);
|
||||
}
|
||||
|
||||
protected void encode(ChannelHandlerContext p_encode_1_, ByteBuf p_encode_2_, ByteBuf p_encode_3_) throws ShortBufferException, Exception
|
||||
{
|
||||
this.encryptionCodec.cipher(p_encode_2_, p_encode_3_);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package net.minecraft.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.ShortBufferException;
|
||||
|
||||
public class NettyEncryptionTranslator
|
||||
{
|
||||
private final Cipher cipher;
|
||||
private byte[] inputBuffer = new byte[0];
|
||||
private byte[] outputBuffer = new byte[0];
|
||||
|
||||
protected NettyEncryptionTranslator(Cipher cipherIn)
|
||||
{
|
||||
this.cipher = cipherIn;
|
||||
}
|
||||
|
||||
private byte[] bufToBytes(ByteBuf buf)
|
||||
{
|
||||
int i = buf.readableBytes();
|
||||
|
||||
if (this.inputBuffer.length < i)
|
||||
{
|
||||
this.inputBuffer = new byte[i];
|
||||
}
|
||||
|
||||
buf.readBytes(this.inputBuffer, 0, i);
|
||||
return this.inputBuffer;
|
||||
}
|
||||
|
||||
protected ByteBuf decipher(ChannelHandlerContext ctx, ByteBuf buffer) throws ShortBufferException
|
||||
{
|
||||
int i = buffer.readableBytes();
|
||||
byte[] abyte = this.bufToBytes(buffer);
|
||||
ByteBuf bytebuf = ctx.alloc().heapBuffer(this.cipher.getOutputSize(i));
|
||||
bytebuf.writerIndex(this.cipher.update(abyte, 0, i, bytebuf.array(), bytebuf.arrayOffset()));
|
||||
return bytebuf;
|
||||
}
|
||||
|
||||
protected void cipher(ByteBuf in, ByteBuf out) throws ShortBufferException
|
||||
{
|
||||
int i = in.readableBytes();
|
||||
byte[] abyte = this.bufToBytes(in);
|
||||
int j = this.cipher.getOutputSize(i);
|
||||
|
||||
if (this.outputBuffer.length < j)
|
||||
{
|
||||
this.outputBuffer = new byte[j];
|
||||
}
|
||||
|
||||
out.writeBytes(this.outputBuffer, 0, this.cipher.update(abyte, 0, i, this.outputBuffer));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package net.minecraft.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
import org.apache.logging.log4j.MarkerManager;
|
||||
|
||||
public class NettyPacketDecoder extends ByteToMessageDecoder
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final Marker RECEIVED_PACKET_MARKER = MarkerManager.getMarker("PACKET_RECEIVED", NetworkManager.NETWORK_PACKETS_MARKER);
|
||||
private final EnumPacketDirection direction;
|
||||
|
||||
public NettyPacketDecoder(EnumPacketDirection direction)
|
||||
{
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
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.readVarInt();
|
||||
Packet<?> packet = ((EnumConnectionState)p_decode_1_.channel().attr(NetworkManager.PROTOCOL_ATTRIBUTE_KEY).get()).getPacket(this.direction, i);
|
||||
|
||||
if (packet == null)
|
||||
{
|
||||
throw new IOException("Bad packet id " + i);
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.readPacketData(packetbuffer);
|
||||
|
||||
if (packetbuffer.readableBytes() > 0)
|
||||
{
|
||||
throw new IOException("Packet " + ((EnumConnectionState)p_decode_1_.channel().attr(NetworkManager.PROTOCOL_ATTRIBUTE_KEY).get()).getId() + "/" + i + " (" + packet.getClass().getSimpleName() + ") was larger than I expected, found " + packetbuffer.readableBytes() + " bytes extra whilst reading packet " + i);
|
||||
}
|
||||
else
|
||||
{
|
||||
p_decode_3_.add(packet);
|
||||
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
LOGGER.debug(RECEIVED_PACKET_MARKER, " IN: [{}:{}] {}", p_decode_1_.channel().attr(NetworkManager.PROTOCOL_ATTRIBUTE_KEY).get(), Integer.valueOf(i), packet.getClass().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package net.minecraft.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
import java.io.IOException;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
import org.apache.logging.log4j.MarkerManager;
|
||||
|
||||
public class NettyPacketEncoder extends MessageToByteEncoder < Packet<? >>
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final Marker RECEIVED_PACKET_MARKER = MarkerManager.getMarker("PACKET_SENT", NetworkManager.NETWORK_PACKETS_MARKER);
|
||||
private final EnumPacketDirection direction;
|
||||
|
||||
public NettyPacketEncoder(EnumPacketDirection direction)
|
||||
{
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
protected void encode(ChannelHandlerContext p_encode_1_, Packet<?> p_encode_2_, ByteBuf p_encode_3_) throws IOException, Exception
|
||||
{
|
||||
EnumConnectionState enumconnectionstate = (EnumConnectionState)p_encode_1_.channel().attr(NetworkManager.PROTOCOL_ATTRIBUTE_KEY).get();
|
||||
|
||||
if (enumconnectionstate == null)
|
||||
{
|
||||
throw new RuntimeException("ConnectionProtocol unknown: " + p_encode_2_.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
Integer integer = enumconnectionstate.getPacketId(this.direction, p_encode_2_);
|
||||
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
LOGGER.debug(RECEIVED_PACKET_MARKER, "OUT: [{}:{}] {}", p_encode_1_.channel().attr(NetworkManager.PROTOCOL_ATTRIBUTE_KEY).get(), integer, p_encode_2_.getClass().getName());
|
||||
}
|
||||
|
||||
if (integer == null)
|
||||
{
|
||||
throw new IOException("Can't serialize unregistered packet");
|
||||
}
|
||||
else
|
||||
{
|
||||
PacketBuffer packetbuffer = new PacketBuffer(p_encode_3_);
|
||||
packetbuffer.writeVarInt(integer.intValue());
|
||||
|
||||
try
|
||||
{
|
||||
p_encode_2_.writePacketData(packetbuffer);
|
||||
}
|
||||
catch (Throwable throwable)
|
||||
{
|
||||
throw throwable; // Forge: throw this instead of logging it, to prevent corrupt packets from being sent to the client where they are much harder to debug.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package net.minecraft.network;
|
||||
|
||||
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.CorruptedFrameException;
|
||||
import java.util.List;
|
||||
|
||||
public class NettyVarint21FrameDecoder 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.readVarInt();
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package net.minecraft.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
|
||||
@Sharable
|
||||
public class NettyVarint21FrameEncoder 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.writeVarInt(i);
|
||||
packetbuffer.writeBytes(p_encode_2_, p_encode_2_.readerIndex(), i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,533 @@
|
||||
package net.minecraft.network;
|
||||
|
||||
import com.google.common.collect.Queues;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelException;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.channel.epoll.Epoll;
|
||||
import io.netty.channel.epoll.EpollEventLoopGroup;
|
||||
import io.netty.channel.epoll.EpollSocketChannel;
|
||||
import io.netty.channel.local.LocalChannel;
|
||||
import io.netty.channel.local.LocalEventLoopGroup;
|
||||
import io.netty.channel.local.LocalServerChannel;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import io.netty.handler.timeout.ReadTimeoutHandler;
|
||||
import io.netty.handler.timeout.TimeoutException;
|
||||
import io.netty.util.AttributeKey;
|
||||
import io.netty.util.concurrent.Future;
|
||||
import io.netty.util.concurrent.GenericFutureListener;
|
||||
import java.net.InetAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.crypto.SecretKey;
|
||||
import net.minecraft.util.CryptManager;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.LazyLoadBase;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
import org.apache.logging.log4j.MarkerManager;
|
||||
|
||||
public class NetworkManager extends SimpleChannelInboundHandler < Packet<? >>
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final Marker NETWORK_MARKER = MarkerManager.getMarker("NETWORK");
|
||||
public static final Marker NETWORK_PACKETS_MARKER = MarkerManager.getMarker("NETWORK_PACKETS", NETWORK_MARKER);
|
||||
public static final AttributeKey<EnumConnectionState> PROTOCOL_ATTRIBUTE_KEY = AttributeKey.<EnumConnectionState>valueOf("protocol");
|
||||
public static final LazyLoadBase<NioEventLoopGroup> CLIENT_NIO_EVENTLOOP = new LazyLoadBase<NioEventLoopGroup>()
|
||||
{
|
||||
protected NioEventLoopGroup load()
|
||||
{
|
||||
return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Client IO #%d").setDaemon(true).build());
|
||||
}
|
||||
};
|
||||
public static final LazyLoadBase<EpollEventLoopGroup> CLIENT_EPOLL_EVENTLOOP = new LazyLoadBase<EpollEventLoopGroup>()
|
||||
{
|
||||
protected EpollEventLoopGroup load()
|
||||
{
|
||||
return new EpollEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Client IO #%d").setDaemon(true).build());
|
||||
}
|
||||
};
|
||||
public static final LazyLoadBase<LocalEventLoopGroup> CLIENT_LOCAL_EVENTLOOP = new LazyLoadBase<LocalEventLoopGroup>()
|
||||
{
|
||||
protected LocalEventLoopGroup load()
|
||||
{
|
||||
return new LocalEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Local Client IO #%d").setDaemon(true).build());
|
||||
}
|
||||
};
|
||||
private final EnumPacketDirection direction;
|
||||
/** The queue for packets that require transmission */
|
||||
private final Queue<NetworkManager.InboundHandlerTuplePacketListener> outboundPacketsQueue = Queues.<NetworkManager.InboundHandlerTuplePacketListener>newConcurrentLinkedQueue();
|
||||
private final ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock();
|
||||
/** The active channel */
|
||||
private Channel channel;
|
||||
/** The address of the remote party */
|
||||
private SocketAddress socketAddress;
|
||||
/** The INetHandler instance responsible for processing received packets */
|
||||
private INetHandler packetListener;
|
||||
/** A String indicating why the network has shutdown. */
|
||||
private ITextComponent terminationReason;
|
||||
private boolean isEncrypted;
|
||||
private boolean disconnected;
|
||||
|
||||
public NetworkManager(EnumPacketDirection packetDirection)
|
||||
{
|
||||
this.direction = packetDirection;
|
||||
}
|
||||
|
||||
public EnumPacketDirection getDirection()
|
||||
{
|
||||
return this.direction;
|
||||
}
|
||||
|
||||
public void channelActive(ChannelHandlerContext p_channelActive_1_) throws Exception
|
||||
{
|
||||
super.channelActive(p_channelActive_1_);
|
||||
this.channel = p_channelActive_1_.channel();
|
||||
this.socketAddress = this.channel.remoteAddress();
|
||||
|
||||
try
|
||||
{
|
||||
this.setConnectionState(EnumConnectionState.HANDSHAKING);
|
||||
}
|
||||
catch (Throwable throwable)
|
||||
{
|
||||
LOGGER.fatal(throwable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new connection state and registers which packets this channel may send and receive
|
||||
*/
|
||||
public void setConnectionState(EnumConnectionState newState)
|
||||
{
|
||||
this.channel.attr(PROTOCOL_ATTRIBUTE_KEY).set(newState);
|
||||
this.channel.config().setAutoRead(true);
|
||||
LOGGER.debug("Enabled auto read");
|
||||
}
|
||||
|
||||
public void channelInactive(ChannelHandlerContext p_channelInactive_1_) throws Exception
|
||||
{
|
||||
this.closeChannel(new TextComponentTranslation("disconnect.endOfStream", new Object[0]));
|
||||
}
|
||||
|
||||
public void exceptionCaught(ChannelHandlerContext p_exceptionCaught_1_, Throwable p_exceptionCaught_2_) throws Exception
|
||||
{
|
||||
TextComponentTranslation textcomponenttranslation;
|
||||
|
||||
if (p_exceptionCaught_2_ instanceof TimeoutException)
|
||||
{
|
||||
textcomponenttranslation = new TextComponentTranslation("disconnect.timeout", new Object[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
textcomponenttranslation = new TextComponentTranslation("disconnect.genericReason", new Object[] {"Internal Exception: " + p_exceptionCaught_2_});
|
||||
}
|
||||
|
||||
LOGGER.debug(textcomponenttranslation.getUnformattedText(), p_exceptionCaught_2_);
|
||||
this.closeChannel(textcomponenttranslation);
|
||||
}
|
||||
|
||||
protected void channelRead0(ChannelHandlerContext p_channelRead0_1_, Packet<?> p_channelRead0_2_) throws Exception
|
||||
{
|
||||
if (this.channel.isOpen())
|
||||
{
|
||||
try
|
||||
{
|
||||
((Packet<INetHandler>)p_channelRead0_2_).processPacket(this.packetListener);
|
||||
}
|
||||
catch (ThreadQuickExitException var4)
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the NetHandler for this NetworkManager, no checks are made if this handler is suitable for the particular
|
||||
* connection state (protocol)
|
||||
*/
|
||||
public void setNetHandler(INetHandler handler)
|
||||
{
|
||||
Validate.notNull(handler, "packetListener");
|
||||
LOGGER.debug("Set listener of {} to {}", this, handler);
|
||||
this.packetListener = handler;
|
||||
}
|
||||
|
||||
public void sendPacket(Packet<?> packetIn)
|
||||
{
|
||||
if (this.isChannelOpen())
|
||||
{
|
||||
this.flushOutboundQueue();
|
||||
this.dispatchPacket(packetIn, (GenericFutureListener[])null);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.readWriteLock.writeLock().lock();
|
||||
|
||||
try
|
||||
{
|
||||
this.outboundPacketsQueue.add(new NetworkManager.InboundHandlerTuplePacketListener(packetIn, new GenericFutureListener[0]));
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.readWriteLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendPacket(Packet<?> packetIn, GenericFutureListener <? extends Future <? super Void >> listener, GenericFutureListener <? extends Future <? super Void >> ... listeners)
|
||||
{
|
||||
if (this.isChannelOpen())
|
||||
{
|
||||
this.flushOutboundQueue();
|
||||
this.dispatchPacket(packetIn, (GenericFutureListener[])ArrayUtils.add(listeners, 0, listener));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.readWriteLock.writeLock().lock();
|
||||
|
||||
try
|
||||
{
|
||||
this.outboundPacketsQueue.add(new NetworkManager.InboundHandlerTuplePacketListener(packetIn, (GenericFutureListener[])ArrayUtils.add(listeners, 0, listener)));
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.readWriteLock.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, @Nullable final GenericFutureListener <? extends Future <? super Void >> [] futureListeners)
|
||||
{
|
||||
final EnumConnectionState enumconnectionstate = EnumConnectionState.getFromPacket(inPacket);
|
||||
final EnumConnectionState enumconnectionstate1 = (EnumConnectionState)this.channel.attr(PROTOCOL_ATTRIBUTE_KEY).get();
|
||||
|
||||
if (enumconnectionstate1 != enumconnectionstate && !( inPacket instanceof net.minecraftforge.fml.common.network.internal.FMLProxyPacket))
|
||||
{
|
||||
LOGGER.debug("Disabled auto read");
|
||||
this.channel.config().setAutoRead(false);
|
||||
}
|
||||
|
||||
if (this.channel.eventLoop().inEventLoop())
|
||||
{
|
||||
if (enumconnectionstate != enumconnectionstate1 && !( inPacket instanceof net.minecraftforge.fml.common.network.internal.FMLProxyPacket))
|
||||
{
|
||||
this.setConnectionState(enumconnectionstate);
|
||||
}
|
||||
|
||||
ChannelFuture channelfuture = this.channel.writeAndFlush(inPacket);
|
||||
|
||||
if (futureListeners != null)
|
||||
{
|
||||
channelfuture.addListeners(futureListeners);
|
||||
}
|
||||
|
||||
channelfuture.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.channel.eventLoop().execute(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if (enumconnectionstate != enumconnectionstate1 && !( inPacket instanceof net.minecraftforge.fml.common.network.internal.FMLProxyPacket))
|
||||
{
|
||||
NetworkManager.this.setConnectionState(enumconnectionstate);
|
||||
}
|
||||
|
||||
ChannelFuture channelfuture1 = NetworkManager.this.channel.writeAndFlush(inPacket);
|
||||
|
||||
if (futureListeners != null)
|
||||
{
|
||||
channelfuture1.addListeners(futureListeners);
|
||||
}
|
||||
|
||||
channelfuture1.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Will iterate through the outboundPacketQueue and dispatch all Packets
|
||||
*/
|
||||
private void flushOutboundQueue()
|
||||
{
|
||||
if (this.channel != null && this.channel.isOpen())
|
||||
{
|
||||
this.readWriteLock.readLock().lock();
|
||||
|
||||
try
|
||||
{
|
||||
while (!this.outboundPacketsQueue.isEmpty())
|
||||
{
|
||||
NetworkManager.InboundHandlerTuplePacketListener networkmanager$inboundhandlertuplepacketlistener = this.outboundPacketsQueue.poll();
|
||||
this.dispatchPacket(networkmanager$inboundhandlertuplepacketlistener.packet, networkmanager$inboundhandlertuplepacketlistener.futureListeners);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.readWriteLock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks timeouts and processes all packets received
|
||||
*/
|
||||
public void processReceivedPackets()
|
||||
{
|
||||
this.flushOutboundQueue();
|
||||
|
||||
if (this.packetListener instanceof ITickable)
|
||||
{
|
||||
((ITickable)this.packetListener).update();
|
||||
}
|
||||
|
||||
if (this.channel != null)
|
||||
{
|
||||
this.channel.flush();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the socket address of the remote side. Server-only.
|
||||
*/
|
||||
public SocketAddress getRemoteAddress()
|
||||
{
|
||||
return this.socketAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the channel, the parameter can be used for an exit message (not certain how it gets sent)
|
||||
*/
|
||||
public void closeChannel(ITextComponent message)
|
||||
{
|
||||
if (this.channel.isOpen())
|
||||
{
|
||||
this.channel.close().awaitUninterruptibly();
|
||||
this.terminationReason = message;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* True if this NetworkManager uses a memory connection (single player game). False may imply both an active TCP
|
||||
* connection or simply no active connection at all
|
||||
*/
|
||||
public boolean isLocalChannel()
|
||||
{
|
||||
return this.channel instanceof LocalChannel || this.channel instanceof LocalServerChannel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new NetworkManager from the server host and connect it to the server
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static NetworkManager createNetworkManagerAndConnect(InetAddress address, int serverPort, boolean useNativeTransport)
|
||||
{
|
||||
if (address instanceof java.net.Inet6Address) System.setProperty("java.net.preferIPv4Stack", "false");
|
||||
final NetworkManager networkmanager = new NetworkManager(EnumPacketDirection.CLIENTBOUND);
|
||||
Class <? extends SocketChannel > oclass;
|
||||
LazyLoadBase <? extends EventLoopGroup > lazyloadbase;
|
||||
|
||||
if (Epoll.isAvailable() && useNativeTransport)
|
||||
{
|
||||
oclass = EpollSocketChannel.class;
|
||||
lazyloadbase = CLIENT_EPOLL_EVENTLOOP;
|
||||
}
|
||||
else
|
||||
{
|
||||
oclass = NioSocketChannel.class;
|
||||
lazyloadbase = CLIENT_NIO_EVENTLOOP;
|
||||
}
|
||||
|
||||
((Bootstrap)((Bootstrap)((Bootstrap)(new Bootstrap()).group(lazyloadbase.getValue())).handler(new ChannelInitializer<Channel>()
|
||||
{
|
||||
protected void initChannel(Channel p_initChannel_1_) throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
p_initChannel_1_.config().setOption(ChannelOption.TCP_NODELAY, Boolean.valueOf(true));
|
||||
}
|
||||
catch (ChannelException var3)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
p_initChannel_1_.pipeline().addLast("timeout", new ReadTimeoutHandler(30)).addLast("splitter", new NettyVarint21FrameDecoder()).addLast("decoder", new NettyPacketDecoder(EnumPacketDirection.CLIENTBOUND)).addLast("prepender", new NettyVarint21FrameEncoder()).addLast("encoder", new NettyPacketEncoder(EnumPacketDirection.SERVERBOUND)).addLast("packet_handler", networkmanager);
|
||||
}
|
||||
})).channel(oclass)).connect(address, serverPort).syncUninterruptibly();
|
||||
return networkmanager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a clientside NetworkManager: establishes a connection to the socket supplied and configures the channel
|
||||
* pipeline. Returns the newly created instance.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static NetworkManager provideLocalClient(SocketAddress address)
|
||||
{
|
||||
final NetworkManager networkmanager = new NetworkManager(EnumPacketDirection.CLIENTBOUND);
|
||||
((Bootstrap)((Bootstrap)((Bootstrap)(new Bootstrap()).group(CLIENT_LOCAL_EVENTLOOP.getValue())).handler(new ChannelInitializer<Channel>()
|
||||
{
|
||||
protected void initChannel(Channel p_initChannel_1_) throws Exception
|
||||
{
|
||||
p_initChannel_1_.pipeline().addLast("packet_handler", networkmanager);
|
||||
}
|
||||
})).channel(LocalChannel.class)).connect(address).syncUninterruptibly();
|
||||
return networkmanager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an encoder+decoder to the channel pipeline. The parameter is the secret key used for encrypted communication
|
||||
*/
|
||||
public void enableEncryption(SecretKey key)
|
||||
{
|
||||
this.isEncrypted = true;
|
||||
this.channel.pipeline().addBefore("splitter", "decrypt", new NettyEncryptingDecoder(CryptManager.createNetCipherInstance(2, key)));
|
||||
this.channel.pipeline().addBefore("prepender", "encrypt", new NettyEncryptingEncoder(CryptManager.createNetCipherInstance(1, key)));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean isEncrypted()
|
||||
{
|
||||
return this.isEncrypted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this NetworkManager has an active channel, false otherwise
|
||||
*/
|
||||
public boolean isChannelOpen()
|
||||
{
|
||||
return this.channel != null && this.channel.isOpen();
|
||||
}
|
||||
|
||||
public boolean hasNoChannel()
|
||||
{
|
||||
return this.channel == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current handler for processing packets
|
||||
*/
|
||||
public INetHandler getNetHandler()
|
||||
{
|
||||
return this.packetListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this channel is closed, returns the exit message, null otherwise.
|
||||
*/
|
||||
public ITextComponent getExitMessage()
|
||||
{
|
||||
return this.terminationReason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches the channel to manual reading modus
|
||||
*/
|
||||
public void disableAutoRead()
|
||||
{
|
||||
this.channel.config().setAutoRead(false);
|
||||
}
|
||||
|
||||
public void setCompressionThreshold(int threshold)
|
||||
{
|
||||
if (threshold >= 0)
|
||||
{
|
||||
if (this.channel.pipeline().get("decompress") instanceof NettyCompressionDecoder)
|
||||
{
|
||||
((NettyCompressionDecoder)this.channel.pipeline().get("decompress")).setCompressionThreshold(threshold);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.channel.pipeline().addBefore("decoder", "decompress", new NettyCompressionDecoder(threshold));
|
||||
}
|
||||
|
||||
if (this.channel.pipeline().get("compress") instanceof NettyCompressionEncoder)
|
||||
{
|
||||
((NettyCompressionEncoder)this.channel.pipeline().get("compress")).setCompressionThreshold(threshold);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.channel.pipeline().addBefore("encoder", "compress", new NettyCompressionEncoder(threshold));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.channel.pipeline().get("decompress") instanceof NettyCompressionDecoder)
|
||||
{
|
||||
this.channel.pipeline().remove("decompress");
|
||||
}
|
||||
|
||||
if (this.channel.pipeline().get("compress") instanceof NettyCompressionEncoder)
|
||||
{
|
||||
this.channel.pipeline().remove("compress");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkDisconnected()
|
||||
{
|
||||
if (this.channel != null && !this.channel.isOpen())
|
||||
{
|
||||
if (this.disconnected)
|
||||
{
|
||||
LOGGER.warn("handleDisconnection() called twice");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.disconnected = true;
|
||||
|
||||
if (this.getExitMessage() != null)
|
||||
{
|
||||
this.getNetHandler().onDisconnect(this.getExitMessage());
|
||||
}
|
||||
else if (this.getNetHandler() != null)
|
||||
{
|
||||
this.getNetHandler().onDisconnect(new TextComponentTranslation("multiplayer.disconnect.generic", new Object[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Channel channel()
|
||||
{
|
||||
return channel;
|
||||
}
|
||||
|
||||
static class InboundHandlerTuplePacketListener
|
||||
{
|
||||
private final Packet<?> packet;
|
||||
private final GenericFutureListener <? extends Future <? super Void >> [] futureListeners;
|
||||
|
||||
public InboundHandlerTuplePacketListener(Packet<?> inPacket, GenericFutureListener <? extends Future <? super Void >> ... inFutureListeners)
|
||||
{
|
||||
this.packet = inPacket;
|
||||
this.futureListeners = inFutureListeners;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
package net.minecraft.network;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelException;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.epoll.Epoll;
|
||||
import io.netty.channel.epoll.EpollEventLoopGroup;
|
||||
import io.netty.channel.epoll.EpollServerSocketChannel;
|
||||
import io.netty.channel.local.LocalAddress;
|
||||
import io.netty.channel.local.LocalEventLoopGroup;
|
||||
import io.netty.channel.local.LocalServerChannel;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.ServerSocketChannel;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
import io.netty.handler.timeout.ReadTimeoutHandler;
|
||||
import io.netty.util.concurrent.Future;
|
||||
import io.netty.util.concurrent.GenericFutureListener;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.network.NetHandlerHandshakeMemory;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
import net.minecraft.crash.ICrashReportDetail;
|
||||
import net.minecraft.network.play.server.SPacketDisconnect;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.NetHandlerHandshakeTCP;
|
||||
import net.minecraft.util.LazyLoadBase;
|
||||
import net.minecraft.util.ReportedException;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class NetworkSystem
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final LazyLoadBase<NioEventLoopGroup> SERVER_NIO_EVENTLOOP = new LazyLoadBase<NioEventLoopGroup>()
|
||||
{
|
||||
protected NioEventLoopGroup load()
|
||||
{
|
||||
return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Server IO #%d").setDaemon(true).setThreadFactory(net.minecraftforge.fml.common.thread.SidedThreadGroups.SERVER).build());
|
||||
}
|
||||
};
|
||||
public static final LazyLoadBase<EpollEventLoopGroup> SERVER_EPOLL_EVENTLOOP = new LazyLoadBase<EpollEventLoopGroup>()
|
||||
{
|
||||
protected EpollEventLoopGroup load()
|
||||
{
|
||||
return new EpollEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Server IO #%d").setDaemon(true).setThreadFactory(net.minecraftforge.fml.common.thread.SidedThreadGroups.SERVER).build());
|
||||
}
|
||||
};
|
||||
public static final LazyLoadBase<LocalEventLoopGroup> SERVER_LOCAL_EVENTLOOP = new LazyLoadBase<LocalEventLoopGroup>()
|
||||
{
|
||||
protected LocalEventLoopGroup load()
|
||||
{
|
||||
return new LocalEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Local Server IO #%d").setDaemon(true).setThreadFactory(net.minecraftforge.fml.common.thread.SidedThreadGroups.CLIENT).build());
|
||||
}
|
||||
};
|
||||
/** Reference to the MinecraftServer object. */
|
||||
private final MinecraftServer mcServer;
|
||||
/** True if this NetworkSystem has never had his endpoints terminated */
|
||||
public volatile boolean isAlive;
|
||||
/** Contains all endpoints added to this NetworkSystem */
|
||||
private final List<ChannelFuture> endpoints = Collections.<ChannelFuture>synchronizedList(Lists.newArrayList());
|
||||
/** A list containing all NetworkManager instances of all endpoints */
|
||||
private final List<NetworkManager> networkManagers = Collections.<NetworkManager>synchronizedList(Lists.newArrayList());
|
||||
|
||||
public NetworkSystem(MinecraftServer server)
|
||||
{
|
||||
this.mcServer = server;
|
||||
this.isAlive = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a channel that listens on publicly accessible network ports
|
||||
*/
|
||||
public void addLanEndpoint(InetAddress address, int port) throws IOException
|
||||
{
|
||||
if (address instanceof java.net.Inet6Address) System.setProperty("java.net.preferIPv4Stack", "false");
|
||||
synchronized (this.endpoints)
|
||||
{
|
||||
Class <? extends ServerSocketChannel > oclass;
|
||||
LazyLoadBase <? extends EventLoopGroup > lazyloadbase;
|
||||
|
||||
if (Epoll.isAvailable() && this.mcServer.shouldUseNativeTransport())
|
||||
{
|
||||
oclass = EpollServerSocketChannel.class;
|
||||
lazyloadbase = SERVER_EPOLL_EVENTLOOP;
|
||||
LOGGER.info("Using epoll channel type");
|
||||
}
|
||||
else
|
||||
{
|
||||
oclass = NioServerSocketChannel.class;
|
||||
lazyloadbase = SERVER_NIO_EVENTLOOP;
|
||||
LOGGER.info("Using default channel type");
|
||||
}
|
||||
|
||||
this.endpoints.add(((ServerBootstrap)((ServerBootstrap)(new ServerBootstrap()).channel(oclass)).childHandler(new ChannelInitializer<Channel>()
|
||||
{
|
||||
protected void initChannel(Channel p_initChannel_1_) throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
p_initChannel_1_.config().setOption(ChannelOption.TCP_NODELAY, Boolean.valueOf(true));
|
||||
}
|
||||
catch (ChannelException var3)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
p_initChannel_1_.pipeline().addLast("timeout", new ReadTimeoutHandler(net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.READ_TIMEOUT)).addLast("legacy_query", new LegacyPingHandler(NetworkSystem.this)).addLast("splitter", new NettyVarint21FrameDecoder()).addLast("decoder", new NettyPacketDecoder(EnumPacketDirection.SERVERBOUND)).addLast("prepender", new NettyVarint21FrameEncoder()).addLast("encoder", new NettyPacketEncoder(EnumPacketDirection.CLIENTBOUND));
|
||||
NetworkManager networkmanager = new NetworkManager(EnumPacketDirection.SERVERBOUND);
|
||||
NetworkSystem.this.networkManagers.add(networkmanager);
|
||||
p_initChannel_1_.pipeline().addLast("packet_handler", networkmanager);
|
||||
networkmanager.setNetHandler(new NetHandlerHandshakeTCP(NetworkSystem.this.mcServer, networkmanager));
|
||||
}
|
||||
}).group(lazyloadbase.getValue()).localAddress(address, port)).bind().syncUninterruptibly());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a channel that listens locally
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public SocketAddress addLocalEndpoint()
|
||||
{
|
||||
ChannelFuture channelfuture;
|
||||
|
||||
synchronized (this.endpoints)
|
||||
{
|
||||
channelfuture = ((ServerBootstrap)((ServerBootstrap)(new ServerBootstrap()).channel(LocalServerChannel.class)).childHandler(new ChannelInitializer<Channel>()
|
||||
{
|
||||
protected void initChannel(Channel p_initChannel_1_) throws Exception
|
||||
{
|
||||
NetworkManager networkmanager = new NetworkManager(EnumPacketDirection.SERVERBOUND);
|
||||
networkmanager.setNetHandler(new NetHandlerHandshakeMemory(NetworkSystem.this.mcServer, networkmanager));
|
||||
NetworkSystem.this.networkManagers.add(networkmanager);
|
||||
p_initChannel_1_.pipeline().addLast("packet_handler", networkmanager);
|
||||
}
|
||||
}).group(SERVER_NIO_EVENTLOOP.getValue()).localAddress(LocalAddress.ANY)).bind().syncUninterruptibly();
|
||||
this.endpoints.add(channelfuture);
|
||||
}
|
||||
|
||||
return channelfuture.channel().localAddress();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuts down all open endpoints (with immediate effect?)
|
||||
*/
|
||||
public void terminateEndpoints()
|
||||
{
|
||||
this.isAlive = false;
|
||||
|
||||
for (ChannelFuture channelfuture : this.endpoints)
|
||||
{
|
||||
try
|
||||
{
|
||||
channelfuture.channel().close().sync();
|
||||
}
|
||||
catch (InterruptedException var4)
|
||||
{
|
||||
LOGGER.error("Interrupted whilst closing channel");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Will try to process the packets received by each NetworkManager, gracefully manage processing failures and cleans
|
||||
* up dead connections
|
||||
*/
|
||||
public void networkTick()
|
||||
{
|
||||
synchronized (this.networkManagers)
|
||||
{
|
||||
Iterator<NetworkManager> iterator = this.networkManagers.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
final NetworkManager networkmanager = iterator.next();
|
||||
|
||||
if (!networkmanager.hasNoChannel())
|
||||
{
|
||||
if (networkmanager.isChannelOpen())
|
||||
{
|
||||
try
|
||||
{
|
||||
networkmanager.processReceivedPackets();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
if (networkmanager.isLocalChannel())
|
||||
{
|
||||
CrashReport crashreport = CrashReport.makeCrashReport(exception, "Ticking memory connection");
|
||||
CrashReportCategory crashreportcategory = crashreport.makeCategory("Ticking connection");
|
||||
crashreportcategory.addDetail("Connection", new ICrashReportDetail<String>()
|
||||
{
|
||||
public String call() throws Exception
|
||||
{
|
||||
return networkmanager.toString();
|
||||
}
|
||||
});
|
||||
throw new ReportedException(crashreport);
|
||||
}
|
||||
|
||||
LOGGER.warn("Failed to handle packet for {}", networkmanager.getRemoteAddress(), exception);
|
||||
final TextComponentString textcomponentstring = new TextComponentString("Internal server error");
|
||||
networkmanager.sendPacket(new SPacketDisconnect(textcomponentstring), new GenericFutureListener < Future <? super Void >> ()
|
||||
{
|
||||
public void operationComplete(Future <? super Void > p_operationComplete_1_) throws Exception
|
||||
{
|
||||
networkmanager.closeChannel(textcomponentstring);
|
||||
}
|
||||
});
|
||||
networkmanager.disableAutoRead();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
iterator.remove();
|
||||
networkmanager.checkDisconnected();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MinecraftServer getServer()
|
||||
{
|
||||
return this.mcServer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package net.minecraft.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface Packet<T extends INetHandler>
|
||||
{
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
void readPacketData(PacketBuffer buf) throws IOException;
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
void writePacketData(PacketBuffer buf) throws IOException;
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
void processPacket(T handler);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,27 @@
|
||||
package net.minecraft.network;
|
||||
|
||||
import net.minecraft.util.IThreadListener;
|
||||
|
||||
public class PacketThreadUtil
|
||||
{
|
||||
/**
|
||||
* Handles pumping inbound packets across threads by checking whether the current thread is actually the main thread
|
||||
* for the side in question. If not, then the packet is pumped into the handler queue in the main thread so that it
|
||||
* can be handled synchronously by the recipient, it then throws an exception to terminate the current packet
|
||||
* handler thread.
|
||||
*/
|
||||
public static <T extends INetHandler> void checkThreadAndEnqueue(final Packet<T> packetIn, final T processor, IThreadListener scheduler) throws ThreadQuickExitException
|
||||
{
|
||||
if (!scheduler.isCallingFromMinecraftThread())
|
||||
{
|
||||
scheduler.addScheduledTask(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
packetIn.processPacket(processor);
|
||||
}
|
||||
});
|
||||
throw ThreadQuickExitException.INSTANCE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
package net.minecraft.network;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class ServerStatusResponse
|
||||
{
|
||||
private ITextComponent description;
|
||||
private ServerStatusResponse.Players players;
|
||||
private ServerStatusResponse.Version version;
|
||||
private String favicon;
|
||||
|
||||
public ITextComponent getServerDescription()
|
||||
{
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setServerDescription(ITextComponent descriptionIn)
|
||||
{
|
||||
this.description = descriptionIn;
|
||||
invalidateJson();
|
||||
}
|
||||
|
||||
public ServerStatusResponse.Players getPlayers()
|
||||
{
|
||||
return this.players;
|
||||
}
|
||||
|
||||
public void setPlayers(ServerStatusResponse.Players playersIn)
|
||||
{
|
||||
this.players = playersIn;
|
||||
invalidateJson();
|
||||
}
|
||||
|
||||
public ServerStatusResponse.Version getVersion()
|
||||
{
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public void setVersion(ServerStatusResponse.Version versionIn)
|
||||
{
|
||||
this.version = versionIn;
|
||||
invalidateJson();
|
||||
}
|
||||
|
||||
public void setFavicon(String faviconBlob)
|
||||
{
|
||||
this.favicon = faviconBlob;
|
||||
invalidateJson();
|
||||
}
|
||||
|
||||
public String getFavicon()
|
||||
{
|
||||
return this.favicon;
|
||||
}
|
||||
|
||||
public static class Players
|
||||
{
|
||||
private final int maxPlayers;
|
||||
private final int onlinePlayerCount;
|
||||
private GameProfile[] players;
|
||||
|
||||
public Players(int maxOnlinePlayers, int onlinePlayers)
|
||||
{
|
||||
this.maxPlayers = maxOnlinePlayers;
|
||||
this.onlinePlayerCount = onlinePlayers;
|
||||
}
|
||||
|
||||
public int getMaxPlayers()
|
||||
{
|
||||
return this.maxPlayers;
|
||||
}
|
||||
|
||||
public int getOnlinePlayerCount()
|
||||
{
|
||||
return this.onlinePlayerCount;
|
||||
}
|
||||
|
||||
public GameProfile[] getPlayers()
|
||||
{
|
||||
return this.players;
|
||||
}
|
||||
|
||||
public void setPlayers(GameProfile[] playersIn)
|
||||
{
|
||||
this.players = playersIn;
|
||||
}
|
||||
|
||||
public static class Serializer implements JsonDeserializer<ServerStatusResponse.Players>, JsonSerializer<ServerStatusResponse.Players>
|
||||
{
|
||||
public ServerStatusResponse.Players deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
|
||||
{
|
||||
JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "players");
|
||||
ServerStatusResponse.Players serverstatusresponse$players = new ServerStatusResponse.Players(JsonUtils.getInt(jsonobject, "max"), JsonUtils.getInt(jsonobject, "online"));
|
||||
|
||||
if (JsonUtils.isJsonArray(jsonobject, "sample"))
|
||||
{
|
||||
JsonArray jsonarray = JsonUtils.getJsonArray(jsonobject, "sample");
|
||||
|
||||
if (jsonarray.size() > 0)
|
||||
{
|
||||
GameProfile[] agameprofile = new GameProfile[jsonarray.size()];
|
||||
|
||||
for (int i = 0; i < agameprofile.length; ++i)
|
||||
{
|
||||
JsonObject jsonobject1 = JsonUtils.getJsonObject(jsonarray.get(i), "player[" + i + "]");
|
||||
String s = JsonUtils.getString(jsonobject1, "id");
|
||||
agameprofile[i] = new GameProfile(UUID.fromString(s), JsonUtils.getString(jsonobject1, "name"));
|
||||
}
|
||||
|
||||
serverstatusresponse$players.setPlayers(agameprofile);
|
||||
}
|
||||
}
|
||||
|
||||
return serverstatusresponse$players;
|
||||
}
|
||||
|
||||
public JsonElement serialize(ServerStatusResponse.Players p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
|
||||
{
|
||||
JsonObject jsonobject = new JsonObject();
|
||||
jsonobject.addProperty("max", Integer.valueOf(p_serialize_1_.getMaxPlayers()));
|
||||
jsonobject.addProperty("online", Integer.valueOf(p_serialize_1_.getOnlinePlayerCount()));
|
||||
|
||||
if (p_serialize_1_.getPlayers() != null && p_serialize_1_.getPlayers().length > 0)
|
||||
{
|
||||
JsonArray jsonarray = new JsonArray();
|
||||
|
||||
for (int i = 0; i < p_serialize_1_.getPlayers().length; ++i)
|
||||
{
|
||||
JsonObject jsonobject1 = new JsonObject();
|
||||
UUID uuid = p_serialize_1_.getPlayers()[i].getId();
|
||||
jsonobject1.addProperty("id", uuid == null ? "" : uuid.toString());
|
||||
jsonobject1.addProperty("name", p_serialize_1_.getPlayers()[i].getName());
|
||||
jsonarray.add(jsonobject1);
|
||||
}
|
||||
|
||||
jsonobject.add("sample", jsonarray);
|
||||
}
|
||||
|
||||
return jsonobject;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Serializer implements JsonDeserializer<ServerStatusResponse>, JsonSerializer<ServerStatusResponse>
|
||||
{
|
||||
public ServerStatusResponse deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
|
||||
{
|
||||
JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "status");
|
||||
ServerStatusResponse serverstatusresponse = new ServerStatusResponse();
|
||||
|
||||
if (jsonobject.has("description"))
|
||||
{
|
||||
serverstatusresponse.setServerDescription((ITextComponent)p_deserialize_3_.deserialize(jsonobject.get("description"), ITextComponent.class));
|
||||
}
|
||||
|
||||
if (jsonobject.has("players"))
|
||||
{
|
||||
serverstatusresponse.setPlayers((ServerStatusResponse.Players)p_deserialize_3_.deserialize(jsonobject.get("players"), ServerStatusResponse.Players.class));
|
||||
}
|
||||
|
||||
if (jsonobject.has("version"))
|
||||
{
|
||||
serverstatusresponse.setVersion((ServerStatusResponse.Version)p_deserialize_3_.deserialize(jsonobject.get("version"), ServerStatusResponse.Version.class));
|
||||
}
|
||||
|
||||
if (jsonobject.has("favicon"))
|
||||
{
|
||||
serverstatusresponse.setFavicon(JsonUtils.getString(jsonobject, "favicon"));
|
||||
}
|
||||
|
||||
net.minecraftforge.fml.client.FMLClientHandler.instance().captureAdditionalData(serverstatusresponse, jsonobject);
|
||||
return serverstatusresponse;
|
||||
}
|
||||
|
||||
public JsonElement serialize(ServerStatusResponse p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
|
||||
{
|
||||
JsonObject jsonobject = new JsonObject();
|
||||
|
||||
if (p_serialize_1_.getServerDescription() != null)
|
||||
{
|
||||
jsonobject.add("description", p_serialize_3_.serialize(p_serialize_1_.getServerDescription()));
|
||||
}
|
||||
|
||||
if (p_serialize_1_.getPlayers() != null)
|
||||
{
|
||||
jsonobject.add("players", p_serialize_3_.serialize(p_serialize_1_.getPlayers()));
|
||||
}
|
||||
|
||||
if (p_serialize_1_.getVersion() != null)
|
||||
{
|
||||
jsonobject.add("version", p_serialize_3_.serialize(p_serialize_1_.getVersion()));
|
||||
}
|
||||
|
||||
if (p_serialize_1_.getFavicon() != null)
|
||||
{
|
||||
jsonobject.addProperty("favicon", p_serialize_1_.getFavicon());
|
||||
}
|
||||
|
||||
net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.enhanceStatusQuery(jsonobject);
|
||||
return jsonobject;
|
||||
}
|
||||
}
|
||||
|
||||
private java.util.concurrent.Semaphore mutex = new java.util.concurrent.Semaphore(1);
|
||||
private String json = null;
|
||||
/**
|
||||
* Returns this object as a Json string.
|
||||
* Converting to JSON if a cached version is not available.
|
||||
*
|
||||
* Also to prevent potentially large memory allocations on the server
|
||||
* this is moved from the S00PacketServerInfo writePacket function
|
||||
*
|
||||
* As this method is called from the network threads thread safety is important!
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getJson()
|
||||
{
|
||||
String ret = this.json;
|
||||
if (ret == null)
|
||||
{
|
||||
mutex.acquireUninterruptibly();
|
||||
ret = this.json;
|
||||
if (ret == null)
|
||||
{
|
||||
ret = net.minecraft.network.status.server.SPacketServerInfo.GSON.toJson(this);
|
||||
this.json = ret;
|
||||
}
|
||||
mutex.release();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidates the cached json, causing the next call to getJson to rebuild it.
|
||||
* This is needed externally because PlayerCountData.setPlayer's is public.
|
||||
*/
|
||||
public void invalidateJson()
|
||||
{
|
||||
this.json = null;
|
||||
}
|
||||
|
||||
public static class Version
|
||||
{
|
||||
private final String name;
|
||||
private final int protocol;
|
||||
|
||||
public Version(String nameIn, int protocolIn)
|
||||
{
|
||||
this.name = nameIn;
|
||||
this.protocol = protocolIn;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public int getProtocol()
|
||||
{
|
||||
return this.protocol;
|
||||
}
|
||||
|
||||
public static class Serializer implements JsonDeserializer<ServerStatusResponse.Version>, JsonSerializer<ServerStatusResponse.Version>
|
||||
{
|
||||
public ServerStatusResponse.Version deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
|
||||
{
|
||||
JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "version");
|
||||
return new ServerStatusResponse.Version(JsonUtils.getString(jsonobject, "name"), JsonUtils.getInt(jsonobject, "protocol"));
|
||||
}
|
||||
|
||||
public JsonElement serialize(ServerStatusResponse.Version p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
|
||||
{
|
||||
JsonObject jsonobject = new JsonObject();
|
||||
jsonobject.addProperty("name", p_serialize_1_.getName());
|
||||
jsonobject.addProperty("protocol", Integer.valueOf(p_serialize_1_.getProtocol()));
|
||||
return jsonobject;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.minecraft.network;
|
||||
|
||||
public final class ThreadQuickExitException extends RuntimeException
|
||||
{
|
||||
public static final ThreadQuickExitException INSTANCE = new ThreadQuickExitException();
|
||||
|
||||
private ThreadQuickExitException()
|
||||
{
|
||||
this.setStackTrace(new StackTraceElement[0]);
|
||||
}
|
||||
|
||||
public synchronized Throwable fillInStackTrace()
|
||||
{
|
||||
this.setStackTrace(new StackTraceElement[0]);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package net.minecraft.network.datasync;
|
||||
|
||||
public class DataParameter<T>
|
||||
{
|
||||
private final int id;
|
||||
private final DataSerializer<T> serializer;
|
||||
|
||||
public DataParameter(int idIn, DataSerializer<T> serializerIn)
|
||||
{
|
||||
this.id = idIn;
|
||||
this.serializer = serializerIn;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public DataSerializer<T> getSerializer()
|
||||
{
|
||||
return this.serializer;
|
||||
}
|
||||
|
||||
public boolean equals(Object p_equals_1_)
|
||||
{
|
||||
if (this == p_equals_1_)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (p_equals_1_ != null && this.getClass() == p_equals_1_.getClass())
|
||||
{
|
||||
DataParameter<?> dataparameter = (DataParameter)p_equals_1_;
|
||||
return this.id == dataparameter.id;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package net.minecraft.network.datasync;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
public interface DataSerializer<T>
|
||||
{
|
||||
void write(PacketBuffer buf, T value);
|
||||
|
||||
T read(PacketBuffer buf) throws IOException;
|
||||
|
||||
DataParameter<T> createKey(int id);
|
||||
|
||||
T copyValue(T value);
|
||||
}
|
||||
@@ -0,0 +1,341 @@
|
||||
package net.minecraft.network.datasync;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.IntIdentityHashBiMap;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Rotations;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class DataSerializers
|
||||
{
|
||||
private static final IntIdentityHashBiMap < DataSerializer<? >> REGISTRY = new IntIdentityHashBiMap < DataSerializer<? >> (16);
|
||||
public static final DataSerializer<Byte> BYTE = new DataSerializer<Byte>()
|
||||
{
|
||||
public void write(PacketBuffer buf, Byte value)
|
||||
{
|
||||
buf.writeByte(value.byteValue());
|
||||
}
|
||||
public Byte read(PacketBuffer buf) throws IOException
|
||||
{
|
||||
return buf.readByte();
|
||||
}
|
||||
public DataParameter<Byte> createKey(int id)
|
||||
{
|
||||
return new DataParameter<Byte>(id, this);
|
||||
}
|
||||
public Byte copyValue(Byte value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
};
|
||||
public static final DataSerializer<Integer> VARINT = new DataSerializer<Integer>()
|
||||
{
|
||||
public void write(PacketBuffer buf, Integer value)
|
||||
{
|
||||
buf.writeVarInt(value.intValue());
|
||||
}
|
||||
public Integer read(PacketBuffer buf) throws IOException
|
||||
{
|
||||
return buf.readVarInt();
|
||||
}
|
||||
public DataParameter<Integer> createKey(int id)
|
||||
{
|
||||
return new DataParameter<Integer>(id, this);
|
||||
}
|
||||
public Integer copyValue(Integer value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
};
|
||||
public static final DataSerializer<Float> FLOAT = new DataSerializer<Float>()
|
||||
{
|
||||
public void write(PacketBuffer buf, Float value)
|
||||
{
|
||||
buf.writeFloat(value.floatValue());
|
||||
}
|
||||
public Float read(PacketBuffer buf) throws IOException
|
||||
{
|
||||
return buf.readFloat();
|
||||
}
|
||||
public DataParameter<Float> createKey(int id)
|
||||
{
|
||||
return new DataParameter<Float>(id, this);
|
||||
}
|
||||
public Float copyValue(Float value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
};
|
||||
public static final DataSerializer<String> STRING = new DataSerializer<String>()
|
||||
{
|
||||
public void write(PacketBuffer buf, String value)
|
||||
{
|
||||
buf.writeString(value);
|
||||
}
|
||||
public String read(PacketBuffer buf) throws IOException
|
||||
{
|
||||
return buf.readString(32767);
|
||||
}
|
||||
public DataParameter<String> createKey(int id)
|
||||
{
|
||||
return new DataParameter<String>(id, this);
|
||||
}
|
||||
public String copyValue(String value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
};
|
||||
public static final DataSerializer<ITextComponent> TEXT_COMPONENT = new DataSerializer<ITextComponent>()
|
||||
{
|
||||
public void write(PacketBuffer buf, ITextComponent value)
|
||||
{
|
||||
buf.writeTextComponent(value);
|
||||
}
|
||||
public ITextComponent read(PacketBuffer buf) throws IOException
|
||||
{
|
||||
return buf.readTextComponent();
|
||||
}
|
||||
public DataParameter<ITextComponent> createKey(int id)
|
||||
{
|
||||
return new DataParameter<ITextComponent>(id, this);
|
||||
}
|
||||
public ITextComponent copyValue(ITextComponent value)
|
||||
{
|
||||
return value.createCopy();
|
||||
}
|
||||
};
|
||||
public static final DataSerializer<ItemStack> ITEM_STACK = new DataSerializer<ItemStack>()
|
||||
{
|
||||
public void write(PacketBuffer buf, ItemStack value)
|
||||
{
|
||||
buf.writeItemStack(value);
|
||||
}
|
||||
public ItemStack read(PacketBuffer buf) throws IOException
|
||||
{
|
||||
return buf.readItemStack();
|
||||
}
|
||||
public DataParameter<ItemStack> createKey(int id)
|
||||
{
|
||||
return new DataParameter<ItemStack>(id, this);
|
||||
}
|
||||
public ItemStack copyValue(ItemStack value)
|
||||
{
|
||||
return value.copy();
|
||||
}
|
||||
};
|
||||
public static final DataSerializer<Optional<IBlockState>> OPTIONAL_BLOCK_STATE = new DataSerializer<Optional<IBlockState>>()
|
||||
{
|
||||
public void write(PacketBuffer buf, Optional<IBlockState> value)
|
||||
{
|
||||
if (value.isPresent())
|
||||
{
|
||||
buf.writeVarInt(Block.getStateId(value.get()));
|
||||
}
|
||||
else
|
||||
{
|
||||
buf.writeVarInt(0);
|
||||
}
|
||||
}
|
||||
public Optional<IBlockState> read(PacketBuffer buf) throws IOException
|
||||
{
|
||||
int i = buf.readVarInt();
|
||||
return i == 0 ? Optional.absent() : Optional.of(Block.getStateById(i));
|
||||
}
|
||||
public DataParameter<Optional<IBlockState>> createKey(int id)
|
||||
{
|
||||
return new DataParameter<Optional<IBlockState>>(id, this);
|
||||
}
|
||||
public Optional<IBlockState> copyValue(Optional<IBlockState> value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
};
|
||||
public static final DataSerializer<Boolean> BOOLEAN = new DataSerializer<Boolean>()
|
||||
{
|
||||
public void write(PacketBuffer buf, Boolean value)
|
||||
{
|
||||
buf.writeBoolean(value.booleanValue());
|
||||
}
|
||||
public Boolean read(PacketBuffer buf) throws IOException
|
||||
{
|
||||
return buf.readBoolean();
|
||||
}
|
||||
public DataParameter<Boolean> createKey(int id)
|
||||
{
|
||||
return new DataParameter<Boolean>(id, this);
|
||||
}
|
||||
public Boolean copyValue(Boolean value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
};
|
||||
public static final DataSerializer<Rotations> ROTATIONS = new DataSerializer<Rotations>()
|
||||
{
|
||||
public void write(PacketBuffer buf, Rotations value)
|
||||
{
|
||||
buf.writeFloat(value.getX());
|
||||
buf.writeFloat(value.getY());
|
||||
buf.writeFloat(value.getZ());
|
||||
}
|
||||
public Rotations read(PacketBuffer buf) throws IOException
|
||||
{
|
||||
return new Rotations(buf.readFloat(), buf.readFloat(), buf.readFloat());
|
||||
}
|
||||
public DataParameter<Rotations> createKey(int id)
|
||||
{
|
||||
return new DataParameter<Rotations>(id, this);
|
||||
}
|
||||
public Rotations copyValue(Rotations value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
};
|
||||
public static final DataSerializer<BlockPos> BLOCK_POS = new DataSerializer<BlockPos>()
|
||||
{
|
||||
public void write(PacketBuffer buf, BlockPos value)
|
||||
{
|
||||
buf.writeBlockPos(value);
|
||||
}
|
||||
public BlockPos read(PacketBuffer buf) throws IOException
|
||||
{
|
||||
return buf.readBlockPos();
|
||||
}
|
||||
public DataParameter<BlockPos> createKey(int id)
|
||||
{
|
||||
return new DataParameter<BlockPos>(id, this);
|
||||
}
|
||||
public BlockPos copyValue(BlockPos value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
};
|
||||
public static final DataSerializer<Optional<BlockPos>> OPTIONAL_BLOCK_POS = new DataSerializer<Optional<BlockPos>>()
|
||||
{
|
||||
public void write(PacketBuffer buf, Optional<BlockPos> value)
|
||||
{
|
||||
buf.writeBoolean(value.isPresent());
|
||||
|
||||
if (value.isPresent())
|
||||
{
|
||||
buf.writeBlockPos(value.get());
|
||||
}
|
||||
}
|
||||
public Optional<BlockPos> read(PacketBuffer buf) throws IOException
|
||||
{
|
||||
return !buf.readBoolean() ? Optional.absent() : Optional.of(buf.readBlockPos());
|
||||
}
|
||||
public DataParameter<Optional<BlockPos>> createKey(int id)
|
||||
{
|
||||
return new DataParameter<Optional<BlockPos>>(id, this);
|
||||
}
|
||||
public Optional<BlockPos> copyValue(Optional<BlockPos> value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
};
|
||||
public static final DataSerializer<EnumFacing> FACING = new DataSerializer<EnumFacing>()
|
||||
{
|
||||
public void write(PacketBuffer buf, EnumFacing value)
|
||||
{
|
||||
buf.writeEnumValue(value);
|
||||
}
|
||||
public EnumFacing read(PacketBuffer buf) throws IOException
|
||||
{
|
||||
return (EnumFacing)buf.readEnumValue(EnumFacing.class);
|
||||
}
|
||||
public DataParameter<EnumFacing> createKey(int id)
|
||||
{
|
||||
return new DataParameter<EnumFacing>(id, this);
|
||||
}
|
||||
public EnumFacing copyValue(EnumFacing value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
};
|
||||
public static final DataSerializer<Optional<UUID>> OPTIONAL_UNIQUE_ID = new DataSerializer<Optional<UUID>>()
|
||||
{
|
||||
public void write(PacketBuffer buf, Optional<UUID> value)
|
||||
{
|
||||
buf.writeBoolean(value.isPresent());
|
||||
|
||||
if (value.isPresent())
|
||||
{
|
||||
buf.writeUniqueId(value.get());
|
||||
}
|
||||
}
|
||||
public Optional<UUID> read(PacketBuffer buf) throws IOException
|
||||
{
|
||||
return !buf.readBoolean() ? Optional.absent() : Optional.of(buf.readUniqueId());
|
||||
}
|
||||
public DataParameter<Optional<UUID>> createKey(int id)
|
||||
{
|
||||
return new DataParameter<Optional<UUID>>(id, this);
|
||||
}
|
||||
public Optional<UUID> copyValue(Optional<UUID> value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
};
|
||||
public static final DataSerializer<NBTTagCompound> COMPOUND_TAG = new DataSerializer<NBTTagCompound>()
|
||||
{
|
||||
public void write(PacketBuffer buf, NBTTagCompound value)
|
||||
{
|
||||
buf.writeCompoundTag(value);
|
||||
}
|
||||
public NBTTagCompound read(PacketBuffer buf) throws IOException
|
||||
{
|
||||
return buf.readCompoundTag();
|
||||
}
|
||||
public DataParameter<NBTTagCompound> createKey(int id)
|
||||
{
|
||||
return new DataParameter<NBTTagCompound>(id, this);
|
||||
}
|
||||
public NBTTagCompound copyValue(NBTTagCompound value)
|
||||
{
|
||||
return value.copy();
|
||||
}
|
||||
};
|
||||
|
||||
public static void registerSerializer(DataSerializer<?> serializer)
|
||||
{
|
||||
REGISTRY.add(serializer);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static DataSerializer<?> getSerializer(int id)
|
||||
{
|
||||
return (DataSerializer)REGISTRY.get(id);
|
||||
}
|
||||
|
||||
public static int getSerializerId(DataSerializer<?> serializer)
|
||||
{
|
||||
return REGISTRY.getId(serializer);
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
registerSerializer(BYTE);
|
||||
registerSerializer(VARINT);
|
||||
registerSerializer(FLOAT);
|
||||
registerSerializer(STRING);
|
||||
registerSerializer(TEXT_COMPONENT);
|
||||
registerSerializer(ITEM_STACK);
|
||||
registerSerializer(BOOLEAN);
|
||||
registerSerializer(ROTATIONS);
|
||||
registerSerializer(BLOCK_POS);
|
||||
registerSerializer(OPTIONAL_BLOCK_POS);
|
||||
registerSerializer(FACING);
|
||||
registerSerializer(OPTIONAL_UNIQUE_ID);
|
||||
registerSerializer(OPTIONAL_BLOCK_STATE);
|
||||
registerSerializer(COMPOUND_TAG);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,387 @@
|
||||
package net.minecraft.network.datasync;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import io.netty.handler.codec.DecoderException;
|
||||
import io.netty.handler.codec.EncoderException;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ReportedException;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class EntityDataManager
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final Map < Class <? extends Entity > , Integer > NEXT_ID_MAP = Maps. < Class <? extends Entity > , Integer > newHashMap();
|
||||
/** The entity that this data manager is for. */
|
||||
private final Entity entity;
|
||||
private final Map < Integer, EntityDataManager.DataEntry<? >> entries = Maps. < Integer, EntityDataManager.DataEntry<? >> newHashMap();
|
||||
private final ReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
private boolean empty = true;
|
||||
private boolean dirty;
|
||||
|
||||
public EntityDataManager(Entity entityIn)
|
||||
{
|
||||
this.entity = entityIn;
|
||||
}
|
||||
|
||||
public static <T> DataParameter<T> createKey(Class <? extends Entity > clazz, DataSerializer<T> serializer)
|
||||
{
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
try
|
||||
{
|
||||
Class<?> oclass = Class.forName(Thread.currentThread().getStackTrace()[2].getClassName());
|
||||
|
||||
if (!oclass.equals(clazz))
|
||||
{
|
||||
LOGGER.debug("defineId called for: {} from {}", clazz, oclass, new RuntimeException());
|
||||
}
|
||||
}
|
||||
catch (ClassNotFoundException var5)
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
int j;
|
||||
|
||||
if (NEXT_ID_MAP.containsKey(clazz))
|
||||
{
|
||||
j = ((Integer)NEXT_ID_MAP.get(clazz)).intValue() + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = 0;
|
||||
Class<?> oclass1 = clazz;
|
||||
|
||||
while (oclass1 != Entity.class)
|
||||
{
|
||||
oclass1 = oclass1.getSuperclass();
|
||||
|
||||
if (NEXT_ID_MAP.containsKey(oclass1))
|
||||
{
|
||||
i = ((Integer)NEXT_ID_MAP.get(oclass1)).intValue() + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
j = i;
|
||||
}
|
||||
|
||||
if (j > 254)
|
||||
{
|
||||
throw new IllegalArgumentException("Data value id is too big with " + j + "! (Max is " + 254 + ")");
|
||||
}
|
||||
else
|
||||
{
|
||||
NEXT_ID_MAP.put(clazz, Integer.valueOf(j));
|
||||
return serializer.createKey(j);
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void register(DataParameter<T> key, T value)
|
||||
{
|
||||
int i = key.getId();
|
||||
|
||||
if (i > 254)
|
||||
{
|
||||
throw new IllegalArgumentException("Data value id is too big with " + i + "! (Max is " + 254 + ")");
|
||||
}
|
||||
else if (this.entries.containsKey(Integer.valueOf(i)))
|
||||
{
|
||||
throw new IllegalArgumentException("Duplicate id value for " + i + "!");
|
||||
}
|
||||
else if (DataSerializers.getSerializerId(key.getSerializer()) < 0)
|
||||
{
|
||||
throw new IllegalArgumentException("Unregistered serializer " + key.getSerializer() + " for " + i + "!");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setEntry(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
private <T> void setEntry(DataParameter<T> key, T value)
|
||||
{
|
||||
EntityDataManager.DataEntry<T> dataentry = new EntityDataManager.DataEntry<T>(key, value);
|
||||
this.lock.writeLock().lock();
|
||||
this.entries.put(Integer.valueOf(key.getId()), dataentry);
|
||||
this.empty = false;
|
||||
this.lock.writeLock().unlock();
|
||||
}
|
||||
|
||||
private <T> EntityDataManager.DataEntry<T> getEntry(DataParameter<T> key)
|
||||
{
|
||||
this.lock.readLock().lock();
|
||||
EntityDataManager.DataEntry<T> dataentry;
|
||||
|
||||
try
|
||||
{
|
||||
dataentry = (EntityDataManager.DataEntry)this.entries.get(Integer.valueOf(key.getId()));
|
||||
}
|
||||
catch (Throwable throwable)
|
||||
{
|
||||
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Getting synched entity data");
|
||||
CrashReportCategory crashreportcategory = crashreport.makeCategory("Synched entity data");
|
||||
crashreportcategory.addCrashSection("Data ID", key);
|
||||
throw new ReportedException(crashreport);
|
||||
}
|
||||
|
||||
this.lock.readLock().unlock();
|
||||
return dataentry;
|
||||
}
|
||||
|
||||
public <T> T get(DataParameter<T> key)
|
||||
{
|
||||
return (T)this.getEntry(key).getValue();
|
||||
}
|
||||
|
||||
public <T> void set(DataParameter<T> key, T value)
|
||||
{
|
||||
EntityDataManager.DataEntry<T> dataentry = this.<T>getEntry(key);
|
||||
|
||||
if (ObjectUtils.notEqual(value, dataentry.getValue()))
|
||||
{
|
||||
dataentry.setValue(value);
|
||||
this.entity.notifyDataManagerChange(key);
|
||||
dataentry.setDirty(true);
|
||||
this.dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void setDirty(DataParameter<T> key)
|
||||
{
|
||||
this.getEntry(key).dirty = true;
|
||||
this.dirty = true;
|
||||
}
|
||||
|
||||
public boolean isDirty()
|
||||
{
|
||||
return this.dirty;
|
||||
}
|
||||
|
||||
public static void writeEntries(List < EntityDataManager.DataEntry<? >> entriesIn, PacketBuffer buf) throws IOException
|
||||
{
|
||||
if (entriesIn != null)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (int j = entriesIn.size(); i < j; ++i)
|
||||
{
|
||||
EntityDataManager.DataEntry<?> dataentry = (EntityDataManager.DataEntry)entriesIn.get(i);
|
||||
writeEntry(buf, dataentry);
|
||||
}
|
||||
}
|
||||
|
||||
buf.writeByte(255);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List < EntityDataManager.DataEntry<? >> getDirty()
|
||||
{
|
||||
List < EntityDataManager.DataEntry<? >> list = null;
|
||||
|
||||
if (this.dirty)
|
||||
{
|
||||
this.lock.readLock().lock();
|
||||
|
||||
for (EntityDataManager.DataEntry<?> dataentry : this.entries.values())
|
||||
{
|
||||
if (dataentry.isDirty())
|
||||
{
|
||||
dataentry.setDirty(false);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
list = Lists. < EntityDataManager.DataEntry<? >> newArrayList();
|
||||
}
|
||||
|
||||
list.add(dataentry.copy());
|
||||
}
|
||||
}
|
||||
|
||||
this.lock.readLock().unlock();
|
||||
}
|
||||
|
||||
this.dirty = false;
|
||||
return list;
|
||||
}
|
||||
|
||||
public void writeEntries(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.lock.readLock().lock();
|
||||
|
||||
for (EntityDataManager.DataEntry<?> dataentry : this.entries.values())
|
||||
{
|
||||
writeEntry(buf, dataentry);
|
||||
}
|
||||
|
||||
this.lock.readLock().unlock();
|
||||
buf.writeByte(255);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List < EntityDataManager.DataEntry<? >> getAll()
|
||||
{
|
||||
List < EntityDataManager.DataEntry<? >> list = null;
|
||||
this.lock.readLock().lock();
|
||||
|
||||
for (EntityDataManager.DataEntry<?> dataentry : this.entries.values())
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
list = Lists. < EntityDataManager.DataEntry<? >> newArrayList();
|
||||
}
|
||||
|
||||
list.add(dataentry.copy());
|
||||
}
|
||||
|
||||
this.lock.readLock().unlock();
|
||||
return list;
|
||||
}
|
||||
|
||||
private static <T> void writeEntry(PacketBuffer buf, EntityDataManager.DataEntry<T> entry) throws IOException
|
||||
{
|
||||
DataParameter<T> dataparameter = entry.getKey();
|
||||
int i = DataSerializers.getSerializerId(dataparameter.getSerializer());
|
||||
|
||||
if (i < 0)
|
||||
{
|
||||
throw new EncoderException("Unknown serializer type " + dataparameter.getSerializer());
|
||||
}
|
||||
else
|
||||
{
|
||||
buf.writeByte(dataparameter.getId());
|
||||
buf.writeVarInt(i);
|
||||
dataparameter.getSerializer().write(buf, entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static List < EntityDataManager.DataEntry<? >> readEntries(PacketBuffer buf) throws IOException
|
||||
{
|
||||
List < EntityDataManager.DataEntry<? >> list = null;
|
||||
int i;
|
||||
|
||||
while ((i = buf.readUnsignedByte()) != 255)
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
list = Lists. < EntityDataManager.DataEntry<? >> newArrayList();
|
||||
}
|
||||
|
||||
int j = buf.readVarInt();
|
||||
DataSerializer<?> dataserializer = DataSerializers.getSerializer(j);
|
||||
|
||||
if (dataserializer == null)
|
||||
{
|
||||
throw new DecoderException("Unknown serializer type " + j);
|
||||
}
|
||||
|
||||
list.add(new EntityDataManager.DataEntry(dataserializer.createKey(i), dataserializer.read(buf)));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void setEntryValues(List < EntityDataManager.DataEntry<? >> entriesIn)
|
||||
{
|
||||
this.lock.writeLock().lock();
|
||||
|
||||
for (EntityDataManager.DataEntry<?> dataentry : entriesIn)
|
||||
{
|
||||
EntityDataManager.DataEntry<?> dataentry1 = (EntityDataManager.DataEntry)this.entries.get(Integer.valueOf(dataentry.getKey().getId()));
|
||||
|
||||
if (dataentry1 != null)
|
||||
{
|
||||
this.setEntryValue(dataentry1, dataentry);
|
||||
this.entity.notifyDataManagerChange(dataentry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
this.lock.writeLock().unlock();
|
||||
this.dirty = true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected <T> void setEntryValue(EntityDataManager.DataEntry<T> target, EntityDataManager.DataEntry<?> source)
|
||||
{
|
||||
target.setValue((T)source.getValue());
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return this.empty;
|
||||
}
|
||||
|
||||
public void setClean()
|
||||
{
|
||||
this.dirty = false;
|
||||
this.lock.readLock().lock();
|
||||
|
||||
for (EntityDataManager.DataEntry<?> dataentry : this.entries.values())
|
||||
{
|
||||
dataentry.setDirty(false);
|
||||
}
|
||||
|
||||
this.lock.readLock().unlock();
|
||||
}
|
||||
|
||||
public static class DataEntry<T>
|
||||
{
|
||||
private final DataParameter<T> key;
|
||||
private T value;
|
||||
private boolean dirty;
|
||||
|
||||
public DataEntry(DataParameter<T> keyIn, T valueIn)
|
||||
{
|
||||
this.key = keyIn;
|
||||
this.value = valueIn;
|
||||
this.dirty = true;
|
||||
}
|
||||
|
||||
public DataParameter<T> getKey()
|
||||
{
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public void setValue(T valueIn)
|
||||
{
|
||||
this.value = valueIn;
|
||||
}
|
||||
|
||||
public T getValue()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public boolean isDirty()
|
||||
{
|
||||
return this.dirty;
|
||||
}
|
||||
|
||||
public void setDirty(boolean dirtyIn)
|
||||
{
|
||||
this.dirty = dirtyIn;
|
||||
}
|
||||
|
||||
public EntityDataManager.DataEntry<T> copy()
|
||||
{
|
||||
return new EntityDataManager.DataEntry<T>(this.key, this.key.getSerializer().copyValue(this.value));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// Auto generated package-info by MCP
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package net.minecraft.network.datasync;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,14 @@
|
||||
package net.minecraft.network.handshake;
|
||||
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.handshake.client.C00Handshake;
|
||||
|
||||
public interface INetHandlerHandshakeServer extends INetHandler
|
||||
{
|
||||
/**
|
||||
* There are two recognized intentions for initiating a handshake: logging in and acquiring server status. The
|
||||
* NetworkManager's protocol will be reconfigured according to the specified intention, although a login-intention
|
||||
* must pass a versioncheck or receive a disconnect otherwise
|
||||
*/
|
||||
void processHandshake(C00Handshake packetIn);
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package net.minecraft.network.handshake.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.EnumConnectionState;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.handshake.INetHandlerHandshakeServer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class C00Handshake implements Packet<INetHandlerHandshakeServer>
|
||||
{
|
||||
private int protocolVersion;
|
||||
private String ip;
|
||||
private int port;
|
||||
private EnumConnectionState requestedState;
|
||||
private boolean hasFMLMarker = false;
|
||||
|
||||
public C00Handshake()
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public C00Handshake(String p_i47613_1_, int p_i47613_2_, EnumConnectionState p_i47613_3_)
|
||||
{
|
||||
this.protocolVersion = 340;
|
||||
this.ip = p_i47613_1_;
|
||||
this.port = p_i47613_2_;
|
||||
this.requestedState = p_i47613_3_;
|
||||
}
|
||||
|
||||
public C00Handshake(String address, int port, EnumConnectionState state, boolean addFMLMarker)
|
||||
{
|
||||
this(address, port, state);
|
||||
this.hasFMLMarker = addFMLMarker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.protocolVersion = buf.readVarInt();
|
||||
this.ip = buf.readString(255);
|
||||
this.port = buf.readUnsignedShort();
|
||||
this.requestedState = EnumConnectionState.getById(buf.readVarInt());
|
||||
this.hasFMLMarker = this.ip.contains("\0FML\0");
|
||||
this.ip = this.ip.split("\0")[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarInt(this.protocolVersion);
|
||||
buf.writeString(this.ip + "\0FML\0");
|
||||
buf.writeShort(this.port);
|
||||
buf.writeVarInt(this.requestedState.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerHandshakeServer handler)
|
||||
{
|
||||
handler.processHandshake(this);
|
||||
}
|
||||
|
||||
public EnumConnectionState getRequestedState()
|
||||
{
|
||||
return this.requestedState;
|
||||
}
|
||||
|
||||
public int getProtocolVersion()
|
||||
{
|
||||
return this.protocolVersion;
|
||||
}
|
||||
|
||||
public boolean hasFMLMarker()
|
||||
{
|
||||
return this.hasFMLMarker;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// Auto generated package-info by MCP
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package net.minecraft.network.handshake.client;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,7 @@
|
||||
// Auto generated package-info by MCP
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package net.minecraft.network.handshake;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,18 @@
|
||||
package net.minecraft.network.login;
|
||||
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.login.server.SPacketDisconnect;
|
||||
import net.minecraft.network.login.server.SPacketEnableCompression;
|
||||
import net.minecraft.network.login.server.SPacketEncryptionRequest;
|
||||
import net.minecraft.network.login.server.SPacketLoginSuccess;
|
||||
|
||||
public interface INetHandlerLoginClient extends INetHandler
|
||||
{
|
||||
void handleEncryptionRequest(SPacketEncryptionRequest packetIn);
|
||||
|
||||
void handleLoginSuccess(SPacketLoginSuccess packetIn);
|
||||
|
||||
void handleDisconnect(SPacketDisconnect packetIn);
|
||||
|
||||
void handleEnableCompression(SPacketEnableCompression packetIn);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package net.minecraft.network.login;
|
||||
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.login.client.CPacketEncryptionResponse;
|
||||
import net.minecraft.network.login.client.CPacketLoginStart;
|
||||
|
||||
public interface INetHandlerLoginServer extends INetHandler
|
||||
{
|
||||
void processLoginStart(CPacketLoginStart packetIn);
|
||||
|
||||
void processEncryptionResponse(CPacketEncryptionResponse packetIn);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package net.minecraft.network.login.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
import javax.crypto.SecretKey;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.login.INetHandlerLoginServer;
|
||||
import net.minecraft.util.CryptManager;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CPacketEncryptionResponse implements Packet<INetHandlerLoginServer>
|
||||
{
|
||||
private byte[] secretKeyEncrypted = new byte[0];
|
||||
private byte[] verifyTokenEncrypted = new byte[0];
|
||||
|
||||
public CPacketEncryptionResponse()
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketEncryptionResponse(SecretKey secret, PublicKey key, byte[] verifyToken)
|
||||
{
|
||||
this.secretKeyEncrypted = CryptManager.encryptData(key, secret.getEncoded());
|
||||
this.verifyTokenEncrypted = CryptManager.encryptData(key, verifyToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.secretKeyEncrypted = buf.readByteArray();
|
||||
this.verifyTokenEncrypted = buf.readByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeByteArray(this.secretKeyEncrypted);
|
||||
buf.writeByteArray(this.verifyTokenEncrypted);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerLoginServer handler)
|
||||
{
|
||||
handler.processEncryptionResponse(this);
|
||||
}
|
||||
|
||||
public SecretKey getSecretKey(PrivateKey key)
|
||||
{
|
||||
return CryptManager.decryptSharedKey(key, this.secretKeyEncrypted);
|
||||
}
|
||||
|
||||
public byte[] getVerifyToken(PrivateKey key)
|
||||
{
|
||||
return key == null ? this.verifyTokenEncrypted : CryptManager.decryptData(key, this.verifyTokenEncrypted);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package net.minecraft.network.login.client;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.login.INetHandlerLoginServer;
|
||||
|
||||
public class CPacketLoginStart implements Packet<INetHandlerLoginServer>
|
||||
{
|
||||
private GameProfile profile;
|
||||
|
||||
public CPacketLoginStart()
|
||||
{
|
||||
}
|
||||
|
||||
public CPacketLoginStart(GameProfile profileIn)
|
||||
{
|
||||
this.profile = profileIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.profile = new GameProfile((UUID)null, buf.readString(16));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeString(this.profile.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerLoginServer handler)
|
||||
{
|
||||
handler.processLoginStart(this);
|
||||
}
|
||||
|
||||
public GameProfile getProfile()
|
||||
{
|
||||
return this.profile;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// Auto generated package-info by MCP
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package net.minecraft.network.login.client;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,7 @@
|
||||
// Auto generated package-info by MCP
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package net.minecraft.network.login;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,53 @@
|
||||
package net.minecraft.network.login.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.login.INetHandlerLoginClient;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketDisconnect implements Packet<INetHandlerLoginClient>
|
||||
{
|
||||
private ITextComponent reason;
|
||||
|
||||
public SPacketDisconnect()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketDisconnect(ITextComponent p_i46853_1_)
|
||||
{
|
||||
this.reason = p_i46853_1_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.reason = ITextComponent.Serializer.fromJsonLenient(buf.readString(32767));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeTextComponent(this.reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerLoginClient handler)
|
||||
{
|
||||
handler.handleDisconnect(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ITextComponent getReason()
|
||||
{
|
||||
return this.reason;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package net.minecraft.network.login.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.login.INetHandlerLoginClient;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketEnableCompression implements Packet<INetHandlerLoginClient>
|
||||
{
|
||||
private int compressionThreshold;
|
||||
|
||||
public SPacketEnableCompression()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketEnableCompression(int thresholdIn)
|
||||
{
|
||||
this.compressionThreshold = thresholdIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.compressionThreshold = buf.readVarInt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarInt(this.compressionThreshold);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerLoginClient handler)
|
||||
{
|
||||
handler.handleEnableCompression(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getCompressionThreshold()
|
||||
{
|
||||
return this.compressionThreshold;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package net.minecraft.network.login.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.PublicKey;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.login.INetHandlerLoginClient;
|
||||
import net.minecraft.util.CryptManager;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketEncryptionRequest implements Packet<INetHandlerLoginClient>
|
||||
{
|
||||
private String hashedServerId;
|
||||
private PublicKey publicKey;
|
||||
private byte[] verifyToken;
|
||||
|
||||
public SPacketEncryptionRequest()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketEncryptionRequest(String serverIdIn, PublicKey publicKeyIn, byte[] verifyTokenIn)
|
||||
{
|
||||
this.hashedServerId = serverIdIn;
|
||||
this.publicKey = publicKeyIn;
|
||||
this.verifyToken = verifyTokenIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.hashedServerId = buf.readString(20);
|
||||
this.publicKey = CryptManager.decodePublicKey(buf.readByteArray());
|
||||
this.verifyToken = buf.readByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeString(this.hashedServerId);
|
||||
buf.writeByteArray(this.publicKey.getEncoded());
|
||||
buf.writeByteArray(this.verifyToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerLoginClient handler)
|
||||
{
|
||||
handler.handleEncryptionRequest(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getServerId()
|
||||
{
|
||||
return this.hashedServerId;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public PublicKey getPublicKey()
|
||||
{
|
||||
return this.publicKey;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public byte[] getVerifyToken()
|
||||
{
|
||||
return this.verifyToken;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package net.minecraft.network.login.server;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.login.INetHandlerLoginClient;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketLoginSuccess implements Packet<INetHandlerLoginClient>
|
||||
{
|
||||
private GameProfile profile;
|
||||
|
||||
public SPacketLoginSuccess()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketLoginSuccess(GameProfile profileIn)
|
||||
{
|
||||
this.profile = profileIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
String s = buf.readString(36);
|
||||
String s1 = buf.readString(16);
|
||||
UUID uuid = s.length() > 0 ? UUID.fromString(s) : null;
|
||||
this.profile = new GameProfile(uuid, s1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
UUID uuid = this.profile.getId();
|
||||
buf.writeString(uuid == null ? "" : uuid.toString());
|
||||
buf.writeString(this.profile.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerLoginClient handler)
|
||||
{
|
||||
handler.handleLoginSuccess(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public GameProfile getProfile()
|
||||
{
|
||||
return this.profile;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// Auto generated package-info by MCP
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package net.minecraft.network.login.server;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,7 @@
|
||||
// Auto generated package-info by MCP
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package net.minecraft.network;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,395 @@
|
||||
package net.minecraft.network.play;
|
||||
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.play.server.SPacketAdvancementInfo;
|
||||
import net.minecraft.network.play.server.SPacketAnimation;
|
||||
import net.minecraft.network.play.server.SPacketBlockAction;
|
||||
import net.minecraft.network.play.server.SPacketBlockBreakAnim;
|
||||
import net.minecraft.network.play.server.SPacketBlockChange;
|
||||
import net.minecraft.network.play.server.SPacketCamera;
|
||||
import net.minecraft.network.play.server.SPacketChangeGameState;
|
||||
import net.minecraft.network.play.server.SPacketChat;
|
||||
import net.minecraft.network.play.server.SPacketChunkData;
|
||||
import net.minecraft.network.play.server.SPacketCloseWindow;
|
||||
import net.minecraft.network.play.server.SPacketCollectItem;
|
||||
import net.minecraft.network.play.server.SPacketCombatEvent;
|
||||
import net.minecraft.network.play.server.SPacketConfirmTransaction;
|
||||
import net.minecraft.network.play.server.SPacketCooldown;
|
||||
import net.minecraft.network.play.server.SPacketCustomPayload;
|
||||
import net.minecraft.network.play.server.SPacketCustomSound;
|
||||
import net.minecraft.network.play.server.SPacketDestroyEntities;
|
||||
import net.minecraft.network.play.server.SPacketDisconnect;
|
||||
import net.minecraft.network.play.server.SPacketDisplayObjective;
|
||||
import net.minecraft.network.play.server.SPacketEffect;
|
||||
import net.minecraft.network.play.server.SPacketEntity;
|
||||
import net.minecraft.network.play.server.SPacketEntityAttach;
|
||||
import net.minecraft.network.play.server.SPacketEntityEffect;
|
||||
import net.minecraft.network.play.server.SPacketEntityEquipment;
|
||||
import net.minecraft.network.play.server.SPacketEntityHeadLook;
|
||||
import net.minecraft.network.play.server.SPacketEntityMetadata;
|
||||
import net.minecraft.network.play.server.SPacketEntityProperties;
|
||||
import net.minecraft.network.play.server.SPacketEntityStatus;
|
||||
import net.minecraft.network.play.server.SPacketEntityTeleport;
|
||||
import net.minecraft.network.play.server.SPacketEntityVelocity;
|
||||
import net.minecraft.network.play.server.SPacketExplosion;
|
||||
import net.minecraft.network.play.server.SPacketHeldItemChange;
|
||||
import net.minecraft.network.play.server.SPacketJoinGame;
|
||||
import net.minecraft.network.play.server.SPacketKeepAlive;
|
||||
import net.minecraft.network.play.server.SPacketMaps;
|
||||
import net.minecraft.network.play.server.SPacketMoveVehicle;
|
||||
import net.minecraft.network.play.server.SPacketMultiBlockChange;
|
||||
import net.minecraft.network.play.server.SPacketOpenWindow;
|
||||
import net.minecraft.network.play.server.SPacketParticles;
|
||||
import net.minecraft.network.play.server.SPacketPlaceGhostRecipe;
|
||||
import net.minecraft.network.play.server.SPacketPlayerAbilities;
|
||||
import net.minecraft.network.play.server.SPacketPlayerListHeaderFooter;
|
||||
import net.minecraft.network.play.server.SPacketPlayerListItem;
|
||||
import net.minecraft.network.play.server.SPacketPlayerPosLook;
|
||||
import net.minecraft.network.play.server.SPacketRecipeBook;
|
||||
import net.minecraft.network.play.server.SPacketRemoveEntityEffect;
|
||||
import net.minecraft.network.play.server.SPacketResourcePackSend;
|
||||
import net.minecraft.network.play.server.SPacketRespawn;
|
||||
import net.minecraft.network.play.server.SPacketScoreboardObjective;
|
||||
import net.minecraft.network.play.server.SPacketSelectAdvancementsTab;
|
||||
import net.minecraft.network.play.server.SPacketServerDifficulty;
|
||||
import net.minecraft.network.play.server.SPacketSetExperience;
|
||||
import net.minecraft.network.play.server.SPacketSetPassengers;
|
||||
import net.minecraft.network.play.server.SPacketSetSlot;
|
||||
import net.minecraft.network.play.server.SPacketSignEditorOpen;
|
||||
import net.minecraft.network.play.server.SPacketSoundEffect;
|
||||
import net.minecraft.network.play.server.SPacketSpawnExperienceOrb;
|
||||
import net.minecraft.network.play.server.SPacketSpawnGlobalEntity;
|
||||
import net.minecraft.network.play.server.SPacketSpawnMob;
|
||||
import net.minecraft.network.play.server.SPacketSpawnObject;
|
||||
import net.minecraft.network.play.server.SPacketSpawnPainting;
|
||||
import net.minecraft.network.play.server.SPacketSpawnPlayer;
|
||||
import net.minecraft.network.play.server.SPacketSpawnPosition;
|
||||
import net.minecraft.network.play.server.SPacketStatistics;
|
||||
import net.minecraft.network.play.server.SPacketTabComplete;
|
||||
import net.minecraft.network.play.server.SPacketTeams;
|
||||
import net.minecraft.network.play.server.SPacketTimeUpdate;
|
||||
import net.minecraft.network.play.server.SPacketTitle;
|
||||
import net.minecraft.network.play.server.SPacketUnloadChunk;
|
||||
import net.minecraft.network.play.server.SPacketUpdateBossInfo;
|
||||
import net.minecraft.network.play.server.SPacketUpdateHealth;
|
||||
import net.minecraft.network.play.server.SPacketUpdateScore;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.network.play.server.SPacketUseBed;
|
||||
import net.minecraft.network.play.server.SPacketWindowItems;
|
||||
import net.minecraft.network.play.server.SPacketWindowProperty;
|
||||
import net.minecraft.network.play.server.SPacketWorldBorder;
|
||||
|
||||
public interface INetHandlerPlayClient extends INetHandler
|
||||
{
|
||||
/**
|
||||
* Spawns an instance of the objecttype indicated by the packet and sets its position and momentum
|
||||
*/
|
||||
void handleSpawnObject(SPacketSpawnObject packetIn);
|
||||
|
||||
/**
|
||||
* Spawns an experience orb and sets its value (amount of XP)
|
||||
*/
|
||||
void handleSpawnExperienceOrb(SPacketSpawnExperienceOrb packetIn);
|
||||
|
||||
/**
|
||||
* Handles globally visible entities. Used in vanilla for lightning bolts
|
||||
*/
|
||||
void handleSpawnGlobalEntity(SPacketSpawnGlobalEntity packetIn);
|
||||
|
||||
/**
|
||||
* Spawns the mob entity at the specified location, with the specified rotation, momentum and type. Updates the
|
||||
* entities Datawatchers with the entity metadata specified in the packet
|
||||
*/
|
||||
void handleSpawnMob(SPacketSpawnMob packetIn);
|
||||
|
||||
/**
|
||||
* May create a scoreboard objective, remove an objective from the scoreboard or update an objectives' displayname
|
||||
*/
|
||||
void handleScoreboardObjective(SPacketScoreboardObjective packetIn);
|
||||
|
||||
/**
|
||||
* Handles the spawning of a painting object
|
||||
*/
|
||||
void handleSpawnPainting(SPacketSpawnPainting packetIn);
|
||||
|
||||
/**
|
||||
* Handles the creation of a nearby player entity, sets the position and held item
|
||||
*/
|
||||
void handleSpawnPlayer(SPacketSpawnPlayer packetIn);
|
||||
|
||||
/**
|
||||
* Renders a specified animation: Waking up a player, a living entity swinging its currently held item, being hurt
|
||||
* or receiving a critical hit by normal or magical means
|
||||
*/
|
||||
void handleAnimation(SPacketAnimation packetIn);
|
||||
|
||||
/**
|
||||
* Updates the players statistics or achievements
|
||||
*/
|
||||
void handleStatistics(SPacketStatistics packetIn);
|
||||
|
||||
void handleRecipeBook(SPacketRecipeBook packetIn);
|
||||
|
||||
/**
|
||||
* Updates all registered IWorldAccess instances with destroyBlockInWorldPartially
|
||||
*/
|
||||
void handleBlockBreakAnim(SPacketBlockBreakAnim packetIn);
|
||||
|
||||
/**
|
||||
* Creates a sign in the specified location if it didn't exist and opens the GUI to edit its text
|
||||
*/
|
||||
void handleSignEditorOpen(SPacketSignEditorOpen packetIn);
|
||||
|
||||
/**
|
||||
* Updates the NBTTagCompound metadata of instances of the following entitytypes: Mob spawners, command blocks,
|
||||
* beacons, skulls, flowerpot
|
||||
*/
|
||||
void handleUpdateTileEntity(SPacketUpdateTileEntity packetIn);
|
||||
|
||||
/**
|
||||
* Triggers Block.onBlockEventReceived, which is implemented in BlockPistonBase for extension/retraction, BlockNote
|
||||
* for setting the instrument (including audiovisual feedback) and in BlockContainer to set the number of players
|
||||
* accessing a (Ender)Chest
|
||||
*/
|
||||
void handleBlockAction(SPacketBlockAction packetIn);
|
||||
|
||||
/**
|
||||
* Updates the block and metadata and generates a blockupdate (and notify the clients)
|
||||
*/
|
||||
void handleBlockChange(SPacketBlockChange packetIn);
|
||||
|
||||
/**
|
||||
* Prints a chatmessage in the chat GUI
|
||||
*/
|
||||
void handleChat(SPacketChat packetIn);
|
||||
|
||||
/**
|
||||
* Displays the available command-completion options the server knows of
|
||||
*/
|
||||
void handleTabComplete(SPacketTabComplete packetIn);
|
||||
|
||||
/**
|
||||
* Received from the servers PlayerManager if between 1 and 64 blocks in a chunk are changed. If only one block
|
||||
* requires an update, the server sends S23PacketBlockChange and if 64 or more blocks are changed, the server sends
|
||||
* S21PacketChunkData
|
||||
*/
|
||||
void handleMultiBlockChange(SPacketMultiBlockChange packetIn);
|
||||
|
||||
/**
|
||||
* Updates the worlds MapStorage with the specified MapData for the specified map-identifier and invokes a
|
||||
* MapItemRenderer for it
|
||||
*/
|
||||
void handleMaps(SPacketMaps packetIn);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void handleConfirmTransaction(SPacketConfirmTransaction packetIn);
|
||||
|
||||
/**
|
||||
* Resets the ItemStack held in hand and closes the window that is opened
|
||||
*/
|
||||
void handleCloseWindow(SPacketCloseWindow packetIn);
|
||||
|
||||
/**
|
||||
* Handles the placement of a specified ItemStack in a specified container/inventory slot
|
||||
*/
|
||||
void handleWindowItems(SPacketWindowItems packetIn);
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
void handleOpenWindow(SPacketOpenWindow packetIn);
|
||||
|
||||
/**
|
||||
* Sets the progressbar of the opened window to the specified value
|
||||
*/
|
||||
void handleWindowProperty(SPacketWindowProperty packetIn);
|
||||
|
||||
/**
|
||||
* Handles pickin up an ItemStack or dropping one in your inventory or an open (non-creative) container
|
||||
*/
|
||||
void handleSetSlot(SPacketSetSlot packetIn);
|
||||
|
||||
/**
|
||||
* Handles packets that have room for a channel specification. Vanilla implemented channels are "MC|TrList" to
|
||||
* acquire a MerchantRecipeList trades for a villager merchant, "MC|Brand" which sets the server brand? on the
|
||||
* player instance and finally "MC|RPack" which the server uses to communicate the identifier of the default server
|
||||
* resourcepack for the client to load.
|
||||
*/
|
||||
void handleCustomPayload(SPacketCustomPayload packetIn);
|
||||
|
||||
/**
|
||||
* Closes the network channel
|
||||
*/
|
||||
void handleDisconnect(SPacketDisconnect packetIn);
|
||||
|
||||
/**
|
||||
* Retrieves the player identified by the packet, puts him to sleep if possible (and flags whether all players are
|
||||
* asleep)
|
||||
*/
|
||||
void handleUseBed(SPacketUseBed packetIn);
|
||||
|
||||
/**
|
||||
* Invokes the entities' handleUpdateHealth method which is implemented in LivingBase (hurt/death),
|
||||
* MinecartMobSpawner (spawn delay), FireworkRocket & MinecartTNT (explosion), IronGolem (throwing,...), Witch
|
||||
* (spawn particles), Zombie (villager transformation), Animal (breeding mode particles), Horse (breeding/smoke
|
||||
* particles), Sheep (...), Tameable (...), Villager (particles for breeding mode, angry and happy), Wolf (...)
|
||||
*/
|
||||
void handleEntityStatus(SPacketEntityStatus packetIn);
|
||||
|
||||
void handleEntityAttach(SPacketEntityAttach packetIn);
|
||||
|
||||
void handleSetPassengers(SPacketSetPassengers packetIn);
|
||||
|
||||
/**
|
||||
* Initiates a new explosion (sound, particles, drop spawn) for the affected blocks indicated by the packet.
|
||||
*/
|
||||
void handleExplosion(SPacketExplosion packetIn);
|
||||
|
||||
void handleChangeGameState(SPacketChangeGameState packetIn);
|
||||
|
||||
void handleKeepAlive(SPacketKeepAlive packetIn);
|
||||
|
||||
/**
|
||||
* Updates the specified chunk with the supplied data, marks it for re-rendering and lighting recalculation
|
||||
*/
|
||||
void handleChunkData(SPacketChunkData packetIn);
|
||||
|
||||
void processChunkUnload(SPacketUnloadChunk packetIn);
|
||||
|
||||
void handleEffect(SPacketEffect packetIn);
|
||||
|
||||
/**
|
||||
* Registers some server properties (gametype,hardcore-mode,terraintype,difficulty,player limit), creates a new
|
||||
* WorldClient and sets the player initial dimension
|
||||
*/
|
||||
void handleJoinGame(SPacketJoinGame packetIn);
|
||||
|
||||
/**
|
||||
* Updates the specified entity's position by the specified relative moment and absolute rotation. Note that
|
||||
* subclassing of the packet allows for the specification of a subset of this data (e.g. only rel. position, abs.
|
||||
* rotation or both).
|
||||
*/
|
||||
void handleEntityMovement(SPacketEntity packetIn);
|
||||
|
||||
void handlePlayerPosLook(SPacketPlayerPosLook packetIn);
|
||||
|
||||
/**
|
||||
* Spawns a specified number of particles at the specified location with a randomized displacement according to
|
||||
* specified bounds
|
||||
*/
|
||||
void handleParticles(SPacketParticles packetIn);
|
||||
|
||||
void handlePlayerAbilities(SPacketPlayerAbilities packetIn);
|
||||
|
||||
void handlePlayerListItem(SPacketPlayerListItem packetIn);
|
||||
|
||||
/**
|
||||
* Locally eliminates the entities. Invoked by the server when the items are in fact destroyed, or the player is no
|
||||
* longer registered as required to monitor them. The latter happens when distance between the player and item
|
||||
* increases beyond a certain treshold (typically the viewing distance)
|
||||
*/
|
||||
void handleDestroyEntities(SPacketDestroyEntities packetIn);
|
||||
|
||||
void handleRemoveEntityEffect(SPacketRemoveEntityEffect packetIn);
|
||||
|
||||
void handleRespawn(SPacketRespawn packetIn);
|
||||
|
||||
/**
|
||||
* Updates the direction in which the specified entity is looking, normally this head rotation is independent of the
|
||||
* rotation of the entity itself
|
||||
*/
|
||||
void handleEntityHeadLook(SPacketEntityHeadLook packetIn);
|
||||
|
||||
/**
|
||||
* Updates which hotbar slot of the player is currently selected
|
||||
*/
|
||||
void handleHeldItemChange(SPacketHeldItemChange packetIn);
|
||||
|
||||
/**
|
||||
* Removes or sets the ScoreObjective to be displayed at a particular scoreboard position (list, sidebar, below
|
||||
* name)
|
||||
*/
|
||||
void handleDisplayObjective(SPacketDisplayObjective packetIn);
|
||||
|
||||
/**
|
||||
* Invoked when the server registers new proximate objects in your watchlist or when objects in your watchlist have
|
||||
* changed -> Registers any changes locally
|
||||
*/
|
||||
void handleEntityMetadata(SPacketEntityMetadata packetIn);
|
||||
|
||||
/**
|
||||
* Sets the velocity of the specified entity to the specified value
|
||||
*/
|
||||
void handleEntityVelocity(SPacketEntityVelocity packetIn);
|
||||
|
||||
void handleEntityEquipment(SPacketEntityEquipment packetIn);
|
||||
|
||||
void handleSetExperience(SPacketSetExperience packetIn);
|
||||
|
||||
void handleUpdateHealth(SPacketUpdateHealth packetIn);
|
||||
|
||||
/**
|
||||
* Updates a team managed by the scoreboard: Create/Remove the team registration, Register/Remove the player-team-
|
||||
* memberships, Set team displayname/prefix/suffix and/or whether friendly fire is enabled
|
||||
*/
|
||||
void handleTeams(SPacketTeams packetIn);
|
||||
|
||||
/**
|
||||
* Either updates the score with a specified value or removes the score for an objective
|
||||
*/
|
||||
void handleUpdateScore(SPacketUpdateScore packetIn);
|
||||
|
||||
void handleSpawnPosition(SPacketSpawnPosition packetIn);
|
||||
|
||||
void handleTimeUpdate(SPacketTimeUpdate packetIn);
|
||||
|
||||
void handleSoundEffect(SPacketSoundEffect packetIn);
|
||||
|
||||
void handleCustomSound(SPacketCustomSound packetIn);
|
||||
|
||||
void handleCollectItem(SPacketCollectItem packetIn);
|
||||
|
||||
/**
|
||||
* Updates an entity's position and rotation as specified by the packet
|
||||
*/
|
||||
void handleEntityTeleport(SPacketEntityTeleport packetIn);
|
||||
|
||||
/**
|
||||
* Updates en entity's attributes and their respective modifiers, which are used for speed bonusses (player
|
||||
* sprinting, animals fleeing, baby speed), weapon/tool attackDamage, hostiles followRange randomization, zombie
|
||||
* maxHealth and knockback resistance as well as reinforcement spawning chance.
|
||||
*/
|
||||
void handleEntityProperties(SPacketEntityProperties packetIn);
|
||||
|
||||
void handleEntityEffect(SPacketEntityEffect packetIn);
|
||||
|
||||
void handleCombatEvent(SPacketCombatEvent packetIn);
|
||||
|
||||
void handleServerDifficulty(SPacketServerDifficulty packetIn);
|
||||
|
||||
void handleCamera(SPacketCamera packetIn);
|
||||
|
||||
void handleWorldBorder(SPacketWorldBorder packetIn);
|
||||
|
||||
void handleTitle(SPacketTitle packetIn);
|
||||
|
||||
void handlePlayerListHeaderFooter(SPacketPlayerListHeaderFooter packetIn);
|
||||
|
||||
void handleResourcePack(SPacketResourcePackSend packetIn);
|
||||
|
||||
void handleUpdateBossInfo(SPacketUpdateBossInfo packetIn);
|
||||
|
||||
void handleCooldown(SPacketCooldown packetIn);
|
||||
|
||||
void handleMoveVehicle(SPacketMoveVehicle packetIn);
|
||||
|
||||
void handleAdvancementInfo(SPacketAdvancementInfo packetIn);
|
||||
|
||||
void handleSelectAdvancementsTab(SPacketSelectAdvancementsTab packetIn);
|
||||
|
||||
void func_194307_a(SPacketPlaceGhostRecipe p_194307_1_);
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package net.minecraft.network.play;
|
||||
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.play.client.CPacketAnimation;
|
||||
import net.minecraft.network.play.client.CPacketChatMessage;
|
||||
import net.minecraft.network.play.client.CPacketClickWindow;
|
||||
import net.minecraft.network.play.client.CPacketClientSettings;
|
||||
import net.minecraft.network.play.client.CPacketClientStatus;
|
||||
import net.minecraft.network.play.client.CPacketCloseWindow;
|
||||
import net.minecraft.network.play.client.CPacketConfirmTeleport;
|
||||
import net.minecraft.network.play.client.CPacketConfirmTransaction;
|
||||
import net.minecraft.network.play.client.CPacketCreativeInventoryAction;
|
||||
import net.minecraft.network.play.client.CPacketCustomPayload;
|
||||
import net.minecraft.network.play.client.CPacketEnchantItem;
|
||||
import net.minecraft.network.play.client.CPacketEntityAction;
|
||||
import net.minecraft.network.play.client.CPacketHeldItemChange;
|
||||
import net.minecraft.network.play.client.CPacketInput;
|
||||
import net.minecraft.network.play.client.CPacketKeepAlive;
|
||||
import net.minecraft.network.play.client.CPacketPlaceRecipe;
|
||||
import net.minecraft.network.play.client.CPacketPlayer;
|
||||
import net.minecraft.network.play.client.CPacketPlayerAbilities;
|
||||
import net.minecraft.network.play.client.CPacketPlayerDigging;
|
||||
import net.minecraft.network.play.client.CPacketPlayerTryUseItem;
|
||||
import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock;
|
||||
import net.minecraft.network.play.client.CPacketRecipeInfo;
|
||||
import net.minecraft.network.play.client.CPacketResourcePackStatus;
|
||||
import net.minecraft.network.play.client.CPacketSeenAdvancements;
|
||||
import net.minecraft.network.play.client.CPacketSpectate;
|
||||
import net.minecraft.network.play.client.CPacketSteerBoat;
|
||||
import net.minecraft.network.play.client.CPacketTabComplete;
|
||||
import net.minecraft.network.play.client.CPacketUpdateSign;
|
||||
import net.minecraft.network.play.client.CPacketUseEntity;
|
||||
import net.minecraft.network.play.client.CPacketVehicleMove;
|
||||
|
||||
public interface INetHandlerPlayServer extends INetHandler
|
||||
{
|
||||
void handleAnimation(CPacketAnimation packetIn);
|
||||
|
||||
/**
|
||||
* Process chat messages (broadcast back to clients) and commands (executes)
|
||||
*/
|
||||
void processChatMessage(CPacketChatMessage packetIn);
|
||||
|
||||
/**
|
||||
* Retrieves possible tab completions for the requested command string and sends them to the client
|
||||
*/
|
||||
void processTabComplete(CPacketTabComplete packetIn);
|
||||
|
||||
/**
|
||||
* Processes the client status updates: respawn attempt from player, opening statistics or achievements, or
|
||||
* acquiring 'open inventory' achievement
|
||||
*/
|
||||
void processClientStatus(CPacketClientStatus packetIn);
|
||||
|
||||
/**
|
||||
* Updates serverside copy of client settings: language, render distance, chat visibility, chat colours, difficulty,
|
||||
* and whether to show the cape
|
||||
*/
|
||||
void processClientSettings(CPacketClientSettings packetIn);
|
||||
|
||||
/**
|
||||
* Received in response to the server requesting to confirm that the client-side open container matches the servers'
|
||||
* after a mismatched container-slot manipulation. It will unlock the player's ability to manipulate the container
|
||||
* contents
|
||||
*/
|
||||
void processConfirmTransaction(CPacketConfirmTransaction packetIn);
|
||||
|
||||
/**
|
||||
* Enchants the item identified by the packet given some convoluted conditions (matching window, which
|
||||
* should/shouldn't be in use?)
|
||||
*/
|
||||
void processEnchantItem(CPacketEnchantItem packetIn);
|
||||
|
||||
/**
|
||||
* Executes a container/inventory slot manipulation as indicated by the packet. Sends the serverside result if they
|
||||
* didn't match the indicated result and prevents further manipulation by the player until he confirms that it has
|
||||
* the same open container/inventory
|
||||
*/
|
||||
void processClickWindow(CPacketClickWindow packetIn);
|
||||
|
||||
void func_194308_a(CPacketPlaceRecipe p_194308_1_);
|
||||
|
||||
/**
|
||||
* Processes the client closing windows (container)
|
||||
*/
|
||||
void processCloseWindow(CPacketCloseWindow packetIn);
|
||||
|
||||
/**
|
||||
* Synchronizes serverside and clientside book contents and signing
|
||||
*/
|
||||
void processCustomPayload(CPacketCustomPayload packetIn);
|
||||
|
||||
/**
|
||||
* Processes left and right clicks on entities
|
||||
*/
|
||||
void processUseEntity(CPacketUseEntity packetIn);
|
||||
|
||||
/**
|
||||
* Updates a players' ping statistics
|
||||
*/
|
||||
void processKeepAlive(CPacketKeepAlive packetIn);
|
||||
|
||||
/**
|
||||
* Processes clients perspective on player positioning and/or orientation
|
||||
*/
|
||||
void processPlayer(CPacketPlayer packetIn);
|
||||
|
||||
/**
|
||||
* Processes a player starting/stopping flying
|
||||
*/
|
||||
void processPlayerAbilities(CPacketPlayerAbilities packetIn);
|
||||
|
||||
/**
|
||||
* Processes the player initiating/stopping digging on a particular spot, as well as a player dropping items
|
||||
*/
|
||||
void processPlayerDigging(CPacketPlayerDigging packetIn);
|
||||
|
||||
/**
|
||||
* Processes a range of action-types: sneaking, sprinting, waking from sleep, opening the inventory or setting jump
|
||||
* height of the horse the player is riding
|
||||
*/
|
||||
void processEntityAction(CPacketEntityAction packetIn);
|
||||
|
||||
/**
|
||||
* Processes player movement input. Includes walking, strafing, jumping, sneaking; excludes riding and toggling
|
||||
* flying/sprinting
|
||||
*/
|
||||
void processInput(CPacketInput packetIn);
|
||||
|
||||
/**
|
||||
* Updates which quickbar slot is selected
|
||||
*/
|
||||
void processHeldItemChange(CPacketHeldItemChange packetIn);
|
||||
|
||||
/**
|
||||
* Update the server with an ItemStack in a slot.
|
||||
*/
|
||||
void processCreativeInventoryAction(CPacketCreativeInventoryAction packetIn);
|
||||
|
||||
void processUpdateSign(CPacketUpdateSign packetIn);
|
||||
|
||||
void processTryUseItemOnBlock(CPacketPlayerTryUseItemOnBlock packetIn);
|
||||
|
||||
/**
|
||||
* Called when a client is using an item while not pointing at a block, but simply using an item
|
||||
*/
|
||||
void processTryUseItem(CPacketPlayerTryUseItem packetIn);
|
||||
|
||||
void handleSpectate(CPacketSpectate packetIn);
|
||||
|
||||
void handleResourcePackStatus(CPacketResourcePackStatus packetIn);
|
||||
|
||||
void processSteerBoat(CPacketSteerBoat packetIn);
|
||||
|
||||
void processVehicleMove(CPacketVehicleMove packetIn);
|
||||
|
||||
void processConfirmTeleport(CPacketConfirmTeleport packetIn);
|
||||
|
||||
void handleRecipeBookUpdate(CPacketRecipeInfo p_191984_1_);
|
||||
|
||||
void handleSeenAdvancements(CPacketSeenAdvancements p_194027_1_);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraft.util.EnumHand;
|
||||
|
||||
public class CPacketAnimation implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private EnumHand hand;
|
||||
|
||||
public CPacketAnimation()
|
||||
{
|
||||
}
|
||||
|
||||
public CPacketAnimation(EnumHand handIn)
|
||||
{
|
||||
this.hand = handIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.hand = (EnumHand)buf.readEnumValue(EnumHand.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeEnumValue(this.hand);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.handleAnimation(this);
|
||||
}
|
||||
|
||||
public EnumHand getHand()
|
||||
{
|
||||
return this.hand;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
|
||||
public class CPacketChatMessage implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private String message;
|
||||
|
||||
public CPacketChatMessage()
|
||||
{
|
||||
}
|
||||
|
||||
public CPacketChatMessage(String messageIn)
|
||||
{
|
||||
if (messageIn.length() > 256)
|
||||
{
|
||||
messageIn = messageIn.substring(0, 256);
|
||||
}
|
||||
|
||||
this.message = messageIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.message = buf.readString(256);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeString(this.message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processChatMessage(this);
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return this.message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.inventory.ClickType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CPacketClickWindow implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
/** The id of the window which was clicked. 0 for player inventory. */
|
||||
private int windowId;
|
||||
/** Id of the clicked slot */
|
||||
private int slotId;
|
||||
/** Button used */
|
||||
private int packedClickData;
|
||||
/** A unique number for the action, used for transaction handling */
|
||||
private short actionNumber;
|
||||
/** The item stack present in the slot */
|
||||
private ItemStack clickedItem = ItemStack.EMPTY;
|
||||
/** Inventory operation mode */
|
||||
private ClickType mode;
|
||||
|
||||
public CPacketClickWindow()
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketClickWindow(int windowIdIn, int slotIdIn, int usedButtonIn, ClickType modeIn, ItemStack clickedItemIn, short actionNumberIn)
|
||||
{
|
||||
this.windowId = windowIdIn;
|
||||
this.slotId = slotIdIn;
|
||||
this.packedClickData = usedButtonIn;
|
||||
this.clickedItem = clickedItemIn.copy();
|
||||
this.actionNumber = actionNumberIn;
|
||||
this.mode = modeIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processClickWindow(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.windowId = buf.readByte();
|
||||
this.slotId = buf.readShort();
|
||||
this.packedClickData = buf.readByte();
|
||||
this.actionNumber = buf.readShort();
|
||||
this.mode = (ClickType)buf.readEnumValue(ClickType.class);
|
||||
this.clickedItem = buf.readItemStack();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeByte(this.windowId);
|
||||
buf.writeShort(this.slotId);
|
||||
buf.writeByte(this.packedClickData);
|
||||
buf.writeShort(this.actionNumber);
|
||||
buf.writeEnumValue(this.mode);
|
||||
net.minecraftforge.common.util.PacketUtil.writeItemStackFromClientToServer(buf, this.clickedItem);
|
||||
}
|
||||
|
||||
public int getWindowId()
|
||||
{
|
||||
return this.windowId;
|
||||
}
|
||||
|
||||
public int getSlotId()
|
||||
{
|
||||
return this.slotId;
|
||||
}
|
||||
|
||||
public int getUsedButton()
|
||||
{
|
||||
return this.packedClickData;
|
||||
}
|
||||
|
||||
public short getActionNumber()
|
||||
{
|
||||
return this.actionNumber;
|
||||
}
|
||||
|
||||
public ItemStack getClickedItem()
|
||||
{
|
||||
return this.clickedItem;
|
||||
}
|
||||
|
||||
public ClickType getClickType()
|
||||
{
|
||||
return this.mode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraft.util.EnumHandSide;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CPacketClientSettings implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private String lang;
|
||||
private int view;
|
||||
private EntityPlayer.EnumChatVisibility chatVisibility;
|
||||
private boolean enableColors;
|
||||
private int modelPartFlags;
|
||||
private EnumHandSide mainHand;
|
||||
|
||||
public CPacketClientSettings()
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketClientSettings(String langIn, int renderDistanceIn, EntityPlayer.EnumChatVisibility chatVisibilityIn, boolean chatColorsIn, int modelPartsIn, EnumHandSide mainHandIn)
|
||||
{
|
||||
this.lang = langIn;
|
||||
this.view = renderDistanceIn;
|
||||
this.chatVisibility = chatVisibilityIn;
|
||||
this.enableColors = chatColorsIn;
|
||||
this.modelPartFlags = modelPartsIn;
|
||||
this.mainHand = mainHandIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.lang = buf.readString(16);
|
||||
this.view = buf.readByte();
|
||||
this.chatVisibility = (EntityPlayer.EnumChatVisibility)buf.readEnumValue(EntityPlayer.EnumChatVisibility.class);
|
||||
this.enableColors = buf.readBoolean();
|
||||
this.modelPartFlags = buf.readUnsignedByte();
|
||||
this.mainHand = (EnumHandSide)buf.readEnumValue(EnumHandSide.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeString(this.lang);
|
||||
buf.writeByte(this.view);
|
||||
buf.writeEnumValue(this.chatVisibility);
|
||||
buf.writeBoolean(this.enableColors);
|
||||
buf.writeByte(this.modelPartFlags);
|
||||
buf.writeEnumValue(this.mainHand);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processClientSettings(this);
|
||||
}
|
||||
|
||||
public String getLang()
|
||||
{
|
||||
return this.lang;
|
||||
}
|
||||
|
||||
public EntityPlayer.EnumChatVisibility getChatVisibility()
|
||||
{
|
||||
return this.chatVisibility;
|
||||
}
|
||||
|
||||
public boolean isColorsEnabled()
|
||||
{
|
||||
return this.enableColors;
|
||||
}
|
||||
|
||||
public int getModelPartFlags()
|
||||
{
|
||||
return this.modelPartFlags;
|
||||
}
|
||||
|
||||
public EnumHandSide getMainHand()
|
||||
{
|
||||
return this.mainHand;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
|
||||
public class CPacketClientStatus implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private CPacketClientStatus.State status;
|
||||
|
||||
public CPacketClientStatus()
|
||||
{
|
||||
}
|
||||
|
||||
public CPacketClientStatus(CPacketClientStatus.State p_i46886_1_)
|
||||
{
|
||||
this.status = p_i46886_1_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.status = (CPacketClientStatus.State)buf.readEnumValue(CPacketClientStatus.State.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeEnumValue(this.status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processClientStatus(this);
|
||||
}
|
||||
|
||||
public CPacketClientStatus.State getStatus()
|
||||
{
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public static enum State
|
||||
{
|
||||
PERFORM_RESPAWN,
|
||||
REQUEST_STATS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CPacketCloseWindow implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private int windowId;
|
||||
|
||||
public CPacketCloseWindow()
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketCloseWindow(int windowIdIn)
|
||||
{
|
||||
this.windowId = windowIdIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processCloseWindow(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.windowId = buf.readByte();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeByte(this.windowId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CPacketConfirmTeleport implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private int telportId;
|
||||
|
||||
public CPacketConfirmTeleport()
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketConfirmTeleport(int teleportIdIn)
|
||||
{
|
||||
this.telportId = teleportIdIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.telportId = buf.readVarInt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarInt(this.telportId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processConfirmTeleport(this);
|
||||
}
|
||||
|
||||
public int getTeleportId()
|
||||
{
|
||||
return this.telportId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CPacketConfirmTransaction implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private int windowId;
|
||||
private short uid;
|
||||
private boolean accepted;
|
||||
|
||||
public CPacketConfirmTransaction()
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketConfirmTransaction(int windowIdIn, short uidIn, boolean acceptedIn)
|
||||
{
|
||||
this.windowId = windowIdIn;
|
||||
this.uid = uidIn;
|
||||
this.accepted = acceptedIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processConfirmTransaction(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.windowId = buf.readByte();
|
||||
this.uid = buf.readShort();
|
||||
this.accepted = buf.readByte() != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeByte(this.windowId);
|
||||
buf.writeShort(this.uid);
|
||||
buf.writeByte(this.accepted ? 1 : 0);
|
||||
}
|
||||
|
||||
public int getWindowId()
|
||||
{
|
||||
return this.windowId;
|
||||
}
|
||||
|
||||
public short getUid()
|
||||
{
|
||||
return this.uid;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CPacketCreativeInventoryAction implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private int slotId;
|
||||
private ItemStack stack = ItemStack.EMPTY;
|
||||
|
||||
public CPacketCreativeInventoryAction()
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketCreativeInventoryAction(int slotIdIn, ItemStack stackIn)
|
||||
{
|
||||
this.slotId = slotIdIn;
|
||||
this.stack = stackIn.copy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processCreativeInventoryAction(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.slotId = buf.readShort();
|
||||
this.stack = buf.readItemStack();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeShort(this.slotId);
|
||||
net.minecraftforge.common.util.PacketUtil.writeItemStackFromClientToServer(buf, this.stack);
|
||||
}
|
||||
|
||||
public int getSlotId()
|
||||
{
|
||||
return this.slotId;
|
||||
}
|
||||
|
||||
public ItemStack getStack()
|
||||
{
|
||||
return this.stack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CPacketCustomPayload implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private String channel;
|
||||
private PacketBuffer data;
|
||||
|
||||
public CPacketCustomPayload()
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketCustomPayload(String channelIn, PacketBuffer bufIn)
|
||||
{
|
||||
this.channel = channelIn;
|
||||
this.data = bufIn;
|
||||
|
||||
if (bufIn.writerIndex() > 32767)
|
||||
{
|
||||
throw new IllegalArgumentException("Payload may not be larger than 32767 bytes");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.channel = buf.readString(20);
|
||||
int i = buf.readableBytes();
|
||||
|
||||
if (i >= 0 && i <= 32767)
|
||||
{
|
||||
this.data = new PacketBuffer(buf.readBytes(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IOException("Payload may not be larger than 32767 bytes");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeString(this.channel);
|
||||
synchronized(this.data) { //This may be access multiple times, from multiple threads, lets be safe.
|
||||
this.data.markReaderIndex();
|
||||
buf.writeBytes((ByteBuf)this.data);
|
||||
this.data.resetReaderIndex();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processCustomPayload(this);
|
||||
|
||||
if (this.data != null)
|
||||
{
|
||||
this.data.release();
|
||||
}
|
||||
}
|
||||
|
||||
public String getChannelName()
|
||||
{
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
public PacketBuffer getBufferData()
|
||||
{
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CPacketEnchantItem implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private int windowId;
|
||||
private int button;
|
||||
|
||||
public CPacketEnchantItem()
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketEnchantItem(int windowIdIn, int buttonIn)
|
||||
{
|
||||
this.windowId = windowIdIn;
|
||||
this.button = buttonIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processEnchantItem(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.windowId = buf.readByte();
|
||||
this.button = buf.readByte();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeByte(this.windowId);
|
||||
buf.writeByte(this.button);
|
||||
}
|
||||
|
||||
public int getWindowId()
|
||||
{
|
||||
return this.windowId;
|
||||
}
|
||||
|
||||
public int getButton()
|
||||
{
|
||||
return this.button;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CPacketEntityAction implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private int entityID;
|
||||
private CPacketEntityAction.Action action;
|
||||
private int auxData;
|
||||
|
||||
public CPacketEntityAction()
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketEntityAction(Entity entityIn, CPacketEntityAction.Action actionIn)
|
||||
{
|
||||
this(entityIn, actionIn, 0);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketEntityAction(Entity entityIn, CPacketEntityAction.Action actionIn, int auxDataIn)
|
||||
{
|
||||
this.entityID = entityIn.getEntityId();
|
||||
this.action = actionIn;
|
||||
this.auxData = auxDataIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityID = buf.readVarInt();
|
||||
this.action = (CPacketEntityAction.Action)buf.readEnumValue(CPacketEntityAction.Action.class);
|
||||
this.auxData = buf.readVarInt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarInt(this.entityID);
|
||||
buf.writeEnumValue(this.action);
|
||||
buf.writeVarInt(this.auxData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processEntityAction(this);
|
||||
}
|
||||
|
||||
public CPacketEntityAction.Action getAction()
|
||||
{
|
||||
return this.action;
|
||||
}
|
||||
|
||||
public int getAuxData()
|
||||
{
|
||||
return this.auxData;
|
||||
}
|
||||
|
||||
public static enum Action
|
||||
{
|
||||
START_SNEAKING,
|
||||
STOP_SNEAKING,
|
||||
STOP_SLEEPING,
|
||||
START_SPRINTING,
|
||||
STOP_SPRINTING,
|
||||
START_RIDING_JUMP,
|
||||
STOP_RIDING_JUMP,
|
||||
OPEN_INVENTORY,
|
||||
START_FALL_FLYING;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CPacketHeldItemChange implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private int slotId;
|
||||
|
||||
public CPacketHeldItemChange()
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketHeldItemChange(int slotIdIn)
|
||||
{
|
||||
this.slotId = slotIdIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.slotId = buf.readShort();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeShort(this.slotId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processHeldItemChange(this);
|
||||
}
|
||||
|
||||
public int getSlotId()
|
||||
{
|
||||
return this.slotId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CPacketInput implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
/** Positive for left strafe, negative for right */
|
||||
private float strafeSpeed;
|
||||
private float forwardSpeed;
|
||||
private boolean jumping;
|
||||
private boolean sneaking;
|
||||
|
||||
public CPacketInput()
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketInput(float strafeSpeedIn, float forwardSpeedIn, boolean jumpingIn, boolean sneakingIn)
|
||||
{
|
||||
this.strafeSpeed = strafeSpeedIn;
|
||||
this.forwardSpeed = forwardSpeedIn;
|
||||
this.jumping = jumpingIn;
|
||||
this.sneaking = sneakingIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.strafeSpeed = buf.readFloat();
|
||||
this.forwardSpeed = buf.readFloat();
|
||||
byte b0 = buf.readByte();
|
||||
this.jumping = (b0 & 1) > 0;
|
||||
this.sneaking = (b0 & 2) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeFloat(this.strafeSpeed);
|
||||
buf.writeFloat(this.forwardSpeed);
|
||||
byte b0 = 0;
|
||||
|
||||
if (this.jumping)
|
||||
{
|
||||
b0 = (byte)(b0 | 1);
|
||||
}
|
||||
|
||||
if (this.sneaking)
|
||||
{
|
||||
b0 = (byte)(b0 | 2);
|
||||
}
|
||||
|
||||
buf.writeByte(b0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processInput(this);
|
||||
}
|
||||
|
||||
public float getStrafeSpeed()
|
||||
{
|
||||
return this.strafeSpeed;
|
||||
}
|
||||
|
||||
public float getForwardSpeed()
|
||||
{
|
||||
return this.forwardSpeed;
|
||||
}
|
||||
|
||||
public boolean isJumping()
|
||||
{
|
||||
return this.jumping;
|
||||
}
|
||||
|
||||
public boolean isSneaking()
|
||||
{
|
||||
return this.sneaking;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CPacketKeepAlive implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private long key;
|
||||
|
||||
public CPacketKeepAlive()
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketKeepAlive(long idIn)
|
||||
{
|
||||
this.key = idIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processKeepAlive(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.key = buf.readLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeLong(this.key);
|
||||
}
|
||||
|
||||
public long getKey()
|
||||
{
|
||||
return this.key;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CPacketPlaceRecipe implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private int field_194320_a;
|
||||
private IRecipe field_194321_b;
|
||||
private boolean field_194322_c;
|
||||
|
||||
public CPacketPlaceRecipe()
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketPlaceRecipe(int p_i47614_1_, IRecipe p_i47614_2_, boolean p_i47614_3_)
|
||||
{
|
||||
this.field_194320_a = p_i47614_1_;
|
||||
this.field_194321_b = p_i47614_2_;
|
||||
this.field_194322_c = p_i47614_3_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.field_194320_a = buf.readByte();
|
||||
this.field_194321_b = CraftingManager.getRecipeById(buf.readVarInt());
|
||||
this.field_194322_c = buf.readBoolean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeByte(this.field_194320_a);
|
||||
buf.writeVarInt(CraftingManager.getIDForRecipe(this.field_194321_b));
|
||||
buf.writeBoolean(this.field_194322_c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.func_194308_a(this);
|
||||
}
|
||||
|
||||
public int func_194318_a()
|
||||
{
|
||||
return this.field_194320_a;
|
||||
}
|
||||
|
||||
public IRecipe func_194317_b()
|
||||
{
|
||||
return this.field_194321_b;
|
||||
}
|
||||
|
||||
public boolean func_194319_c()
|
||||
{
|
||||
return this.field_194322_c;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CPacketPlayer implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
protected double x;
|
||||
protected double y;
|
||||
protected double z;
|
||||
protected float yaw;
|
||||
protected float pitch;
|
||||
protected boolean onGround;
|
||||
protected boolean moving;
|
||||
protected boolean rotating;
|
||||
|
||||
public CPacketPlayer()
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketPlayer(boolean onGroundIn)
|
||||
{
|
||||
this.onGround = onGroundIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processPlayer(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.onGround = buf.readUnsignedByte() != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeByte(this.onGround ? 1 : 0);
|
||||
}
|
||||
|
||||
public double getX(double defaultValue)
|
||||
{
|
||||
return this.moving ? this.x : defaultValue;
|
||||
}
|
||||
|
||||
public double getY(double defaultValue)
|
||||
{
|
||||
return this.moving ? this.y : defaultValue;
|
||||
}
|
||||
|
||||
public double getZ(double defaultValue)
|
||||
{
|
||||
return this.moving ? this.z : defaultValue;
|
||||
}
|
||||
|
||||
public float getYaw(float defaultValue)
|
||||
{
|
||||
return this.rotating ? this.yaw : defaultValue;
|
||||
}
|
||||
|
||||
public float getPitch(float defaultValue)
|
||||
{
|
||||
return this.rotating ? this.pitch : defaultValue;
|
||||
}
|
||||
|
||||
public boolean isOnGround()
|
||||
{
|
||||
return this.onGround;
|
||||
}
|
||||
|
||||
public static class Position extends CPacketPlayer
|
||||
{
|
||||
public Position()
|
||||
{
|
||||
this.moving = true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Position(double xIn, double yIn, double zIn, boolean onGroundIn)
|
||||
{
|
||||
this.x = xIn;
|
||||
this.y = yIn;
|
||||
this.z = zIn;
|
||||
this.onGround = onGroundIn;
|
||||
this.moving = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.x = buf.readDouble();
|
||||
this.y = buf.readDouble();
|
||||
this.z = buf.readDouble();
|
||||
super.readPacketData(buf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
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 PositionRotation extends CPacketPlayer
|
||||
{
|
||||
public PositionRotation()
|
||||
{
|
||||
this.moving = true;
|
||||
this.rotating = true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public PositionRotation(double xIn, double yIn, double zIn, float yawIn, float pitchIn, boolean onGroundIn)
|
||||
{
|
||||
this.x = xIn;
|
||||
this.y = yIn;
|
||||
this.z = zIn;
|
||||
this.yaw = yawIn;
|
||||
this.pitch = pitchIn;
|
||||
this.onGround = onGroundIn;
|
||||
this.rotating = true;
|
||||
this.moving = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Rotation extends CPacketPlayer
|
||||
{
|
||||
public Rotation()
|
||||
{
|
||||
this.rotating = true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Rotation(float yawIn, float pitchIn, boolean onGroundIn)
|
||||
{
|
||||
this.yaw = yawIn;
|
||||
this.pitch = pitchIn;
|
||||
this.onGround = onGroundIn;
|
||||
this.rotating = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.yaw = buf.readFloat();
|
||||
this.pitch = buf.readFloat();
|
||||
super.readPacketData(buf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeFloat(this.yaw);
|
||||
buf.writeFloat(this.pitch);
|
||||
super.writePacketData(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.entity.player.PlayerCapabilities;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
|
||||
public class CPacketPlayerAbilities implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private boolean invulnerable;
|
||||
private boolean flying;
|
||||
private boolean allowFlying;
|
||||
private boolean creativeMode;
|
||||
private float flySpeed;
|
||||
private float walkSpeed;
|
||||
|
||||
public CPacketPlayerAbilities()
|
||||
{
|
||||
}
|
||||
|
||||
public CPacketPlayerAbilities(PlayerCapabilities capabilities)
|
||||
{
|
||||
this.setInvulnerable(capabilities.disableDamage);
|
||||
this.setFlying(capabilities.isFlying);
|
||||
this.setAllowFlying(capabilities.allowFlying);
|
||||
this.setCreativeMode(capabilities.isCreativeMode);
|
||||
this.setFlySpeed(capabilities.getFlySpeed());
|
||||
this.setWalkSpeed(capabilities.getWalkSpeed());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
byte b0 = buf.readByte();
|
||||
this.setInvulnerable((b0 & 1) > 0);
|
||||
this.setFlying((b0 & 2) > 0);
|
||||
this.setAllowFlying((b0 & 4) > 0);
|
||||
this.setCreativeMode((b0 & 8) > 0);
|
||||
this.setFlySpeed(buf.readFloat());
|
||||
this.setWalkSpeed(buf.readFloat());
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
byte b0 = 0;
|
||||
|
||||
if (this.isInvulnerable())
|
||||
{
|
||||
b0 = (byte)(b0 | 1);
|
||||
}
|
||||
|
||||
if (this.isFlying())
|
||||
{
|
||||
b0 = (byte)(b0 | 2);
|
||||
}
|
||||
|
||||
if (this.isAllowFlying())
|
||||
{
|
||||
b0 = (byte)(b0 | 4);
|
||||
}
|
||||
|
||||
if (this.isCreativeMode())
|
||||
{
|
||||
b0 = (byte)(b0 | 8);
|
||||
}
|
||||
|
||||
buf.writeByte(b0);
|
||||
buf.writeFloat(this.flySpeed);
|
||||
buf.writeFloat(this.walkSpeed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processPlayerAbilities(this);
|
||||
}
|
||||
|
||||
public boolean isInvulnerable()
|
||||
{
|
||||
return this.invulnerable;
|
||||
}
|
||||
|
||||
public void setInvulnerable(boolean isInvulnerable)
|
||||
{
|
||||
this.invulnerable = isInvulnerable;
|
||||
}
|
||||
|
||||
public boolean isFlying()
|
||||
{
|
||||
return this.flying;
|
||||
}
|
||||
|
||||
public void setFlying(boolean isFlying)
|
||||
{
|
||||
this.flying = isFlying;
|
||||
}
|
||||
|
||||
public boolean isAllowFlying()
|
||||
{
|
||||
return this.allowFlying;
|
||||
}
|
||||
|
||||
public void setAllowFlying(boolean isAllowFlying)
|
||||
{
|
||||
this.allowFlying = isAllowFlying;
|
||||
}
|
||||
|
||||
public boolean isCreativeMode()
|
||||
{
|
||||
return this.creativeMode;
|
||||
}
|
||||
|
||||
public void setCreativeMode(boolean isCreativeMode)
|
||||
{
|
||||
this.creativeMode = isCreativeMode;
|
||||
}
|
||||
|
||||
public void setFlySpeed(float flySpeedIn)
|
||||
{
|
||||
this.flySpeed = flySpeedIn;
|
||||
}
|
||||
|
||||
public void setWalkSpeed(float walkSpeedIn)
|
||||
{
|
||||
this.walkSpeed = walkSpeedIn;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CPacketPlayerDigging implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private BlockPos position;
|
||||
private EnumFacing facing;
|
||||
/** Status of the digging (started, ongoing, broken). */
|
||||
private CPacketPlayerDigging.Action action;
|
||||
|
||||
public CPacketPlayerDigging()
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketPlayerDigging(CPacketPlayerDigging.Action actionIn, BlockPos posIn, EnumFacing facingIn)
|
||||
{
|
||||
this.action = actionIn;
|
||||
this.position = posIn;
|
||||
this.facing = facingIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.action = (CPacketPlayerDigging.Action)buf.readEnumValue(CPacketPlayerDigging.Action.class);
|
||||
this.position = buf.readBlockPos();
|
||||
this.facing = EnumFacing.getFront(buf.readUnsignedByte());
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeEnumValue(this.action);
|
||||
buf.writeBlockPos(this.position);
|
||||
buf.writeByte(this.facing.getIndex());
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processPlayerDigging(this);
|
||||
}
|
||||
|
||||
public BlockPos getPosition()
|
||||
{
|
||||
return this.position;
|
||||
}
|
||||
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
return this.facing;
|
||||
}
|
||||
|
||||
public CPacketPlayerDigging.Action getAction()
|
||||
{
|
||||
return this.action;
|
||||
}
|
||||
|
||||
public static enum Action
|
||||
{
|
||||
START_DESTROY_BLOCK,
|
||||
ABORT_DESTROY_BLOCK,
|
||||
STOP_DESTROY_BLOCK,
|
||||
DROP_ALL_ITEMS,
|
||||
DROP_ITEM,
|
||||
RELEASE_USE_ITEM,
|
||||
SWAP_HELD_ITEMS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraft.util.EnumHand;
|
||||
|
||||
public class CPacketPlayerTryUseItem implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private EnumHand hand;
|
||||
|
||||
public CPacketPlayerTryUseItem()
|
||||
{
|
||||
}
|
||||
|
||||
public CPacketPlayerTryUseItem(EnumHand handIn)
|
||||
{
|
||||
this.hand = handIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.hand = (EnumHand)buf.readEnumValue(EnumHand.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeEnumValue(this.hand);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processTryUseItem(this);
|
||||
}
|
||||
|
||||
public EnumHand getHand()
|
||||
{
|
||||
return this.hand;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CPacketPlayerTryUseItemOnBlock implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private BlockPos position;
|
||||
private EnumFacing placedBlockDirection;
|
||||
private EnumHand hand;
|
||||
private float facingX;
|
||||
private float facingY;
|
||||
private float facingZ;
|
||||
|
||||
public CPacketPlayerTryUseItemOnBlock()
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketPlayerTryUseItemOnBlock(BlockPos posIn, EnumFacing placedBlockDirectionIn, EnumHand handIn, float facingXIn, float facingYIn, float facingZIn)
|
||||
{
|
||||
this.position = posIn;
|
||||
this.placedBlockDirection = placedBlockDirectionIn;
|
||||
this.hand = handIn;
|
||||
this.facingX = facingXIn;
|
||||
this.facingY = facingYIn;
|
||||
this.facingZ = facingZIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.position = buf.readBlockPos();
|
||||
this.placedBlockDirection = (EnumFacing)buf.readEnumValue(EnumFacing.class);
|
||||
this.hand = (EnumHand)buf.readEnumValue(EnumHand.class);
|
||||
this.facingX = buf.readFloat();
|
||||
this.facingY = buf.readFloat();
|
||||
this.facingZ = buf.readFloat();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeBlockPos(this.position);
|
||||
buf.writeEnumValue(this.placedBlockDirection);
|
||||
buf.writeEnumValue(this.hand);
|
||||
buf.writeFloat(this.facingX);
|
||||
buf.writeFloat(this.facingY);
|
||||
buf.writeFloat(this.facingZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processTryUseItemOnBlock(this);
|
||||
}
|
||||
|
||||
public BlockPos getPos()
|
||||
{
|
||||
return this.position;
|
||||
}
|
||||
|
||||
public EnumFacing getDirection()
|
||||
{
|
||||
return this.placedBlockDirection;
|
||||
}
|
||||
|
||||
public EnumHand getHand()
|
||||
{
|
||||
return this.hand;
|
||||
}
|
||||
|
||||
public float getFacingX()
|
||||
{
|
||||
return this.facingX;
|
||||
}
|
||||
|
||||
public float getFacingY()
|
||||
{
|
||||
return this.facingY;
|
||||
}
|
||||
|
||||
public float getFacingZ()
|
||||
{
|
||||
return this.facingZ;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CPacketRecipeInfo implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private CPacketRecipeInfo.Purpose purpose;
|
||||
private IRecipe recipe;
|
||||
private boolean isGuiOpen;
|
||||
private boolean filteringCraftable;
|
||||
|
||||
public CPacketRecipeInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public CPacketRecipeInfo(IRecipe p_i47518_1_)
|
||||
{
|
||||
this.purpose = CPacketRecipeInfo.Purpose.SHOWN;
|
||||
this.recipe = p_i47518_1_;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketRecipeInfo(boolean p_i47424_1_, boolean p_i47424_2_)
|
||||
{
|
||||
this.purpose = CPacketRecipeInfo.Purpose.SETTINGS;
|
||||
this.isGuiOpen = p_i47424_1_;
|
||||
this.filteringCraftable = p_i47424_2_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.purpose = (CPacketRecipeInfo.Purpose)buf.readEnumValue(CPacketRecipeInfo.Purpose.class);
|
||||
|
||||
if (this.purpose == CPacketRecipeInfo.Purpose.SHOWN)
|
||||
{
|
||||
this.recipe = CraftingManager.getRecipeById(buf.readInt());
|
||||
}
|
||||
else if (this.purpose == CPacketRecipeInfo.Purpose.SETTINGS)
|
||||
{
|
||||
this.isGuiOpen = buf.readBoolean();
|
||||
this.filteringCraftable = buf.readBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeEnumValue(this.purpose);
|
||||
|
||||
if (this.purpose == CPacketRecipeInfo.Purpose.SHOWN)
|
||||
{
|
||||
buf.writeInt(CraftingManager.getIDForRecipe(this.recipe));
|
||||
}
|
||||
else if (this.purpose == CPacketRecipeInfo.Purpose.SETTINGS)
|
||||
{
|
||||
buf.writeBoolean(this.isGuiOpen);
|
||||
buf.writeBoolean(this.filteringCraftable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.handleRecipeBookUpdate(this);
|
||||
}
|
||||
|
||||
public CPacketRecipeInfo.Purpose getPurpose()
|
||||
{
|
||||
return this.purpose;
|
||||
}
|
||||
|
||||
public IRecipe getRecipe()
|
||||
{
|
||||
return this.recipe;
|
||||
}
|
||||
|
||||
public boolean isGuiOpen()
|
||||
{
|
||||
return this.isGuiOpen;
|
||||
}
|
||||
|
||||
public boolean isFilteringCraftable()
|
||||
{
|
||||
return this.filteringCraftable;
|
||||
}
|
||||
|
||||
public static enum Purpose
|
||||
{
|
||||
SHOWN,
|
||||
SETTINGS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
|
||||
public class CPacketResourcePackStatus implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private CPacketResourcePackStatus.Action action;
|
||||
|
||||
public CPacketResourcePackStatus()
|
||||
{
|
||||
}
|
||||
|
||||
public CPacketResourcePackStatus(CPacketResourcePackStatus.Action p_i47156_1_)
|
||||
{
|
||||
this.action = p_i47156_1_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.action = (CPacketResourcePackStatus.Action)buf.readEnumValue(CPacketResourcePackStatus.Action.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeEnumValue(this.action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.handleResourcePackStatus(this);
|
||||
}
|
||||
|
||||
public static enum Action
|
||||
{
|
||||
SUCCESSFULLY_LOADED,
|
||||
DECLINED,
|
||||
FAILED_DOWNLOAD,
|
||||
ACCEPTED;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CPacketSeenAdvancements implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private CPacketSeenAdvancements.Action action;
|
||||
private ResourceLocation tab;
|
||||
|
||||
public CPacketSeenAdvancements()
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketSeenAdvancements(CPacketSeenAdvancements.Action p_i47595_1_, @Nullable ResourceLocation p_i47595_2_)
|
||||
{
|
||||
this.action = p_i47595_1_;
|
||||
this.tab = p_i47595_2_;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static CPacketSeenAdvancements openedTab(Advancement p_194163_0_)
|
||||
{
|
||||
return new CPacketSeenAdvancements(CPacketSeenAdvancements.Action.OPENED_TAB, p_194163_0_.getId());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static CPacketSeenAdvancements closedScreen()
|
||||
{
|
||||
return new CPacketSeenAdvancements(CPacketSeenAdvancements.Action.CLOSED_SCREEN, (ResourceLocation)null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.action = (CPacketSeenAdvancements.Action)buf.readEnumValue(CPacketSeenAdvancements.Action.class);
|
||||
|
||||
if (this.action == CPacketSeenAdvancements.Action.OPENED_TAB)
|
||||
{
|
||||
this.tab = buf.readResourceLocation();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeEnumValue(this.action);
|
||||
|
||||
if (this.action == CPacketSeenAdvancements.Action.OPENED_TAB)
|
||||
{
|
||||
buf.writeResourceLocation(this.tab);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.handleSeenAdvancements(this);
|
||||
}
|
||||
|
||||
public CPacketSeenAdvancements.Action getAction()
|
||||
{
|
||||
return this.action;
|
||||
}
|
||||
|
||||
public ResourceLocation getTab()
|
||||
{
|
||||
return this.tab;
|
||||
}
|
||||
|
||||
public static enum Action
|
||||
{
|
||||
OPENED_TAB,
|
||||
CLOSED_SCREEN;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
public class CPacketSpectate implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private UUID id;
|
||||
|
||||
public CPacketSpectate()
|
||||
{
|
||||
}
|
||||
|
||||
public CPacketSpectate(UUID uniqueIdIn)
|
||||
{
|
||||
this.id = uniqueIdIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.id = buf.readUniqueId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeUniqueId(this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.handleSpectate(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Entity getEntity(WorldServer worldIn)
|
||||
{
|
||||
return worldIn.getEntityFromUuid(this.id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
|
||||
public class CPacketSteerBoat implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private boolean left;
|
||||
private boolean right;
|
||||
|
||||
public CPacketSteerBoat()
|
||||
{
|
||||
}
|
||||
|
||||
public CPacketSteerBoat(boolean p_i46873_1_, boolean p_i46873_2_)
|
||||
{
|
||||
this.left = p_i46873_1_;
|
||||
this.right = p_i46873_2_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.left = buf.readBoolean();
|
||||
this.right = buf.readBoolean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeBoolean(this.left);
|
||||
buf.writeBoolean(this.right);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processSteerBoat(this);
|
||||
}
|
||||
|
||||
public boolean getLeft()
|
||||
{
|
||||
return this.left;
|
||||
}
|
||||
|
||||
public boolean getRight()
|
||||
{
|
||||
return this.right;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class CPacketTabComplete implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private String message;
|
||||
private boolean hasTargetBlock;
|
||||
@Nullable
|
||||
private BlockPos targetBlock;
|
||||
|
||||
public CPacketTabComplete()
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketTabComplete(String messageIn, @Nullable BlockPos targetBlockIn, boolean hasTargetBlockIn)
|
||||
{
|
||||
this.message = messageIn;
|
||||
this.targetBlock = targetBlockIn;
|
||||
this.hasTargetBlock = hasTargetBlockIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.message = buf.readString(32767);
|
||||
this.hasTargetBlock = buf.readBoolean();
|
||||
boolean flag = buf.readBoolean();
|
||||
|
||||
if (flag)
|
||||
{
|
||||
this.targetBlock = buf.readBlockPos();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeString(StringUtils.substring(this.message, 0, 32767));
|
||||
buf.writeBoolean(this.hasTargetBlock);
|
||||
boolean flag = this.targetBlock != null;
|
||||
buf.writeBoolean(flag);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
buf.writeBlockPos(this.targetBlock);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processTabComplete(this);
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return this.message;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BlockPos getTargetBlock()
|
||||
{
|
||||
return this.targetBlock;
|
||||
}
|
||||
|
||||
public boolean hasTargetBlock()
|
||||
{
|
||||
return this.hasTargetBlock;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CPacketUpdateSign implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private BlockPos pos;
|
||||
private String[] lines;
|
||||
|
||||
public CPacketUpdateSign()
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketUpdateSign(BlockPos posIn, ITextComponent[] linesIn)
|
||||
{
|
||||
this.pos = posIn;
|
||||
this.lines = new String[] {linesIn[0].getUnformattedText(), linesIn[1].getUnformattedText(), linesIn[2].getUnformattedText(), linesIn[3].getUnformattedText()};
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.pos = buf.readBlockPos();
|
||||
this.lines = new String[4];
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
this.lines[i] = buf.readString(384);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeBlockPos(this.pos);
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
buf.writeString(this.lines[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processUpdateSign(this);
|
||||
}
|
||||
|
||||
public BlockPos getPosition()
|
||||
{
|
||||
return this.pos;
|
||||
}
|
||||
|
||||
public String[] getLines()
|
||||
{
|
||||
return this.lines;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CPacketUseEntity implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private int entityId;
|
||||
private CPacketUseEntity.Action action;
|
||||
private Vec3d hitVec;
|
||||
private EnumHand hand;
|
||||
|
||||
public CPacketUseEntity()
|
||||
{
|
||||
}
|
||||
|
||||
public CPacketUseEntity(Entity entityIn)
|
||||
{
|
||||
this.entityId = entityIn.getEntityId();
|
||||
this.action = CPacketUseEntity.Action.ATTACK;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketUseEntity(Entity entityIn, EnumHand handIn)
|
||||
{
|
||||
this.entityId = entityIn.getEntityId();
|
||||
this.action = CPacketUseEntity.Action.INTERACT;
|
||||
this.hand = handIn;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CPacketUseEntity(Entity entityIn, EnumHand handIn, Vec3d hitVecIn)
|
||||
{
|
||||
this.entityId = entityIn.getEntityId();
|
||||
this.action = CPacketUseEntity.Action.INTERACT_AT;
|
||||
this.hand = handIn;
|
||||
this.hitVec = hitVecIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityId = buf.readVarInt();
|
||||
this.action = (CPacketUseEntity.Action)buf.readEnumValue(CPacketUseEntity.Action.class);
|
||||
|
||||
if (this.action == CPacketUseEntity.Action.INTERACT_AT)
|
||||
{
|
||||
this.hitVec = new Vec3d((double)buf.readFloat(), (double)buf.readFloat(), (double)buf.readFloat());
|
||||
}
|
||||
|
||||
if (this.action == CPacketUseEntity.Action.INTERACT || this.action == CPacketUseEntity.Action.INTERACT_AT)
|
||||
{
|
||||
this.hand = (EnumHand)buf.readEnumValue(EnumHand.class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarInt(this.entityId);
|
||||
buf.writeEnumValue(this.action);
|
||||
|
||||
if (this.action == CPacketUseEntity.Action.INTERACT_AT)
|
||||
{
|
||||
buf.writeFloat((float)this.hitVec.x);
|
||||
buf.writeFloat((float)this.hitVec.y);
|
||||
buf.writeFloat((float)this.hitVec.z);
|
||||
}
|
||||
|
||||
if (this.action == CPacketUseEntity.Action.INTERACT || this.action == CPacketUseEntity.Action.INTERACT_AT)
|
||||
{
|
||||
buf.writeEnumValue(this.hand);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processUseEntity(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Entity getEntityFromWorld(World worldIn)
|
||||
{
|
||||
return worldIn.getEntityByID(this.entityId);
|
||||
}
|
||||
|
||||
public CPacketUseEntity.Action getAction()
|
||||
{
|
||||
return this.action;
|
||||
}
|
||||
|
||||
public EnumHand getHand()
|
||||
{
|
||||
return this.hand;
|
||||
}
|
||||
|
||||
public Vec3d getHitVec()
|
||||
{
|
||||
return this.hitVec;
|
||||
}
|
||||
|
||||
public static enum Action
|
||||
{
|
||||
INTERACT,
|
||||
ATTACK,
|
||||
INTERACT_AT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
|
||||
public class CPacketVehicleMove implements Packet<INetHandlerPlayServer>
|
||||
{
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
private float yaw;
|
||||
private float pitch;
|
||||
|
||||
public CPacketVehicleMove()
|
||||
{
|
||||
}
|
||||
|
||||
public CPacketVehicleMove(Entity entityIn)
|
||||
{
|
||||
this.x = entityIn.posX;
|
||||
this.y = entityIn.posY;
|
||||
this.z = entityIn.posZ;
|
||||
this.yaw = entityIn.rotationYaw;
|
||||
this.pitch = entityIn.rotationPitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processVehicleMove(this);
|
||||
}
|
||||
|
||||
public double getX()
|
||||
{
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public double getY()
|
||||
{
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public double getZ()
|
||||
{
|
||||
return this.z;
|
||||
}
|
||||
|
||||
public float getYaw()
|
||||
{
|
||||
return this.yaw;
|
||||
}
|
||||
|
||||
public float getPitch()
|
||||
{
|
||||
return this.pitch;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// Auto generated package-info by MCP
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package net.minecraft.network.play.client;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,7 @@
|
||||
// Auto generated package-info by MCP
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package net.minecraft.network.play;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,142 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementProgress;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketAdvancementInfo implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
private boolean firstSync;
|
||||
private Map<ResourceLocation, Advancement.Builder> advancementsToAdd;
|
||||
private Set<ResourceLocation> advancementsToRemove;
|
||||
private Map<ResourceLocation, AdvancementProgress> progressUpdates;
|
||||
|
||||
public SPacketAdvancementInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketAdvancementInfo(boolean p_i47519_1_, Collection<Advancement> p_i47519_2_, Set<ResourceLocation> p_i47519_3_, Map<ResourceLocation, AdvancementProgress> p_i47519_4_)
|
||||
{
|
||||
this.firstSync = p_i47519_1_;
|
||||
this.advancementsToAdd = Maps.<ResourceLocation, Advancement.Builder>newHashMap();
|
||||
|
||||
for (Advancement advancement : p_i47519_2_)
|
||||
{
|
||||
this.advancementsToAdd.put(advancement.getId(), advancement.copy());
|
||||
}
|
||||
|
||||
this.advancementsToRemove = p_i47519_3_;
|
||||
this.progressUpdates = Maps.<ResourceLocation, AdvancementProgress>newHashMap(p_i47519_4_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleAdvancementInfo(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.firstSync = buf.readBoolean();
|
||||
this.advancementsToAdd = Maps.<ResourceLocation, Advancement.Builder>newHashMap();
|
||||
this.advancementsToRemove = Sets.<ResourceLocation>newLinkedHashSet();
|
||||
this.progressUpdates = Maps.<ResourceLocation, AdvancementProgress>newHashMap();
|
||||
int i = buf.readVarInt();
|
||||
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
ResourceLocation resourcelocation = buf.readResourceLocation();
|
||||
Advancement.Builder advancement$builder = Advancement.Builder.readFrom(buf);
|
||||
this.advancementsToAdd.put(resourcelocation, advancement$builder);
|
||||
}
|
||||
|
||||
i = buf.readVarInt();
|
||||
|
||||
for (int k = 0; k < i; ++k)
|
||||
{
|
||||
ResourceLocation resourcelocation1 = buf.readResourceLocation();
|
||||
this.advancementsToRemove.add(resourcelocation1);
|
||||
}
|
||||
|
||||
i = buf.readVarInt();
|
||||
|
||||
for (int l = 0; l < i; ++l)
|
||||
{
|
||||
ResourceLocation resourcelocation2 = buf.readResourceLocation();
|
||||
this.progressUpdates.put(resourcelocation2, AdvancementProgress.fromNetwork(buf));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeBoolean(this.firstSync);
|
||||
buf.writeVarInt(this.advancementsToAdd.size());
|
||||
|
||||
for (Entry<ResourceLocation, Advancement.Builder> entry : this.advancementsToAdd.entrySet())
|
||||
{
|
||||
ResourceLocation resourcelocation = entry.getKey();
|
||||
Advancement.Builder advancement$builder = entry.getValue();
|
||||
buf.writeResourceLocation(resourcelocation);
|
||||
advancement$builder.writeTo(buf);
|
||||
}
|
||||
|
||||
buf.writeVarInt(this.advancementsToRemove.size());
|
||||
|
||||
for (ResourceLocation resourcelocation1 : this.advancementsToRemove)
|
||||
{
|
||||
buf.writeResourceLocation(resourcelocation1);
|
||||
}
|
||||
|
||||
buf.writeVarInt(this.progressUpdates.size());
|
||||
|
||||
for (Entry<ResourceLocation, AdvancementProgress> entry1 : this.progressUpdates.entrySet())
|
||||
{
|
||||
buf.writeResourceLocation(entry1.getKey());
|
||||
((AdvancementProgress)entry1.getValue()).serializeToNetwork(buf);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Map<ResourceLocation, Advancement.Builder> getAdvancementsToAdd()
|
||||
{
|
||||
return this.advancementsToAdd;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Set<ResourceLocation> getAdvancementsToRemove()
|
||||
{
|
||||
return this.advancementsToRemove;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Map<ResourceLocation, AdvancementProgress> getProgressUpdates()
|
||||
{
|
||||
return this.progressUpdates;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean isFirstSync()
|
||||
{
|
||||
return this.firstSync;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketAnimation implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
private int entityId;
|
||||
private int type;
|
||||
|
||||
public SPacketAnimation()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketAnimation(Entity entityIn, int typeIn)
|
||||
{
|
||||
this.entityId = entityIn.getEntityId();
|
||||
this.type = typeIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityId = buf.readVarInt();
|
||||
this.type = buf.readUnsignedByte();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarInt(this.entityId);
|
||||
buf.writeByte(this.type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleAnimation(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getEntityID()
|
||||
{
|
||||
return this.entityId;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getAnimationType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketBlockAction implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
private BlockPos blockPosition;
|
||||
private int instrument;
|
||||
private int pitch;
|
||||
private Block block;
|
||||
|
||||
public SPacketBlockAction()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketBlockAction(BlockPos pos, Block blockIn, int instrumentIn, int pitchIn)
|
||||
{
|
||||
this.blockPosition = pos;
|
||||
this.instrument = instrumentIn;
|
||||
this.pitch = pitchIn;
|
||||
this.block = blockIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.blockPosition = buf.readBlockPos();
|
||||
this.instrument = buf.readUnsignedByte();
|
||||
this.pitch = buf.readUnsignedByte();
|
||||
this.block = Block.getBlockById(buf.readVarInt() & 4095);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeBlockPos(this.blockPosition);
|
||||
buf.writeByte(this.instrument);
|
||||
buf.writeByte(this.pitch);
|
||||
buf.writeVarInt(Block.getIdFromBlock(this.block) & 4095);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleBlockAction(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BlockPos getBlockPosition()
|
||||
{
|
||||
return this.blockPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* instrument data for noteblocks
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getData1()
|
||||
{
|
||||
return this.instrument;
|
||||
}
|
||||
|
||||
/**
|
||||
* pitch data for noteblocks
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getData2()
|
||||
{
|
||||
return this.pitch;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Block getBlockType()
|
||||
{
|
||||
return this.block;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketBlockBreakAnim implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
private int breakerId;
|
||||
private BlockPos position;
|
||||
private int progress;
|
||||
|
||||
public SPacketBlockBreakAnim()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketBlockBreakAnim(int breakerIdIn, BlockPos positionIn, int progressIn)
|
||||
{
|
||||
this.breakerId = breakerIdIn;
|
||||
this.position = positionIn;
|
||||
this.progress = progressIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.breakerId = buf.readVarInt();
|
||||
this.position = buf.readBlockPos();
|
||||
this.progress = buf.readUnsignedByte();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarInt(this.breakerId);
|
||||
buf.writeBlockPos(this.position);
|
||||
buf.writeByte(this.progress);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleBlockBreakAnim(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getBreakerId()
|
||||
{
|
||||
return this.breakerId;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BlockPos getPosition()
|
||||
{
|
||||
return this.position;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getProgress()
|
||||
{
|
||||
return this.progress;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketBlockChange implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
private BlockPos blockPosition;
|
||||
public IBlockState blockState;
|
||||
|
||||
public SPacketBlockChange()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketBlockChange(World worldIn, BlockPos posIn)
|
||||
{
|
||||
this.blockPosition = posIn;
|
||||
this.blockState = worldIn.getBlockState(posIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.blockPosition = buf.readBlockPos();
|
||||
this.blockState = Block.BLOCK_STATE_IDS.getByValue(buf.readVarInt());
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeBlockPos(this.blockPosition);
|
||||
buf.writeVarInt(Block.BLOCK_STATE_IDS.get(this.blockState));
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleBlockChange(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IBlockState getBlockState()
|
||||
{
|
||||
return this.blockState;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BlockPos getBlockPosition()
|
||||
{
|
||||
return this.blockPosition;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketCamera implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
public int entityId;
|
||||
|
||||
public SPacketCamera()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketCamera(Entity entityIn)
|
||||
{
|
||||
this.entityId = entityIn.getEntityId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleCamera(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Entity getEntity(World worldIn)
|
||||
{
|
||||
return worldIn.getEntityByID(this.entityId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketChangeGameState implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
public static final String[] MESSAGE_NAMES = new String[] {"tile.bed.notValid"};
|
||||
private int state;
|
||||
private float value;
|
||||
|
||||
public SPacketChangeGameState()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketChangeGameState(int stateIn, float valueIn)
|
||||
{
|
||||
this.state = stateIn;
|
||||
this.value = valueIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.state = buf.readUnsignedByte();
|
||||
this.value = buf.readFloat();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeByte(this.state);
|
||||
buf.writeFloat(this.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleChangeGameState(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getGameState()
|
||||
{
|
||||
return this.state;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getValue()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraft.util.text.ChatType;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketChat implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
private ITextComponent chatComponent;
|
||||
private ChatType type;
|
||||
|
||||
public SPacketChat()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketChat(ITextComponent componentIn)
|
||||
{
|
||||
this(componentIn, ChatType.SYSTEM);
|
||||
}
|
||||
|
||||
public SPacketChat(ITextComponent message, ChatType type)
|
||||
{
|
||||
this.chatComponent = message;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.chatComponent = buf.readTextComponent();
|
||||
this.type = ChatType.byId(buf.readByte());
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeTextComponent(this.chatComponent);
|
||||
buf.writeByte(this.type.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleChat(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ITextComponent getChatComponent()
|
||||
{
|
||||
return this.chatComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns true if the type is SYSTEM or ABOVE_HOTBAR, and false if CHAT
|
||||
*/
|
||||
public boolean isSystem()
|
||||
{
|
||||
return this.type == ChatType.SYSTEM || this.type == ChatType.GAME_INFO;
|
||||
}
|
||||
|
||||
public ChatType getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketChunkData implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
private int chunkX;
|
||||
private int chunkZ;
|
||||
private int availableSections;
|
||||
private byte[] buffer;
|
||||
private List<NBTTagCompound> tileEntityTags;
|
||||
private boolean fullChunk;
|
||||
|
||||
public SPacketChunkData()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketChunkData(Chunk chunkIn, int changedSectionFilter)
|
||||
{
|
||||
this.chunkX = chunkIn.x;
|
||||
this.chunkZ = chunkIn.z;
|
||||
this.fullChunk = changedSectionFilter == 65535;
|
||||
boolean flag = chunkIn.getWorld().provider.hasSkyLight();
|
||||
this.buffer = new byte[this.calculateChunkSize(chunkIn, flag, changedSectionFilter)];
|
||||
this.availableSections = this.extractChunkData(new PacketBuffer(this.getWriteBuffer()), chunkIn, flag, changedSectionFilter);
|
||||
this.tileEntityTags = Lists.<NBTTagCompound>newArrayList();
|
||||
|
||||
for (Entry<BlockPos, TileEntity> entry : chunkIn.getTileEntityMap().entrySet())
|
||||
{
|
||||
BlockPos blockpos = entry.getKey();
|
||||
TileEntity tileentity = entry.getValue();
|
||||
int i = blockpos.getY() >> 4;
|
||||
|
||||
if (this.isFullChunk() || (changedSectionFilter & 1 << i) != 0)
|
||||
{
|
||||
NBTTagCompound nbttagcompound = tileentity.getUpdateTag();
|
||||
this.tileEntityTags.add(nbttagcompound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.chunkX = buf.readInt();
|
||||
this.chunkZ = buf.readInt();
|
||||
this.fullChunk = buf.readBoolean();
|
||||
this.availableSections = buf.readVarInt();
|
||||
int i = buf.readVarInt();
|
||||
|
||||
if (i > 2097152)
|
||||
{
|
||||
throw new RuntimeException("Chunk Packet trying to allocate too much memory on read.");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.buffer = new byte[i];
|
||||
buf.readBytes(this.buffer);
|
||||
int j = buf.readVarInt();
|
||||
this.tileEntityTags = Lists.<NBTTagCompound>newArrayList();
|
||||
|
||||
for (int k = 0; k < j; ++k)
|
||||
{
|
||||
this.tileEntityTags.add(buf.readCompoundTag());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeInt(this.chunkX);
|
||||
buf.writeInt(this.chunkZ);
|
||||
buf.writeBoolean(this.fullChunk);
|
||||
buf.writeVarInt(this.availableSections);
|
||||
buf.writeVarInt(this.buffer.length);
|
||||
buf.writeBytes(this.buffer);
|
||||
buf.writeVarInt(this.tileEntityTags.size());
|
||||
|
||||
for (NBTTagCompound nbttagcompound : this.tileEntityTags)
|
||||
{
|
||||
buf.writeCompoundTag(nbttagcompound);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleChunkData(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public PacketBuffer getReadBuffer()
|
||||
{
|
||||
return new PacketBuffer(Unpooled.wrappedBuffer(this.buffer));
|
||||
}
|
||||
|
||||
private ByteBuf getWriteBuffer()
|
||||
{
|
||||
ByteBuf bytebuf = Unpooled.wrappedBuffer(this.buffer);
|
||||
bytebuf.writerIndex(0);
|
||||
return bytebuf;
|
||||
}
|
||||
|
||||
public int extractChunkData(PacketBuffer buf, Chunk chunkIn, boolean writeSkylight, int changedSectionFilter)
|
||||
{
|
||||
int i = 0;
|
||||
ExtendedBlockStorage[] aextendedblockstorage = chunkIn.getBlockStorageArray();
|
||||
int j = 0;
|
||||
|
||||
for (int k = aextendedblockstorage.length; j < k; ++j)
|
||||
{
|
||||
ExtendedBlockStorage extendedblockstorage = aextendedblockstorage[j];
|
||||
|
||||
if (extendedblockstorage != Chunk.NULL_BLOCK_STORAGE && (!this.isFullChunk() || !extendedblockstorage.isEmpty()) && (changedSectionFilter & 1 << j) != 0)
|
||||
{
|
||||
i |= 1 << j;
|
||||
extendedblockstorage.getData().write(buf);
|
||||
buf.writeBytes(extendedblockstorage.getBlockLight().getData());
|
||||
|
||||
if (writeSkylight)
|
||||
{
|
||||
buf.writeBytes(extendedblockstorage.getSkyLight().getData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isFullChunk())
|
||||
{
|
||||
buf.writeBytes(chunkIn.getBiomeArray());
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
protected int calculateChunkSize(Chunk chunkIn, boolean p_189556_2_, int p_189556_3_)
|
||||
{
|
||||
int i = 0;
|
||||
ExtendedBlockStorage[] aextendedblockstorage = chunkIn.getBlockStorageArray();
|
||||
int j = 0;
|
||||
|
||||
for (int k = aextendedblockstorage.length; j < k; ++j)
|
||||
{
|
||||
ExtendedBlockStorage extendedblockstorage = aextendedblockstorage[j];
|
||||
|
||||
if (extendedblockstorage != Chunk.NULL_BLOCK_STORAGE && (!this.isFullChunk() || !extendedblockstorage.isEmpty()) && (p_189556_3_ & 1 << j) != 0)
|
||||
{
|
||||
i = i + extendedblockstorage.getData().getSerializedSize();
|
||||
i = i + extendedblockstorage.getBlockLight().getData().length;
|
||||
|
||||
if (p_189556_2_)
|
||||
{
|
||||
i += extendedblockstorage.getSkyLight().getData().length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isFullChunk())
|
||||
{
|
||||
i += chunkIn.getBiomeArray().length;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getChunkX()
|
||||
{
|
||||
return this.chunkX;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getChunkZ()
|
||||
{
|
||||
return this.chunkZ;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getExtractedSize()
|
||||
{
|
||||
return this.availableSections;
|
||||
}
|
||||
|
||||
public boolean isFullChunk()
|
||||
{
|
||||
return this.fullChunk;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public List<NBTTagCompound> getTileEntityTags()
|
||||
{
|
||||
return this.tileEntityTags;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
|
||||
public class SPacketCloseWindow implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
private int windowId;
|
||||
|
||||
public SPacketCloseWindow()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketCloseWindow(int windowIdIn)
|
||||
{
|
||||
this.windowId = windowIdIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleCloseWindow(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.windowId = buf.readUnsignedByte();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeByte(this.windowId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketCollectItem implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
private int collectedItemEntityId;
|
||||
private int entityId;
|
||||
private int collectedQuantity;
|
||||
|
||||
public SPacketCollectItem()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketCollectItem(int p_i47316_1_, int p_i47316_2_, int p_i47316_3_)
|
||||
{
|
||||
this.collectedItemEntityId = p_i47316_1_;
|
||||
this.entityId = p_i47316_2_;
|
||||
this.collectedQuantity = p_i47316_3_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.collectedItemEntityId = buf.readVarInt();
|
||||
this.entityId = buf.readVarInt();
|
||||
this.collectedQuantity = buf.readVarInt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarInt(this.collectedItemEntityId);
|
||||
buf.writeVarInt(this.entityId);
|
||||
buf.writeVarInt(this.collectedQuantity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleCollectItem(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getCollectedItemEntityID()
|
||||
{
|
||||
return this.collectedItemEntityId;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getEntityID()
|
||||
{
|
||||
return this.entityId;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getAmount()
|
||||
{
|
||||
return this.collectedQuantity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraft.util.CombatTracker;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
|
||||
public class SPacketCombatEvent implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
public SPacketCombatEvent.Event eventType;
|
||||
public int playerId;
|
||||
public int entityId;
|
||||
public int duration;
|
||||
public ITextComponent deathMessage;
|
||||
|
||||
public SPacketCombatEvent()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketCombatEvent(CombatTracker tracker, SPacketCombatEvent.Event eventIn)
|
||||
{
|
||||
this(tracker, eventIn, true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
public SPacketCombatEvent(CombatTracker tracker, SPacketCombatEvent.Event eventIn, boolean showDeathMessage)
|
||||
{
|
||||
this.eventType = eventIn;
|
||||
EntityLivingBase entitylivingbase = tracker.getBestAttacker();
|
||||
|
||||
switch (eventIn)
|
||||
{
|
||||
case END_COMBAT:
|
||||
this.duration = tracker.getCombatDuration();
|
||||
this.entityId = entitylivingbase == null ? -1 : entitylivingbase.getEntityId();
|
||||
break;
|
||||
case ENTITY_DIED:
|
||||
this.playerId = tracker.getFighter().getEntityId();
|
||||
this.entityId = entitylivingbase == null ? -1 : entitylivingbase.getEntityId();
|
||||
|
||||
if (showDeathMessage)
|
||||
{
|
||||
this.deathMessage = tracker.getDeathMessage();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.deathMessage = new TextComponentString("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.eventType = (SPacketCombatEvent.Event)buf.readEnumValue(SPacketCombatEvent.Event.class);
|
||||
|
||||
if (this.eventType == SPacketCombatEvent.Event.END_COMBAT)
|
||||
{
|
||||
this.duration = buf.readVarInt();
|
||||
this.entityId = buf.readInt();
|
||||
}
|
||||
else if (this.eventType == SPacketCombatEvent.Event.ENTITY_DIED)
|
||||
{
|
||||
this.playerId = buf.readVarInt();
|
||||
this.entityId = buf.readInt();
|
||||
this.deathMessage = buf.readTextComponent();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeEnumValue(this.eventType);
|
||||
|
||||
if (this.eventType == SPacketCombatEvent.Event.END_COMBAT)
|
||||
{
|
||||
buf.writeVarInt(this.duration);
|
||||
buf.writeInt(this.entityId);
|
||||
}
|
||||
else if (this.eventType == SPacketCombatEvent.Event.ENTITY_DIED)
|
||||
{
|
||||
buf.writeVarInt(this.playerId);
|
||||
buf.writeInt(this.entityId);
|
||||
buf.writeTextComponent(this.deathMessage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleCombatEvent(this);
|
||||
}
|
||||
|
||||
public static enum Event
|
||||
{
|
||||
ENTER_COMBAT,
|
||||
END_COMBAT,
|
||||
ENTITY_DIED;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketConfirmTransaction implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
private int windowId;
|
||||
private short actionNumber;
|
||||
private boolean accepted;
|
||||
|
||||
public SPacketConfirmTransaction()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketConfirmTransaction(int windowIdIn, short actionNumberIn, boolean acceptedIn)
|
||||
{
|
||||
this.windowId = windowIdIn;
|
||||
this.actionNumber = actionNumberIn;
|
||||
this.accepted = acceptedIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleConfirmTransaction(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.windowId = buf.readUnsignedByte();
|
||||
this.actionNumber = buf.readShort();
|
||||
this.accepted = buf.readBoolean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeByte(this.windowId);
|
||||
buf.writeShort(this.actionNumber);
|
||||
buf.writeBoolean(this.accepted);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getWindowId()
|
||||
{
|
||||
return this.windowId;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public short getActionNumber()
|
||||
{
|
||||
return this.actionNumber;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean wasAccepted()
|
||||
{
|
||||
return this.accepted;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketCooldown implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
private Item item;
|
||||
private int ticks;
|
||||
|
||||
public SPacketCooldown()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketCooldown(Item itemIn, int ticksIn)
|
||||
{
|
||||
this.item = itemIn;
|
||||
this.ticks = ticksIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.item = Item.getItemById(buf.readVarInt());
|
||||
this.ticks = buf.readVarInt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarInt(Item.getIdFromItem(this.item));
|
||||
buf.writeVarInt(this.ticks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleCooldown(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Item getItem()
|
||||
{
|
||||
return this.item;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getTicks()
|
||||
{
|
||||
return this.ticks;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketCustomPayload implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
private String channel;
|
||||
private PacketBuffer data;
|
||||
|
||||
public SPacketCustomPayload()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketCustomPayload(String channelIn, PacketBuffer bufIn)
|
||||
{
|
||||
this.channel = channelIn;
|
||||
this.data = bufIn;
|
||||
|
||||
if (bufIn.writerIndex() > 1048576)
|
||||
{
|
||||
throw new IllegalArgumentException("Payload may not be larger than 1048576 bytes");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.channel = buf.readString(20);
|
||||
int i = buf.readableBytes();
|
||||
|
||||
if (i >= 0 && i <= 1048576)
|
||||
{
|
||||
this.data = new PacketBuffer(buf.readBytes(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IOException("Payload may not be larger than 1048576 bytes");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeString(this.channel);
|
||||
synchronized(this.data) { //This may be access multiple times, from multiple threads, lets be safe.
|
||||
this.data.markReaderIndex();
|
||||
buf.writeBytes((ByteBuf)this.data);
|
||||
this.data.resetReaderIndex();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleCustomPayload(this);
|
||||
// Forge: fix network buffer leaks (MC-121884)
|
||||
if (this.data != null) this.data.release();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getChannelName()
|
||||
{
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public PacketBuffer getBufferData()
|
||||
{
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
public class SPacketCustomSound implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
private String soundName;
|
||||
private SoundCategory category;
|
||||
private int x;
|
||||
private int y = Integer.MAX_VALUE;
|
||||
private int z;
|
||||
private float volume;
|
||||
private float pitch;
|
||||
|
||||
public SPacketCustomSound()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketCustomSound(String soundNameIn, SoundCategory categoryIn, double xIn, double yIn, double zIn, float volumeIn, float pitchIn)
|
||||
{
|
||||
Validate.notNull(soundNameIn, "name");
|
||||
this.soundName = soundNameIn;
|
||||
this.category = categoryIn;
|
||||
this.x = (int)(xIn * 8.0D);
|
||||
this.y = (int)(yIn * 8.0D);
|
||||
this.z = (int)(zIn * 8.0D);
|
||||
this.volume = volumeIn;
|
||||
this.pitch = pitchIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.soundName = buf.readString(256);
|
||||
this.category = (SoundCategory)buf.readEnumValue(SoundCategory.class);
|
||||
this.x = buf.readInt();
|
||||
this.y = buf.readInt();
|
||||
this.z = buf.readInt();
|
||||
this.volume = buf.readFloat();
|
||||
this.pitch = buf.readFloat();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeString(this.soundName);
|
||||
buf.writeEnumValue(this.category);
|
||||
buf.writeInt(this.x);
|
||||
buf.writeInt(this.y);
|
||||
buf.writeInt(this.z);
|
||||
buf.writeFloat(this.volume);
|
||||
buf.writeFloat(this.pitch);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getSoundName()
|
||||
{
|
||||
return this.soundName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleCustomSound(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public SoundCategory getCategory()
|
||||
{
|
||||
return this.category;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public double getX()
|
||||
{
|
||||
return (double)((float)this.x / 8.0F);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public double getY()
|
||||
{
|
||||
return (double)((float)this.y / 8.0F);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public double getZ()
|
||||
{
|
||||
return (double)((float)this.z / 8.0F);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getVolume()
|
||||
{
|
||||
return this.volume;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getPitch()
|
||||
{
|
||||
return this.pitch;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketDestroyEntities implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
private int[] entityIDs;
|
||||
|
||||
public SPacketDestroyEntities()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketDestroyEntities(int... entityIdsIn)
|
||||
{
|
||||
this.entityIDs = entityIdsIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityIDs = new int[buf.readVarInt()];
|
||||
|
||||
for (int i = 0; i < this.entityIDs.length; ++i)
|
||||
{
|
||||
this.entityIDs[i] = buf.readVarInt();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarInt(this.entityIDs.length);
|
||||
|
||||
for (int i : this.entityIDs)
|
||||
{
|
||||
buf.writeVarInt(i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleDestroyEntities(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int[] getEntityIDs()
|
||||
{
|
||||
return this.entityIDs;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketDisconnect implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
private ITextComponent reason;
|
||||
|
||||
public SPacketDisconnect()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketDisconnect(ITextComponent messageIn)
|
||||
{
|
||||
this.reason = messageIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.reason = buf.readTextComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeTextComponent(this.reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleDisconnect(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ITextComponent getReason()
|
||||
{
|
||||
return this.reason;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraft.scoreboard.ScoreObjective;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketDisplayObjective implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
private int position;
|
||||
private String scoreName;
|
||||
|
||||
public SPacketDisplayObjective()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketDisplayObjective(int positionIn, ScoreObjective objective)
|
||||
{
|
||||
this.position = positionIn;
|
||||
|
||||
if (objective == null)
|
||||
{
|
||||
this.scoreName = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
this.scoreName = objective.getName();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.position = buf.readByte();
|
||||
this.scoreName = buf.readString(16);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeByte(this.position);
|
||||
buf.writeString(this.scoreName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleDisplayObjective(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getPosition()
|
||||
{
|
||||
return this.position;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getName()
|
||||
{
|
||||
return this.scoreName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketEffect implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
private int soundType;
|
||||
private BlockPos soundPos;
|
||||
/** can be a block/item id or other depending on the soundtype */
|
||||
private int soundData;
|
||||
/** If true the sound is played across the server */
|
||||
private boolean serverWide;
|
||||
|
||||
public SPacketEffect()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketEffect(int soundTypeIn, BlockPos soundPosIn, int soundDataIn, boolean serverWideIn)
|
||||
{
|
||||
this.soundType = soundTypeIn;
|
||||
this.soundPos = soundPosIn;
|
||||
this.soundData = soundDataIn;
|
||||
this.serverWide = serverWideIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.soundType = buf.readInt();
|
||||
this.soundPos = buf.readBlockPos();
|
||||
this.soundData = buf.readInt();
|
||||
this.serverWide = buf.readBoolean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeInt(this.soundType);
|
||||
buf.writeBlockPos(this.soundPos);
|
||||
buf.writeInt(this.soundData);
|
||||
buf.writeBoolean(this.serverWide);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleEffect(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean isSoundServerwide()
|
||||
{
|
||||
return this.serverWide;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getSoundType()
|
||||
{
|
||||
return this.soundType;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getSoundData()
|
||||
{
|
||||
return this.soundData;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BlockPos getSoundPos()
|
||||
{
|
||||
return this.soundPos;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketEntity implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
protected int entityId;
|
||||
protected int posX;
|
||||
protected int posY;
|
||||
protected int posZ;
|
||||
protected byte yaw;
|
||||
protected byte pitch;
|
||||
protected boolean onGround;
|
||||
protected boolean rotating;
|
||||
|
||||
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(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleEntityMovement(this);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "Entity_" + super.toString();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Entity getEntity(World worldIn)
|
||||
{
|
||||
return worldIn.getEntityByID(this.entityId);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getX()
|
||||
{
|
||||
return this.posX;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getY()
|
||||
{
|
||||
return this.posY;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getZ()
|
||||
{
|
||||
return this.posZ;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public byte getYaw()
|
||||
{
|
||||
return this.yaw;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public byte getPitch()
|
||||
{
|
||||
return this.pitch;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean isRotating()
|
||||
{
|
||||
return this.rotating;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean getOnGround()
|
||||
{
|
||||
return this.onGround;
|
||||
}
|
||||
|
||||
public static class S15PacketEntityRelMove extends SPacketEntity
|
||||
{
|
||||
public S15PacketEntityRelMove()
|
||||
{
|
||||
}
|
||||
|
||||
public S15PacketEntityRelMove(int entityIdIn, long xIn, long yIn, long zIn, boolean onGroundIn)
|
||||
{
|
||||
super(entityIdIn);
|
||||
this.posX = (int)xIn;
|
||||
this.posY = (int)yIn;
|
||||
this.posZ = (int)zIn;
|
||||
this.onGround = onGroundIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
super.readPacketData(buf);
|
||||
this.posX = buf.readShort();
|
||||
this.posY = buf.readShort();
|
||||
this.posZ = buf.readShort();
|
||||
this.onGround = buf.readBoolean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
super.writePacketData(buf);
|
||||
buf.writeShort(this.posX);
|
||||
buf.writeShort(this.posY);
|
||||
buf.writeShort(this.posZ);
|
||||
buf.writeBoolean(this.onGround);
|
||||
}
|
||||
}
|
||||
|
||||
public static class S16PacketEntityLook extends SPacketEntity
|
||||
{
|
||||
public S16PacketEntityLook()
|
||||
{
|
||||
this.rotating = true;
|
||||
}
|
||||
|
||||
public S16PacketEntityLook(int entityIdIn, byte yawIn, byte pitchIn, boolean onGroundIn)
|
||||
{
|
||||
super(entityIdIn);
|
||||
this.yaw = yawIn;
|
||||
this.pitch = pitchIn;
|
||||
this.rotating = true;
|
||||
this.onGround = onGroundIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
super.readPacketData(buf);
|
||||
this.yaw = buf.readByte();
|
||||
this.pitch = buf.readByte();
|
||||
this.onGround = buf.readBoolean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
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 SPacketEntity
|
||||
{
|
||||
public S17PacketEntityLookMove()
|
||||
{
|
||||
this.rotating = true;
|
||||
}
|
||||
|
||||
public S17PacketEntityLookMove(int entityIdIn, long xIn, long yIn, long zIn, byte yawIn, byte pitchIn, boolean onGroundIn)
|
||||
{
|
||||
super(entityIdIn);
|
||||
this.posX = (int)xIn;
|
||||
this.posY = (int)yIn;
|
||||
this.posZ = (int)zIn;
|
||||
this.yaw = yawIn;
|
||||
this.pitch = pitchIn;
|
||||
this.onGround = onGroundIn;
|
||||
this.rotating = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
super.readPacketData(buf);
|
||||
this.posX = buf.readShort();
|
||||
this.posY = buf.readShort();
|
||||
this.posZ = buf.readShort();
|
||||
this.yaw = buf.readByte();
|
||||
this.pitch = buf.readByte();
|
||||
this.onGround = buf.readBoolean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
super.writePacketData(buf);
|
||||
buf.writeShort(this.posX);
|
||||
buf.writeShort(this.posY);
|
||||
buf.writeShort(this.posZ);
|
||||
buf.writeByte(this.yaw);
|
||||
buf.writeByte(this.pitch);
|
||||
buf.writeBoolean(this.onGround);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketEntityAttach implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
private int entityId;
|
||||
private int vehicleEntityId;
|
||||
|
||||
public SPacketEntityAttach()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketEntityAttach(Entity entityIn, @Nullable Entity vehicleIn)
|
||||
{
|
||||
this.entityId = entityIn.getEntityId();
|
||||
this.vehicleEntityId = vehicleIn != null ? vehicleIn.getEntityId() : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityId = buf.readInt();
|
||||
this.vehicleEntityId = buf.readInt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeInt(this.entityId);
|
||||
buf.writeInt(this.vehicleEntityId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleEntityAttach(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getEntityId()
|
||||
{
|
||||
return this.entityId;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getVehicleEntityId()
|
||||
{
|
||||
return this.vehicleEntityId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketEntityEffect implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
private int entityId;
|
||||
private byte effectId;
|
||||
private byte amplifier;
|
||||
private int duration;
|
||||
private byte flags;
|
||||
|
||||
public SPacketEntityEffect()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketEntityEffect(int entityIdIn, PotionEffect effect)
|
||||
{
|
||||
this.entityId = entityIdIn;
|
||||
this.effectId = (byte)(Potion.getIdFromPotion(effect.getPotion()) & 255);
|
||||
this.amplifier = (byte)(effect.getAmplifier() & 255);
|
||||
|
||||
if (effect.getDuration() > 32767)
|
||||
{
|
||||
this.duration = 32767;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.duration = effect.getDuration();
|
||||
}
|
||||
|
||||
this.flags = 0;
|
||||
|
||||
if (effect.getIsAmbient())
|
||||
{
|
||||
this.flags = (byte)(this.flags | 1);
|
||||
}
|
||||
|
||||
if (effect.doesShowParticles())
|
||||
{
|
||||
this.flags = (byte)(this.flags | 2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityId = buf.readVarInt();
|
||||
this.effectId = buf.readByte();
|
||||
this.amplifier = buf.readByte();
|
||||
this.duration = buf.readVarInt();
|
||||
this.flags = buf.readByte();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarInt(this.entityId);
|
||||
buf.writeByte(this.effectId);
|
||||
buf.writeByte(this.amplifier);
|
||||
buf.writeVarInt(this.duration);
|
||||
buf.writeByte(this.flags);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean isMaxDuration()
|
||||
{
|
||||
return this.duration == 32767;
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleEntityEffect(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getEntityId()
|
||||
{
|
||||
return this.entityId;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public byte getEffectId()
|
||||
{
|
||||
return this.effectId;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public byte getAmplifier()
|
||||
{
|
||||
return this.amplifier;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getDuration()
|
||||
{
|
||||
return this.duration;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean doesShowParticles()
|
||||
{
|
||||
return (this.flags & 2) == 2;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean getIsAmbient()
|
||||
{
|
||||
return (this.flags & 1) == 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package net.minecraft.network.play.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SPacketEntityEquipment implements Packet<INetHandlerPlayClient>
|
||||
{
|
||||
private int entityID;
|
||||
private EntityEquipmentSlot equipmentSlot;
|
||||
private ItemStack itemStack = ItemStack.EMPTY;
|
||||
|
||||
public SPacketEntityEquipment()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketEntityEquipment(int entityIdIn, EntityEquipmentSlot equipmentSlotIn, ItemStack itemStackIn)
|
||||
{
|
||||
this.entityID = entityIdIn;
|
||||
this.equipmentSlot = equipmentSlotIn;
|
||||
this.itemStack = itemStackIn.copy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityID = buf.readVarInt();
|
||||
this.equipmentSlot = (EntityEquipmentSlot)buf.readEnumValue(EntityEquipmentSlot.class);
|
||||
this.itemStack = buf.readItemStack();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarInt(this.entityID);
|
||||
buf.writeEnumValue(this.equipmentSlot);
|
||||
buf.writeItemStack(this.itemStack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(INetHandlerPlayClient handler)
|
||||
{
|
||||
handler.handleEntityEquipment(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return this.itemStack;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getEntityID()
|
||||
{
|
||||
return this.entityID;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public EntityEquipmentSlot getEquipmentSlot()
|
||||
{
|
||||
return this.equipmentSlot;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user