Java Code Examples for net.minecraft.entity.player.EntityPlayerMP#getServerWorld()
The following examples show how to use
net.minecraft.entity.player.EntityPlayerMP#getServerWorld() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MessageQuestUpdate.java From ToroQuest with GNU General Public License v3.0 | 6 votes |
@Override public IMessage onMessage(final MessageQuestUpdate message, MessageContext ctx) { if (ctx.side != Side.SERVER) { return null; } final EntityPlayerMP player = ctx.getServerHandler().player; if (player == null) { return null; } final WorldServer worldServer = player.getServerWorld(); worldServer.addScheduledTask(new Runnable() { @Override public void run() { new Worker(message.action).work(message, player); } }); return null; }
Example 2
Source File: MessageRequestPlayerCivilizationSync.java From ToroQuest with GNU General Public License v3.0 | 6 votes |
@Override public IMessage onMessage(final MessageRequestPlayerCivilizationSync message, MessageContext ctx) { if (ctx.side != Side.SERVER) { return null; } final EntityPlayerMP player = ctx.getServerHandler().player; if (player == null) { return null; } final WorldServer worldServer = player.getServerWorld(); worldServer.addScheduledTask(new Runnable() { @Override public void run() { PlayerCivilizationCapabilityImpl.get(player).syncClient(); } }); return null; }
Example 3
Source File: ITransformablePacket.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
/** * Puts the player into local coordinates and makes a record of where they used to be. */ default void doPreProcessing(INetHandlerPlayServer server, boolean callingFromSponge) { if (isPacketOnMainThread(server, callingFromSponge)) { // System.out.println("Pre packet process"); NetHandlerPlayServer serverHandler = (NetHandlerPlayServer) server; EntityPlayerMP player = serverHandler.player; PhysicsWrapperEntity wrapper = getPacketParent(serverHandler); if (wrapper != null && wrapper.getPhysicsObject().getShipTransformationManager() != null) { ISubspaceProvider worldProvider = (ISubspaceProvider) player.getServerWorld(); ISubspace worldSubspace = worldProvider.getSubspace(); worldSubspace.snapshotSubspacedEntity((ISubspacedEntity) player); wrapper.getPhysicsObject().getShipTransformationManager() .getCurrentTickTransform().transform(player, TransformType.GLOBAL_TO_SUBSPACE); } } }
Example 4
Source File: ITransformablePacket.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
/** * Restores the player from local coordinates to where they used to be. */ default void doPostProcessing(INetHandlerPlayServer server, boolean callingFromSponge) { if (isPacketOnMainThread(server, callingFromSponge)) { NetHandlerPlayServer serverHandler = (NetHandlerPlayServer) server; EntityPlayerMP player = serverHandler.player; PhysicsWrapperEntity wrapper = getPacketParent(serverHandler); // I don't care what happened to that ship in the time between, we must restore // the player to their proper coordinates. ISubspaceProvider worldProvider = (ISubspaceProvider) player.getServerWorld(); ISubspace worldSubspace = worldProvider.getSubspace(); ISubspacedEntity subspacedEntity = (ISubspacedEntity) player; ISubspacedEntityRecord record = worldSubspace .getRecordForSubspacedEntity(subspacedEntity); // System.out.println(player.getPosition()); if (subspacedEntity.currentSubspaceType() == CoordinateSpaceType.SUBSPACE_COORDINATES) { subspacedEntity.restoreSubspacedEntityStateToRecord(record); player.setPosition(player.posX, player.posY, player.posZ); } // System.out.println(player.getPosition()); // We need this because Sponge Mixins prevent this from properly working. This // won't be necessary on client however. } }
Example 5
Source File: MessageKeyPressed.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public IMessage onMessage(final MessageKeyPressed message, MessageContext ctx) { if (ctx.side != Side.SERVER) { EnderUtilities.logger.error("Wrong side in MessageKeyPressed: " + ctx.side); return null; } final EntityPlayerMP sendingPlayer = ctx.getServerHandler().player; if (sendingPlayer == null) { EnderUtilities.logger.error("Sending player was null in MessageKeyPressed"); return null; } final WorldServer playerWorldServer = sendingPlayer.getServerWorld(); if (playerWorldServer == null) { EnderUtilities.logger.error("World was null in MessageKeyPressed"); return null; } playerWorldServer.addScheduledTask(new Runnable() { public void run() { processMessage(message, sendingPlayer); } }); return null; }
Example 6
Source File: MessageSendString.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public IMessage onMessage(final MessageSendString message, MessageContext ctx) { if (ctx.side != Side.SERVER) { EnderUtilities.logger.error("Wrong side in MessageSendString: " + ctx.side); return null; } final EntityPlayerMP sendingPlayer = ctx.getServerHandler().player; if (sendingPlayer == null) { EnderUtilities.logger.error("Sending player was null in MessageSendString"); return null; } final WorldServer playerWorldServer = sendingPlayer.getServerWorld(); if (playerWorldServer == null) { EnderUtilities.logger.error("World was null in MessageSendString"); return null; } playerWorldServer.addScheduledTask(new Runnable() { public void run() { processMessage(message, sendingPlayer); } }); return null; }
Example 7
Source File: MessageGuiAction.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public IMessage onMessage(final MessageGuiAction message, MessageContext ctx) { if (ctx.side != Side.SERVER) { EnderUtilities.logger.error("Wrong side in MessageGuiAction: " + ctx.side); return null; } final EntityPlayerMP sendingPlayer = ctx.getServerHandler().player; if (sendingPlayer == null) { EnderUtilities.logger.error("Sending player was null in MessageGuiAction"); return null; } final WorldServer playerWorldServer = sendingPlayer.getServerWorld(); if (playerWorldServer == null) { EnderUtilities.logger.error("World was null in MessageGuiAction"); return null; } playerWorldServer.addScheduledTask(new Runnable() { public void run() { processMessage(message, sendingPlayer); } }); return null; }
Example 8
Source File: MessageOpenGui.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public IMessage onMessage(final MessageOpenGui message, MessageContext ctx) { if (ctx.side != Side.SERVER) { EnderUtilities.logger.error("Wrong side in MessageOpenGui: " + ctx.side); return null; } final EntityPlayerMP sendingPlayer = ctx.getServerHandler().player; if (sendingPlayer == null) { EnderUtilities.logger.error("player was null in MessageOpenGui"); return null; } final WorldServer playerWorldServer = sendingPlayer.getServerWorld(); if (playerWorldServer == null) { EnderUtilities.logger.error("World was null in MessageOpenGui"); return null; } playerWorldServer.addScheduledTask(new Runnable() { public void run() { processMessage(message, sendingPlayer); } }); return null; }