Search in sources :

Example 76 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class CallRunnerClient method doRenderEntity.

public static void doRenderEntity(RenderManager manager, Entity entityIn, double x, double y, double z, float yaw, float partialTicks, boolean p_188391_10_) {
    PhysicsWrapperEntity fixedOnto = ValkyrienWarfareMod.physicsManager.getShipFixedOnto(entityIn);
    if (fixedOnto != null) {
        double oldPosX = entityIn.posX;
        double oldPosY = entityIn.posY;
        double oldPosZ = entityIn.posZ;
        double oldLastPosX = entityIn.lastTickPosX;
        double oldLastPosY = entityIn.lastTickPosY;
        double oldLastPosZ = entityIn.lastTickPosZ;
        Vector localPosition = fixedOnto.wrapping.getLocalPositionForEntity(entityIn);
        fixedOnto.wrapping.renderer.setupTranslation(partialTicks);
        if (localPosition != null) {
            localPosition = new Vector(localPosition);
            localPosition.X -= fixedOnto.wrapping.renderer.offsetPos.getX();
            localPosition.Y -= fixedOnto.wrapping.renderer.offsetPos.getY();
            localPosition.Z -= fixedOnto.wrapping.renderer.offsetPos.getZ();
            x = entityIn.posX = entityIn.lastTickPosX = localPosition.X;
            y = entityIn.posY = entityIn.lastTickPosY = localPosition.Y;
            z = entityIn.posZ = entityIn.lastTickPosZ = localPosition.Z;
        }
        boolean makePlayerMount = false;
        PhysicsWrapperEntity shipRidden = null;
        if (entityIn instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) entityIn;
            if (player.isPlayerSleeping()) {
                if (player.ridingEntity instanceof PhysicsWrapperEntity) {
                    shipRidden = (PhysicsWrapperEntity) player.ridingEntity;
                }
                if (shipRidden != null) {
                    player.ridingEntity = null;
                    makePlayerMount = true;
                    //Now fix the rotation of sleeping players
                    Vector playerPosInLocal = new Vector(fixedOnto.wrapping.getLocalPositionForEntity(entityIn));
                    playerPosInLocal.subtract(.5D, .6875, .5);
                    playerPosInLocal.roundToWhole();
                    BlockPos bedPos = new BlockPos(playerPosInLocal.X, playerPosInLocal.Y, playerPosInLocal.Z);
                    IBlockState state = entityIn.worldObj.getBlockState(bedPos);
                    Block block = state.getBlock();
                    float angleYaw = 0;
                    if (block != null && block.isBed(state, entityIn.worldObj, bedPos, entityIn)) {
                        angleYaw = (float) (block.getBedDirection(state, entityIn.worldObj, bedPos).getHorizontalIndex() * 90);
                    //	                    	angleYaw += 180;
                    }
                    GL11.glRotatef(angleYaw, 0, 1F, 0);
                }
            }
        }
        manager.doRenderEntity(entityIn, x, y, z, yaw, partialTicks, p_188391_10_);
        if (makePlayerMount) {
            EntityPlayer player = (EntityPlayer) entityIn;
            player.ridingEntity = shipRidden;
        }
        if (localPosition != null) {
            fixedOnto.wrapping.renderer.inverseTransform(partialTicks);
        }
        entityIn.posX = oldPosX;
        entityIn.posY = oldPosY;
        entityIn.posZ = oldPosZ;
        entityIn.lastTickPosX = oldLastPosX;
        entityIn.lastTickPosY = oldLastPosY;
        entityIn.lastTickPosZ = oldLastPosZ;
    } else {
        manager.doRenderEntity(entityIn, x, y, z, yaw, partialTicks, p_188391_10_);
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) EnumSkyBlock(net.minecraft.world.EnumSkyBlock) BlockPos(net.minecraft.util.math.BlockPos) Vector(ValkyrienWarfareBase.API.Vector)

Example 77 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class CallRunner method onGetEntitiesInAABBexcluding.

