use of net.minecraft.entity.player.EntityPlayerMP in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class PhysicsObject method fixEntity.
/**
* ONLY USE THESE 2 METHODS TO EVER ADD/REMOVE ENTITIES, OTHERWISE YOU'LL RUIN EVERYTHING!
*
* @param toFix
* @param posInLocal
*/
public void fixEntity(Entity toFix, Vector posInLocal) {
EntityFixMessage entityFixingMessage = new EntityFixMessage(wrapper, toFix, true, posInLocal);
for (EntityPlayerMP watcher : watchingPlayers) {
ValkyrienWarfareControlMod.controlNetwork.sendTo(entityFixingMessage, watcher);
}
entityLocalPositions.put(toFix.getPersistentID().hashCode(), posInLocal);
}
use of net.minecraft.entity.player.EntityPlayerMP in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class PhysicsObject method unFixEntity.
/**
* ONLY USE THESE 2 METHODS TO EVER ADD/REMOVE ENTITIES, OTHERWISE YOU'LL RUIN EVERYTHING!
*
* @param toFix
* @param posInLocal
*/
public void unFixEntity(Entity toUnfix) {
EntityFixMessage entityUnfixingMessage = new EntityFixMessage(wrapper, toUnfix, false, null);
for (EntityPlayerMP watcher : watchingPlayers) {
ValkyrienWarfareControlMod.controlNetwork.sendTo(entityUnfixingMessage, watcher);
}
entityLocalPositions.remove(toUnfix.getPersistentID().hashCode());
}
use of net.minecraft.entity.player.EntityPlayerMP in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class CallRunner method onSendToAllNearExcept.
/* public static boolean onSpawnEntityInWorld(World world, Entity entity) {
BlockPos posAt = new BlockPos(entity);
PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(world, posAt);
if (!(entity instanceof EntityFallingBlock) && wrapper != null && wrapper.wrapping.coordTransform != null) {
if (entity instanceof EntityMountingWeaponBase || entity instanceof EntityArmorStand || entity instanceof EntityPig || entity instanceof EntityBoat) {
// entity.startRiding(wrapper);
wrapper.wrapping.fixEntity(entity, new Vector(entity));
wrapper.wrapping.queueEntityForMounting(entity);
}
RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.lToWTransform, wrapper.wrapping.coordTransform.lToWRotation, entity);
}
return world.spawnEntityInWorld(entity);
}*/
public static void onSendToAllNearExcept(PlayerList list, @Nullable EntityPlayer except, double x, double y, double z, double radius, int dimension, Packet<?> packetIn) {
BlockPos pos = new BlockPos(x, y, z);
World worldIn = null;
if (except == null) {
worldIn = DimensionManager.getWorld(dimension);
} else {
worldIn = except.worldObj;
}
PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldIn, pos);
Vector packetPosition = new Vector(x, y, z);
if (wrapper != null && wrapper.wrapping.coordTransform != null) {
wrapper.wrapping.coordTransform.fromLocalToGlobal(packetPosition);
if (packetIn instanceof SPacketSoundEffect) {
SPacketSoundEffect soundEffect = (SPacketSoundEffect) packetIn;
packetIn = new SPacketSoundEffect(soundEffect.sound, soundEffect.category, packetPosition.X, packetPosition.Y, packetPosition.Z, soundEffect.soundVolume, soundEffect.soundPitch);
}
//
if (packetIn instanceof SPacketEffect) {
SPacketEffect effect = (SPacketEffect) packetIn;
BlockPos blockpos = new BlockPos(packetPosition.X, packetPosition.Y, packetPosition.Z);
packetIn = new SPacketEffect(effect.soundType, blockpos, effect.soundData, effect.serverWide);
}
}
x = packetPosition.X;
y = packetPosition.Y;
z = packetPosition.Z;
for (int i = 0; i < list.playerEntityList.size(); ++i) {
EntityPlayerMP entityplayermp = (EntityPlayerMP) list.playerEntityList.get(i);
if (entityplayermp != except && entityplayermp.dimension == dimension) {
// NOTE: These are set to use the last variables for a good reason; dont change them
double d0 = x - entityplayermp.posX;
double d1 = y - entityplayermp.posY;
double d2 = z - entityplayermp.posZ;
if (d0 * d0 + d1 * d1 + d2 * d2 < radius * radius) {
entityplayermp.connection.sendPacket(packetIn);
} else {
d0 = x - entityplayermp.lastTickPosX;
d1 = y - entityplayermp.lastTickPosY;
d2 = z - entityplayermp.lastTickPosZ;
if (d0 * d0 + d1 * d1 + d2 * d2 < radius * radius) {
entityplayermp.connection.sendPacket(packetIn);
}
}
}
}
}
use of net.minecraft.entity.player.EntityPlayerMP in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class AirshipMapCommand method execute.
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
String term = args[0];
if (term.equals("tpto")) {
String shipName = args[1];
if (args.length > 2) {
for (int i = 2; i < args.length; i++) {
shipName += " " + args[i];
}
}
Entity player = sender.getCommandSenderEntity();
World world = player.worldObj;
ShipNameUUIDData data = ShipNameUUIDData.get(world);
if (data.ShipNameToLongMap.containsKey(shipName)) {
long shipUUIDMostSig = data.ShipNameToLongMap.get(shipName);
ShipUUIDToPosData posData = ShipUUIDToPosData.get(world);
ShipPositionData positionData = posData.getShipPositionData(shipUUIDMostSig);
double posX = positionData.shipPosition.X;
double posY = positionData.shipPosition.Y;
double posZ = positionData.shipPosition.Z;
if (player instanceof EntityPlayerMP) {
EntityPlayerMP playerMP = (EntityPlayerMP) player;
((EntityPlayerMP) player).connection.setPlayerLocation(posX, posY, posZ, 0, 0);
}
}
}
if (term.equals("help")) {
sender.addChatMessage(new TextComponentString("tpto"));
}
}
use of net.minecraft.entity.player.EntityPlayerMP in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class BlockHovercraftController method onBlockActivated.
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldIn, pos);
if (heldItem != null && heldItem.getItem() instanceof ItemSystemLinker) {
return false;
}
if (wrapper != null) {
if (!worldIn.isRemote) {
if (playerIn instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) playerIn;
int realWindowId = player.currentWindowId;
// TODO: Fix this, I have to reset the window Id's because there is no container on client side, resulting in the client never changing its window id
player.currentWindowId = player.inventoryContainer.windowId - 1;
player.openGui(ValkyrienWarfareControlMod.instance, ControlGUIEnum.HoverCraftController.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ());
player.currentWindowId = realWindowId;
// player.openContainer = playerIn.inventoryContainer;
}
// ModContainer mc = FMLCommonHandler.instance().findContainerFor(ValkyrienWarfareControlMod.instance);
// if (playerIn instanceof EntityPlayerMP && !(playerIn instanceof FakePlayer))
// {
// EntityPlayerMP entityPlayerMP = (EntityPlayerMP) playerIn;
// Container remoteGuiContainer = NetworkRegistry.INSTANCE.getRemoteGuiContainer(mc, entityPlayerMP, ControlGUIEnum.HoverCraftController.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ());
// if (remoteGuiContainer != null)
// {
// entityPlayerMP.getNextWindowId();
// entityPlayerMP.closeContainer();
// int windowId = entityPlayerMP.currentWindowId;
// entityPlayerMP.openContainer = remoteGuiContainer;
// entityPlayerMP.openContainer = entityPlayerMP.inventoryContainer;
//// entityPlayerMP.openContainer.windowId = windowId;
//// entityPlayerMP.openContainer.addListener(entityPlayerMP);
// net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(playerIn, playerIn.openContainer));
// }
// }
}
return true;
}
return false;
}
Aggregations