Search in sources :

Example 21 with EntityPlayerMP

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);
}
Also used : EntityFixMessage(ValkyrienWarfareControl.Network.EntityFixMessage) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Example 22 with EntityPlayerMP

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());
}
Also used : EntityFixMessage(ValkyrienWarfareControl.Network.EntityFixMessage) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Example 23 with EntityPlayerMP

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);
                }
            }
        }
    }
}
Also used : SPacketSoundEffect(net.minecraft.network.play.server.SPacketSoundEffect) SPacketEffect(net.minecraft.network.play.server.SPacketEffect) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) BlockPos(net.minecraft.util.math.BlockPos) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) World(net.minecraft.world.World) Vector(ValkyrienWarfareBase.API.Vector)

Example 24 with EntityPlayerMP

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"));
    }
}
Also used : Entity(net.minecraft.entity.Entity) ShipUUIDToPosData(ValkyrienWarfareBase.Interaction.ShipUUIDToPosData) ShipNameUUIDData(ValkyrienWarfareBase.Interaction.ShipNameUUIDData) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) TextComponentString(net.minecraft.util.text.TextComponentString) ShipPositionData(ValkyrienWarfareBase.Interaction.ShipUUIDToPosData.ShipPositionData) World(net.minecraft.world.World) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 25 with EntityPlayerMP

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;
}
Also used : ItemSystemLinker(ValkyrienWarfareControl.Item.ItemSystemLinker) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Aggregations

EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)163 EntityPlayer (net.minecraft.entity.player.EntityPlayer)32 ItemStack (net.minecraft.item.ItemStack)23 TileEntity (net.minecraft.tileentity.TileEntity)18 Entity (net.minecraft.entity.Entity)17 EntityLivingBase (net.minecraft.entity.EntityLivingBase)15 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)15 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)14 BlockPos (net.minecraft.util.math.BlockPos)14 Block (net.minecraft.block.Block)11 IBlockState (net.minecraft.block.state.IBlockState)8 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)8 World (net.minecraft.world.World)8 WrongUsageException (net.minecraft.command.WrongUsageException)7 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)7 NetHandlerPlayServer (net.minecraft.network.NetHandlerPlayServer)7 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)6 TrainPacket (club.nsdn.nyasamarailway.network.TrainPacket)5 TileEntityReceiver (club.nsdn.nyasamatelecom.api.tileentity.TileEntityReceiver)5 GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)5