public static List<Entity> onGetEntitiesInAABBexcluding(World world, @Nullable Entity entityIn, AxisAlignedBB boundingBox, @Nullable Predicate<? super Entity> predicate) {
    if ((boundingBox.maxX - boundingBox.minX) * (boundingBox.maxZ - boundingBox.minZ) > 1000000D) {
        return new ArrayList();
    }
    //Prevents the players item pickup AABB from merging with a PhysicsWrapperEntity AABB
    if (entityIn instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) entityIn;
        if (player.isRiding() && !player.getRidingEntity().isDead && player.getRidingEntity() instanceof PhysicsWrapperEntity) {
            AxisAlignedBB axisalignedbb = player.getEntityBoundingBox().union(player.getRidingEntity().getEntityBoundingBox()).expand(1.0D, 0.0D, 1.0D);
            if (boundingBox.equals(axisalignedbb)) {
                boundingBox = player.getEntityBoundingBox().expand(1.0D, 0.5D, 1.0D);
            }
        }
    }
    List toReturn = world.getEntitiesInAABBexcluding(entityIn, boundingBox, predicate);
    BlockPos pos = new BlockPos((boundingBox.minX + boundingBox.maxX) / 2D, (boundingBox.minY + boundingBox.maxY) / 2D, (boundingBox.minZ + boundingBox.maxZ) / 2D);
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(world, pos);
    if (wrapper != null) {
        Polygon poly = new Polygon(boundingBox, wrapper.wrapping.coordTransform.lToWTransform);
        boundingBox = poly.getEnclosedAABB().contract(.3D);
        toReturn.addAll(world.getEntitiesInAABBexcluding(entityIn, boundingBox, predicate));
    }
    return toReturn;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) ArrayList(java.util.ArrayList) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ArrayList(java.util.ArrayList) PlayerList(net.minecraft.server.management.PlayerList) List(java.util.List) BlockPos(net.minecraft.util.math.BlockPos) Polygon(ValkyrienWarfareBase.Collision.Polygon) EntityPolygon(ValkyrienWarfareBase.Collision.EntityPolygon)

Example 78 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class AirshipSettingsCommand method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (!(sender instanceof EntityPlayer)) {
        sender.addChatMessage(new TextComponentString("You need to be a player to do that!"));
        return;
    }
    if (args.length == 0) {
        sender.addChatMessage(new TextComponentString(TextFormatting.RED + "Usage: " + getCommandUsage(sender)));
        return;
    }
    EntityPlayer p = (EntityPlayer) sender;
    //This method has an @SIDE.CLIENT, and it broke all the commands on servers!
    //		BlockPos pos = p.rayTrace(p.isCreative() ? 5.0 : 4.5, 1).getBlockPos();
    BlockPos pos = rayTraceBothSides(p, p.isCreative() ? 5.0 : 4.5, 1).getBlockPos();
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(p.getEntityWorld(), pos);
    if (wrapper == null) {
        sender.addChatMessage(new TextComponentString("You need to be looking at an airship to do that!"));
        return;
    }
    if (p.entityUniqueID.toString().equals(wrapper.wrapping.creator)) {
        if (args[0].equals("transfer")) {
            if (args.length == 1) {
                return;
            }
            if (!args[1].isEmpty()) {
                EntityPlayer target = server.getPlayerList().getPlayerByUsername(args[1]);
                if (target == null) {
                    p.addChatMessage(new TextComponentString("That player is not online!"));
                    return;
                }
                switch(wrapper.wrapping.changeOwner(target)) {
                    case ERROR_IMPOSSIBLE_STATUS:
                        p.addChatMessage(new TextComponentString("An error occured, please report to mod devs"));
                        break;
                    case ERROR_NEWOWNER_NOT_ENOUGH:
                        p.addChatMessage(new TextComponentString("That player doesn't have enough free airship slots!"));
                        break;
                    case SUCCESS:
                        p.addChatMessage(new TextComponentString("Success! " + target.getName() + " is the new owner of this airship!"));
                        break;
                    case ALREADY_CLAIMED:
                        p.addChatMessage(new TextComponentString("Airship already claimed"));
                        break;
                }
                return;
            }
        } else if (args[0].equals("allowPlayer")) {
            if (args.length == 1) {
                StringBuilder result = new StringBuilder("<");
                Iterator<String> iter = wrapper.wrapping.allowedUsers.iterator();
                while (iter.hasNext()) {
                    result.append(iter.next() + (iter.hasNext() ? ", " : ">"));
                }
                p.addChatMessage(new TextComponentString(result.toString()));
                return;
            }
            if (!args[1].isEmpty()) {
                EntityPlayer target = server.getPlayerList().getPlayerByUsername(args[1]);
                if (target == null) {
                    p.addChatMessage(new TextComponentString("That player is not online!"));
                    return;
                }
                if (target.entityUniqueID.toString().equals(wrapper.wrapping.creator)) {
                    p.addChatMessage(new TextComponentString("You can't add yourself to your own airship!"));
                    return;
                }
                wrapper.wrapping.allowedUsers.add(target.entityUniqueID.toString());
                p.addChatMessage(new TextComponentString("Success! " + target.getName() + " can now interact with this airship!"));
                return;
            }
        }
    } else {
        if (wrapper.wrapping.creator == null || wrapper.wrapping.creator.trim().isEmpty()) {
            if (args.length == 1 && args[0].equals("claim")) {
                wrapper.wrapping.creator = p.entityUniqueID.toString();
                p.addChatMessage(new TextComponentString("You've successfully claimed an airship!"));
                return;
            }
        }
        p.addChatMessage(new TextComponentString("You need to be the owner of an airship to change airship settings!"));
    }
    if (args[0].equals("help")) {
        for (String command : completionOptions) {
            sender.addChatMessage(new TextComponentString(command));
        }
    }
    sender.addChatMessage(new TextComponentString(TextFormatting.RED + "Usage: " + getCommandUsage(sender)));
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) Iterator(java.util.Iterator) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 79 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project Engine by VoltzEngine-Project.

