本文整理汇总了Java中net.minecraft.network.PacketThreadUtil类的典型用法代码示例。如果您正苦于以下问题:Java PacketThreadUtil类的具体用法?Java PacketThreadUtil怎么用?Java PacketThreadUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PacketThreadUtil类属于net.minecraft.network包,在下文中一共展示了PacketThreadUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleConfirmTransaction
import net.minecraft.network.PacketThreadUtil; //导入依赖的package包/类
/**
* Verifies that the server and client are synchronized with respect to the inventory/container opened by the player
* and confirms if it is the case.
*/
public void handleConfirmTransaction(SPacketConfirmTransaction packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Container container = null;
EntityPlayer entityplayer = this.gameController.player;
if (packetIn.getWindowId() == 0)
{
container = entityplayer.inventoryContainer;
}
else if (packetIn.getWindowId() == entityplayer.openContainer.windowId)
{
container = entityplayer.openContainer;
}
if (container != null && !packetIn.wasAccepted())
{
this.sendPacket(new CPacketConfirmTransaction(packetIn.getWindowId(), packetIn.getActionNumber(), true));
}
}
示例2: handleEntityMovement
import net.minecraft.network.PacketThreadUtil; //导入依赖的package包/类
/**
* 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).
*/
public void handleEntityMovement(S14PacketEntity packetIn) {
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Entity entity = packetIn.getEntity(this.clientWorldController);
if (entity != null) {
entity.serverPosX += packetIn.func_149062_c();
entity.serverPosY += packetIn.func_149061_d();
entity.serverPosZ += packetIn.func_149064_e();
double d0 = (double) entity.serverPosX / 32.0D;
double d1 = (double) entity.serverPosY / 32.0D;
double d2 = (double) entity.serverPosZ / 32.0D;
float f = packetIn.func_149060_h() ? (float) (packetIn.func_149066_f() * 360) / 256.0F : entity.rotationYaw;
float f1 = packetIn.func_149060_h() ? (float) (packetIn.func_149063_g() * 360) / 256.0F
: entity.rotationPitch;
entity.setPositionAndRotation2(d0, d1, d2, f, f1, 3, false);
entity.onGround = packetIn.getOnGround();
}
}
示例3: handleCollectItem
import net.minecraft.network.PacketThreadUtil; //导入依赖的package包/类
public void handleCollectItem(S0DPacketCollectItem packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Entity entity = this.clientWorldController.getEntityByID(packetIn.getCollectedItemEntityID());
EntityLivingBase entitylivingbase = (EntityLivingBase)this.clientWorldController.getEntityByID(packetIn.getEntityID());
if (entitylivingbase == null)
{
entitylivingbase = this.gameController.thePlayer;
}
if (entity != null)
{
if (entity instanceof EntityXPOrb)
{
this.clientWorldController.playSoundAtEntity(entity, "random.orb", 0.2F, ((this.avRandomizer.nextFloat() - this.avRandomizer.nextFloat()) * 0.7F + 1.0F) * 2.0F);
}
else
{
this.clientWorldController.playSoundAtEntity(entity, "random.pop", 0.2F, ((this.avRandomizer.nextFloat() - this.avRandomizer.nextFloat()) * 0.7F + 1.0F) * 2.0F);
}
this.gameController.effectRenderer.addEffect(new EntityPickupFX(this.clientWorldController, entity, entitylivingbase, 0.5F));
this.clientWorldController.removeEntityFromWorld(packetIn.getCollectedItemEntityID());
}
}
示例4: handleDisplayObjective
import net.minecraft.network.PacketThreadUtil; //导入依赖的package包/类
/**
* Removes or sets the ScoreObjective to be displayed at a particular scoreboard position (list, sidebar, below
* name)
*/
public void handleDisplayObjective(SPacketDisplayObjective packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Scoreboard scoreboard = this.clientWorldController.getScoreboard();
if (packetIn.getName().isEmpty())
{
scoreboard.setObjectiveInDisplaySlot(packetIn.getPosition(), (ScoreObjective)null);
}
else
{
ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.getName());
scoreboard.setObjectiveInDisplaySlot(packetIn.getPosition(), scoreobjective);
}
}
示例5: handleRespawn
import net.minecraft.network.PacketThreadUtil; //导入依赖的package包/类
public void handleRespawn(S07PacketRespawn packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
if (packetIn.getDimensionID() != this.gameController.thePlayer.dimension)
{
this.doneLoadingTerrain = false;
Scoreboard scoreboard = this.clientWorldController.getScoreboard();
this.clientWorldController = new WorldClient(this, new WorldSettings(0L, packetIn.getGameType(), false, this.gameController.theWorld.getWorldInfo().isHardcoreModeEnabled(), packetIn.getWorldType()), packetIn.getDimensionID(), packetIn.getDifficulty(), this.gameController.mcProfiler);
this.clientWorldController.setWorldScoreboard(scoreboard);
this.gameController.loadWorld(this.clientWorldController);
this.gameController.thePlayer.dimension = packetIn.getDimensionID();
this.gameController.displayGuiScreen(new GuiDownloadTerrain(this));
}
this.gameController.setDimensionAndSpawnPlayer(packetIn.getDimensionID());
this.gameController.playerController.setGameType(packetIn.getGameType());
}
示例6: handleConfirmTransaction
import net.minecraft.network.PacketThreadUtil; //导入依赖的package包/类
/**
* Verifies that the server and client are synchronized with respect to the inventory/container opened by the player
* and confirms if it is the case.
*/
public void handleConfirmTransaction(S32PacketConfirmTransaction packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Container container = null;
EntityPlayer entityplayer = this.gameController.thePlayer;
if (packetIn.getWindowId() == 0)
{
container = entityplayer.inventoryContainer;
}
else if (packetIn.getWindowId() == entityplayer.openContainer.windowId)
{
container = entityplayer.openContainer;
}
if (container != null && !packetIn.func_148888_e())
{
this.addToSendQueue(new C0FPacketConfirmTransaction(packetIn.getWindowId(), packetIn.getActionNumber(), true));
}
}
示例7: handleUpdateSign
import net.minecraft.network.PacketThreadUtil; //导入依赖的package包/类
/**
* Updates a specified sign with the specified text lines
*/
public void handleUpdateSign(S33PacketUpdateSign packetIn) {
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
boolean flag = false;
if (this.gameController.theWorld.isBlockLoaded(packetIn.getPos())) {
TileEntity tileentity = this.gameController.theWorld.getTileEntity(packetIn.getPos());
if (tileentity instanceof TileEntitySign) {
TileEntitySign tileentitysign = (TileEntitySign) tileentity;
if (tileentitysign.getIsEditable()) {
System.arraycopy(packetIn.getLines(), 0, tileentitysign.signText, 0, 4);
tileentitysign.markDirty();
}
flag = true;
}
}
if (!flag && this.gameController.thePlayer != null) {
this.gameController.thePlayer.addChatMessage(new ChatComponentText("Unable to locate sign at "
+ packetIn.getPos().getX() + ", " + packetIn.getPos().getY() + ", " + packetIn.getPos().getZ()));
}
}
示例8: handleEntityAttach
import net.minecraft.network.PacketThreadUtil; //导入依赖的package包/类
public void handleEntityAttach(SPacketEntityAttach packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
Entity entity1 = this.clientWorldController.getEntityByID(packetIn.getVehicleEntityId());
if (entity instanceof EntityLiving)
{
if (entity1 != null)
{
((EntityLiving)entity).setLeashedToEntity(entity1, false);
}
else
{
((EntityLiving)entity).clearLeashed(false, false);
}
}
}
示例9: handleMapChunkBulk
import net.minecraft.network.PacketThreadUtil; //导入依赖的package包/类
public void handleMapChunkBulk(S26PacketMapChunkBulk packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
for (int i = 0; i < packetIn.getChunkCount(); ++i)
{
int j = packetIn.getChunkX(i);
int k = packetIn.getChunkZ(i);
this.clientWorldController.doPreChunk(j, k, true);
this.clientWorldController.invalidateBlockReceiveRegion(j << 4, 0, k << 4, (j << 4) + 15, 256, (k << 4) + 15);
Chunk chunk = this.clientWorldController.getChunkFromChunkCoords(j, k);
chunk.fillChunk(packetIn.getChunkBytes(i), packetIn.getChunkSize(i), true);
this.clientWorldController.markBlockRangeForRenderUpdate(j << 4, 0, k << 4, (j << 4) + 15, 256, (k << 4) + 15);
if (!(this.clientWorldController.provider instanceof WorldProviderSurface))
{
chunk.resetRelightChecks();
}
}
}
示例10: handleEntityMovement
import net.minecraft.network.PacketThreadUtil; //导入依赖的package包/类
/**
* 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).
*/
public void handleEntityMovement(SPacketEntity packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Entity entity = packetIn.getEntity(this.clientWorldController);
if (entity != null)
{
entity.serverPosX += (long)packetIn.getX();
entity.serverPosY += (long)packetIn.getY();
entity.serverPosZ += (long)packetIn.getZ();
double d0 = (double)entity.serverPosX / 4096.0D;
double d1 = (double)entity.serverPosY / 4096.0D;
double d2 = (double)entity.serverPosZ / 4096.0D;
if (!entity.canPassengerSteer())
{
float f = packetIn.isRotating() ? (float)(packetIn.getYaw() * 360) / 256.0F : entity.rotationYaw;
float f1 = packetIn.isRotating() ? (float)(packetIn.getPitch() * 360) / 256.0F : entity.rotationPitch;
entity.setPositionAndRotationDirect(d0, d1, d2, f, f1, 3, false);
entity.onGround = packetIn.getOnGround();
}
}
}
示例11: handleUpdateScore
import net.minecraft.network.PacketThreadUtil; //导入依赖的package包/类
/**
* Either updates the score with a specified value or removes the score for an objective
*/
public void handleUpdateScore(SPacketUpdateScore packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Scoreboard scoreboard = this.clientWorldController.getScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.getObjectiveName());
if (packetIn.getScoreAction() == SPacketUpdateScore.Action.CHANGE)
{
Score score = scoreboard.getOrCreateScore(packetIn.getPlayerName(), scoreobjective);
score.setScorePoints(packetIn.getScoreValue());
}
else if (packetIn.getScoreAction() == SPacketUpdateScore.Action.REMOVE)
{
if (StringUtils.isNullOrEmpty(packetIn.getObjectiveName()))
{
scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), (ScoreObjective)null);
}
else if (scoreobjective != null)
{
scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), scoreobjective);
}
}
}
示例12: handleUpdateScore
import net.minecraft.network.PacketThreadUtil; //导入依赖的package包/类
/**
* Either updates the score with a specified value or removes the score for an objective
*/
public void handleUpdateScore(S3CPacketUpdateScore packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Scoreboard scoreboard = this.clientWorldController.getScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.getObjectiveName());
if (packetIn.getScoreAction() == S3CPacketUpdateScore.Action.CHANGE)
{
Score score = scoreboard.getValueFromObjective(packetIn.getPlayerName(), scoreobjective);
score.setScorePoints(packetIn.getScoreValue());
}
else if (packetIn.getScoreAction() == S3CPacketUpdateScore.Action.REMOVE)
{
if (StringUtils.isNullOrEmpty(packetIn.getObjectiveName()))
{
scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), (ScoreObjective)null);
}
else if (scoreobjective != null)
{
scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), scoreobjective);
}
}
}
示例13: handleEntityEffect
import net.minecraft.network.PacketThreadUtil; //导入依赖的package包/类
public void handleEntityEffect(SPacketEntityEffect packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
if (entity instanceof EntityLivingBase)
{
Potion potion = Potion.getPotionById(packetIn.getEffectId() & 0xFF);
if (potion != null)
{
PotionEffect potioneffect = new PotionEffect(potion, packetIn.getDuration(), packetIn.getAmplifier(), packetIn.getIsAmbient(), packetIn.doesShowParticles());
potioneffect.setPotionDurationMax(packetIn.isMaxDuration());
((EntityLivingBase)entity).addPotionEffect(potioneffect);
}
}
}
示例14: handleUpdateTileEntity
import net.minecraft.network.PacketThreadUtil; //导入依赖的package包/类
/**
* Updates the NBTTagCompound metadata of instances of the following entitytypes: Mob spawners, command blocks,
* beacons, skulls, flowerpot
*/
public void handleUpdateTileEntity(SPacketUpdateTileEntity packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
if (this.gameController.world.isBlockLoaded(packetIn.getPos()))
{
TileEntity tileentity = this.gameController.world.getTileEntity(packetIn.getPos());
int i = packetIn.getTileEntityType();
boolean flag = i == 2 && tileentity instanceof TileEntityCommandBlock;
if (i == 1 && tileentity instanceof TileEntityMobSpawner || flag || i == 3 && tileentity instanceof TileEntityBeacon || i == 4 && tileentity instanceof TileEntitySkull || i == 5 && tileentity instanceof TileEntityFlowerPot || i == 6 && tileentity instanceof TileEntityBanner || i == 7 && tileentity instanceof TileEntityStructure || i == 8 && tileentity instanceof TileEntityEndGateway || i == 9 && tileentity instanceof TileEntitySign || i == 10 && tileentity instanceof TileEntityShulkerBox)
{
tileentity.readFromNBT(packetIn.getNbtCompound());
}
if (flag && this.gameController.currentScreen instanceof GuiCommandBlock)
{
((GuiCommandBlock)this.gameController.currentScreen).updateGui();
}
}
}
示例15: handleEntityVelocity
import net.minecraft.network.PacketThreadUtil; //导入依赖的package包/类
/**
* Sets the velocity of the specified entity to the specified value
*/
public void handleEntityVelocity(S12PacketEntityVelocity packetIn) {
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityID());
if (Minecraft.getMinecraft().thePlayer == entity) {
EventPlayerVelocity eventPlayerVelocity = new EventPlayerVelocity(100, 100);
eventPlayerVelocity.call();
if (eventPlayerVelocity.isCancelled()) {
return;
}
} else if (entity != null) {
entity.setVelocity((packetIn.getMotionX() * 100 / 100) / 8000.0D,
(packetIn.getMotionY() * 100 / 100) / 8000.0D, (packetIn.getMotionZ() * 100 / 100) / 8000.0D);
}
}