use of net.minecraft.entity.player.EntityPlayerMP in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class EventsCommon method onPlayerTickEvent.
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerTickEvent(PlayerTickEvent event) {
if (!event.player.worldObj.isRemote && event.player != null) {
EntityPlayerMP p = (EntityPlayerMP) event.player;
try {
if (!(p.connection instanceof CustomNetHandlerPlayServer)) {
p.connection = new CustomNetHandlerPlayServer(p.connection);
} else {
CustomNetHandlerPlayServer customNetHandler = (CustomNetHandlerPlayServer) p.connection;
if (p.interactionManager.getBlockReachDistance() == CustomNetHandlerPlayServer.dummyBlockReachDist && customNetHandler.ticksSinceLastTry == 2) {
p.interactionManager.setBlockReachDistance(((CustomNetHandlerPlayServer) p.connection).lastGoodBlockReachDist);
}
customNetHandler.ticksSinceLastTry++;
}
} catch (Exception e) {
e.printStackTrace();
}
Double[] pos = lastPositions.get(p);
if (pos == null) {
pos = new Double[3];
lastPositions.put(p, pos);
}
try {
if (pos[0] != p.posX || pos[2] != p.posZ) {
// Player has moved
if (Math.abs(p.posX) > 27000000 || Math.abs(p.posZ) > 27000000) {
// Player is outside of world border, tp them back
p.attemptTeleport(pos[0], pos[1], pos[2]);
p.addChatMessage(new TextComponentString("You can't go beyond 27000000 blocks because airships are stored there!"));
}
}
} catch (NullPointerException e) {
ValkyrienWarfareMod.VWLogger.log(Level.WARNING, "Nullpointer EventsCommon.java:onPlayerTickEvent");
}
pos[0] = p.posX;
pos[1] = p.posY;
pos[2] = p.posZ;
}
}
use of net.minecraft.entity.player.EntityPlayerMP in project Witchworks by Um-Mitternacht.
the class BrewEvents method onWorldJoin.
@SubscribeEvent
public void onWorldJoin(EntityJoinWorldEvent event) {
if (event.getEntity() instanceof EntityPlayerMP) {
EntityPlayerMP entity = (EntityPlayerMP) event.getEntity();
Optional<IBrewStorage> optional = BrewStorageHandler.getBrewStorage(entity);
if (optional.isPresent()) {
PacketHandler.sendTo(entity, new PotionMessage(optional.get().getBrews().keySet(), entity.getUniqueID()));
}
}
}
use of net.minecraft.entity.player.EntityPlayerMP in project Witchworks by Um-Mitternacht.
the class EnergyEvents method onWorldJoin.
@SubscribeEvent
public void onWorldJoin(EntityJoinWorldEvent event) {
if (event.getEntity() instanceof EntityPlayerMP) {
EntityPlayerMP entity = (EntityPlayerMP) event.getEntity();
Optional<IEnergy> optional = EnergyHandler.getEnergy(entity);
if (optional.isPresent()) {
PacketHandler.sendTo(entity, new EnergyMessage(optional.get(), entity.getUniqueID()));
}
}
}
use of net.minecraft.entity.player.EntityPlayerMP in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class PhysicsObject method getPlayersThatJustWatched.
private Set getPlayersThatJustWatched() {
HashSet newPlayers = new HashSet();
for (Object o : ((WorldServer) worldObj).getEntityTracker().getTrackingPlayers(wrapper)) {
EntityPlayerMP player = (EntityPlayerMP) o;
if (!watchingPlayers.contains(player)) {
newPlayers.add(player);
watchingPlayers.add(player);
}
}
return newPlayers;
}
use of net.minecraft.entity.player.EntityPlayerMP in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class PhysicsObject method destroy.
public void destroy() {
wrapper.setDead();
ArrayList<EntityPlayerMP> watchersCopy = (ArrayList<EntityPlayerMP>) watchingPlayers.clone();
for (EntityPlayerMP wachingPlayer : watchersCopy) {
for (int x = ownedChunks.minX; x <= ownedChunks.maxX; x++) {
for (int z = ownedChunks.minZ; z <= ownedChunks.maxZ; z++) {
SPacketUnloadChunk unloadPacket = new SPacketUnloadChunk(x, z);
((EntityPlayerMP) wachingPlayer).connection.sendPacket(unloadPacket);
}
}
// NOTICE: This method isnt being called to avoid the watchingPlayers.remove(player) call, which is a waste of CPU time
// onPlayerUntracking(wachingPlayer);
}
watchingPlayers.clear();
ValkyrienWarfareMod.chunkManager.removeRegistedChunksForShip(wrapper);
ValkyrienWarfareMod.chunkManager.removeShipPosition(wrapper);
ValkyrienWarfareMod.chunkManager.removeShipNameRegistry(wrapper);
ValkyrienWarfareMod.physicsManager.onShipUnload(wrapper);
}
Aggregations