the class ClientProxy method clientUpdate.

@SubscribeEvent
public void clientUpdate(TickEvent.WorldTickEvent event) {
    if (///TODO reduce check to every 10 ticks
    Engine.enableExtendedMetaPacketSync) {
        try {
            if (event.side == Side.CLIENT) {
                Minecraft mc = Minecraft.getMinecraft();
                if (mc != null) {
                    EntityPlayer player = mc.thePlayer;
                    World world = mc.theWorld;
                    if (player != null && world != null) {
                        if (ExtendedBlockDataManager.CLIENT.dimID != world.provider.dimensionId) {
                            ExtendedBlockDataManager.CLIENT.clear();
                            ExtendedBlockDataManager.CLIENT.dimID = world.provider.dimensionId;
                        }
                        int renderDistance = mc.gameSettings.renderDistanceChunks + 2;
                        int centerX = ((int) Math.floor(player.posX)) >> 4;
                        int centerZ = ((int) Math.floor(player.posZ)) >> 4;
                        //Clear out chunks outside of render distance
                        List<ChunkData> chunksToRemove = new ArrayList();
                        for (ChunkData data : ExtendedBlockDataManager.CLIENT.chunks.values()) {
                            if (Math.abs(data.position.chunkXPos - centerX) > renderDistance || Math.abs(data.position.chunkZPos - centerZ) > renderDistance) {
                                chunksToRemove.add(data);
                            }
                        }
                        for (ChunkData data : chunksToRemove) {
                            ExtendedBlockDataManager.CLIENT.chunks.remove(data.position);
                        }
                        renderDistance = mc.gameSettings.renderDistanceChunks;
                        for (int x = centerX - renderDistance; x < centerX + renderDistance; x++) {
                            for (int z = centerZ - renderDistance; z < centerZ + renderDistance; z++) {
                                ChunkData chunkData = ExtendedBlockDataManager.CLIENT.getChunk(x, z);
                                if (chunkData == null) {
                                    Engine.instance.packetHandler.sendToServer(new PacketRequestData(world.provider.dimensionId, x, z, 0));
                                }
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            Engine.logger().error("Unexpected error while updating client chunk data state", e);
        }
    }
}
Also used : ChunkData(com.builtbroken.mc.lib.world.map.data.ChunkData) PacketRequestData(com.builtbroken.mc.core.network.packet.callback.chunk.PacketRequestData) ArrayList(java.util.ArrayList) EntityPlayer(net.minecraft.entity.player.EntityPlayer) World(net.minecraft.world.World) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 80 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project Engine by VoltzEngine-Project.

the class GroupProfileHandler method canExecuteCommand.

public boolean canExecuteCommand(ICommandSender sender, ICommand command, String[] args) {
    if (sender instanceof EntityPlayer) {
        AccessUser user = getAccessProfile().getUserAccess((EntityPlayer) sender);
        String node = PermissionsRegistry.getNodeFor(command, args);
        return user.hasNode(node);
    }
    return command.canCommandSenderUseCommand(sender);
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) AccessUser(com.builtbroken.mc.framework.access.AccessUser)

Aggregations

EntityPlayer (net.minecraft.entity.player.EntityPlayer)625 ItemStack (net.minecraft.item.ItemStack)169 EntityLivingBase (net.minecraft.entity.EntityLivingBase)104 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)81 Entity (net.minecraft.entity.Entity)77 World (net.minecraft.world.World)73 BlockPos (net.minecraft.util.math.BlockPos)61 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)49 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)44 TileEntity (net.minecraft.tileentity.TileEntity)43 PotionEffect (net.minecraft.potion.PotionEffect)41 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)38 EntityItem (net.minecraft.entity.item.EntityItem)37 Block (net.minecraft.block.Block)36 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)35 ArrayList (java.util.ArrayList)33 IBlockState (net.minecraft.block.state.IBlockState)33 List (java.util.List)28 TextComponentString (net.minecraft.util.text.TextComponentString)27 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)23