Search in sources :

Example 86 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP in project Charset by CharsetMC.

the class SubCommandSetupTestWorld method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) {
    ((EntityPlayerSP) sender).sendChatMessage("/gamerule doDaylightCycle false");
    ((EntityPlayerSP) sender).sendChatMessage("/gamerule doMobSpawning false");
    ((EntityPlayerSP) sender).sendChatMessage("/gamerule keepInventory true");
    ((EntityPlayerSP) sender).sendChatMessage("/weather clear 999999");
    ((EntityPlayerSP) sender).sendChatMessage("/time set 1200");
    // TODO: FIXME - this won't work on a dedicated server!
    for (World world : server.worlds) {
        for (Entity entity : world.loadedEntityList) {
            if (entity instanceof EntityLiving || entity instanceof EntityItem) {
                entity.setDead();
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityLiving(net.minecraft.entity.EntityLiving) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) World(net.minecraft.world.World) EntityItem(net.minecraft.entity.item.EntityItem)

Example 87 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP in project ConvenientAdditions by Necr0.

the class EventHandlerPlayerMovement method onClientUpdate.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onClientUpdate(TickEvent.ClientTickEvent event) {
    EntityPlayerSP player = Helper.getClientPlayer();
    if (player == null || event.phase != TickEvent.Phase.START)
        return;
    MovementInput input = player.movementInput;
    if (!wasJumping && input.jump) {
        MinecraftForge.EVENT_BUS.post(new PlayerMovementEvent.PlayerJumpEvent(player, player.getEntityWorld()));
    }
    if (!wasSneaking && input.sneak) {
        MinecraftForge.EVENT_BUS.post(new PlayerMovementEvent.PlayerSneakEvent(player, player.getEntityWorld()));
    }
    wasJumping = input.jump;
    wasSneaking = input.sneak;
}
Also used : PlayerMovementEvent(convenientadditions.api.event.PlayerMovementEvent) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) MovementInput(net.minecraft.util.MovementInput) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 88 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP in project Wurst-MC-1.12 by Wurst-Imperium.

the class TrajectoriesMod method onRender.

@Override
public void onRender(float partialTicks) {
    EntityPlayerSP player = WMinecraft.getPlayer();
    // check if player is holding item
    ItemStack stack = player.inventory.getCurrentItem();
    if (stack == null)
        return;
    // check if item is throwable
    if (!WItem.isThrowable(stack))
        return;
    boolean usingBow = stack.getItem() instanceof ItemBow;
    // calculate starting position
    double arrowPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * mc.timer.renderPartialTicks - WMath.cos((float) Math.toRadians(player.rotationYaw)) * 0.16F;
    double arrowPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * Minecraft.getMinecraft().timer.renderPartialTicks + player.getEyeHeight() - 0.1;
    double arrowPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * Minecraft.getMinecraft().timer.renderPartialTicks - WMath.sin((float) Math.toRadians(player.rotationYaw)) * 0.16F;
    // calculate starting motion
    float arrowMotionFactor = usingBow ? 1F : 0.4F;
    float yaw = (float) Math.toRadians(player.rotationYaw);
    float pitch = (float) Math.toRadians(player.rotationPitch);
    float arrowMotionX = -WMath.sin(yaw) * WMath.cos(pitch) * arrowMotionFactor;
    float arrowMotionY = -WMath.sin(pitch) * arrowMotionFactor;
    float arrowMotionZ = WMath.cos(yaw) * WMath.cos(pitch) * arrowMotionFactor;
    double arrowMotion = Math.sqrt(arrowMotionX * arrowMotionX + arrowMotionY * arrowMotionY + arrowMotionZ * arrowMotionZ);
    arrowMotionX /= arrowMotion;
    arrowMotionY /= arrowMotion;
    arrowMotionZ /= arrowMotion;
    if (usingBow) {
        float bowPower = (72000 - player.getItemInUseCount()) / 20F;
        bowPower = (bowPower * bowPower + bowPower * 2F) / 3F;
        if (bowPower > 1F || bowPower <= 0.1F)
            bowPower = 1F;
        bowPower *= 3F;
        arrowMotionX *= bowPower;
        arrowMotionY *= bowPower;
        arrowMotionZ *= bowPower;
    } else {
        arrowMotionX *= 1.5D;
        arrowMotionY *= 1.5D;
        arrowMotionZ *= 1.5D;
    }
    // GL settings
    GL11.glPushMatrix();
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(false);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glLineWidth(2);
    RenderManager renderManager = mc.getRenderManager();
    // draw trajectory line
    double gravity = usingBow ? 0.05D : stack.getItem() instanceof ItemPotion ? 0.4D : stack.getItem() instanceof ItemFishingRod ? 0.15D : 0.03D;
    Vec3d playerVector = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
    GL11.glColor4f(0, 1, 0, 0.75F);
    GL11.glBegin(GL11.GL_LINE_STRIP);
    for (int i = 0; i < 1000; i++) {
        GL11.glVertex3d(arrowPosX - renderManager.renderPosX, arrowPosY - renderManager.renderPosY, arrowPosZ - renderManager.renderPosZ);
        arrowPosX += arrowMotionX * 0.1;
        arrowPosY += arrowMotionY * 0.1;
        arrowPosZ += arrowMotionZ * 0.1;
        arrowMotionX *= 0.999D;
        arrowMotionY *= 0.999D;
        arrowMotionZ *= 0.999D;
        arrowMotionY -= gravity * 0.1;
        if (WMinecraft.getWorld().rayTraceBlocks(playerVector, new Vec3d(arrowPosX, arrowPosY, arrowPosZ)) != null)
            break;
    }
    GL11.glEnd();
    // draw end of trajectory line
    double renderX = arrowPosX - renderManager.renderPosX;
    double renderY = arrowPosY - renderManager.renderPosY;
    double renderZ = arrowPosZ - renderManager.renderPosZ;
    GL11.glPushMatrix();
    GL11.glTranslated(renderX - 0.5, renderY - 0.5, renderZ - 0.5);
    GL11.glColor4f(0F, 1F, 0F, 0.25F);
    RenderUtils.drawSolidBox();
    GL11.glColor4f(0, 1, 0, 0.75F);
    RenderUtils.drawOutlinedBox();
    GL11.glPopMatrix();
    // GL resets
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(true);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glPopMatrix();
}
Also used : ItemPotion(net.minecraft.item.ItemPotion) ItemFishingRod(net.minecraft.item.ItemFishingRod) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) ItemStack(net.minecraft.item.ItemStack) ItemBow(net.minecraft.item.ItemBow) RenderManager(net.minecraft.client.renderer.entity.RenderManager) Vec3d(net.minecraft.util.math.Vec3d)

Example 89 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP in project Wurst-MC-1.12 by Wurst-Imperium.

the class StepMod method onUpdate.

@Override
public void onUpdate() {
    if (mode.getSelected() == 0) {
        // simple mode
        WMinecraft.getPlayer().stepHeight = height.getValueF();
        return;
    }
    // legit mode
    EntityPlayerSP player = WMinecraft.getPlayer();
    player.stepHeight = 0.5F;
    if (!player.isCollidedHorizontally)
        return;
    if (!player.onGround || player.isOnLadder() || player.isInWater() || player.isInLava())
        return;
    if (player.movementInput.moveForward == 0 && player.movementInput.moveStrafe == 0)
        return;
    if (player.movementInput.jump)
        return;
    AxisAlignedBB box = player.getEntityBoundingBox().offset(0, 0.05, 0).expandXyz(0.05);
    if (!WMinecraft.getWorld().getCollisionBoxes(player, box.offset(0, 1, 0)).isEmpty())
        return;
    double stepHeight = -1;
    for (AxisAlignedBB bb : WMinecraft.getWorld().getCollisionBoxes(player, box)) if (bb.maxY > stepHeight)
        stepHeight = bb.maxY;
    stepHeight = stepHeight - player.posY;
    if (stepHeight < 0 || stepHeight > 1)
        return;
    WConnection.sendPacket(new CPacketPlayer.Position(player.posX, player.posY + 0.42 * stepHeight, player.posZ, player.onGround));
    WConnection.sendPacket(new CPacketPlayer.Position(player.posX, player.posY + 0.753 * stepHeight, player.posZ, player.onGround));
    player.setPosition(player.posX, player.posY + 1 * stepHeight, player.posZ);
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) CPacketPlayer(net.minecraft.network.play.client.CPacketPlayer) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP)

Example 90 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP in project Wurst-MC-1.12 by Wurst-Imperium.

the class RepairCmd method call.

@Override
public void call(String[] args) throws CmdException {
    if (args.length > 0)
        throw new CmdSyntaxError();
    // check for creative mode
    EntityPlayerSP player = WMinecraft.getPlayer();
    if (!player.capabilities.isCreativeMode)
        throw new CmdError("Creative mode only.");
    // validate item
    ItemStack item = player.inventory.getCurrentItem();
    if (item == null)
        throw new CmdError("You need an item in your hand.");
    if (!item.isItemStackDamageable())
        throw new CmdError("This item can't take damage.");
    if (!item.isItemDamaged())
        throw new CmdError("This item is not damaged.");
    // repair item
    item.setItemDamage(0);
    WConnection.sendPacket(new CPacketCreativeInventoryAction(36 + player.inventory.currentItem, item));
}
Also used : CPacketCreativeInventoryAction(net.minecraft.network.play.client.CPacketCreativeInventoryAction) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)158 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)31 Minecraft (net.minecraft.client.Minecraft)29 ItemStack (net.minecraft.item.ItemStack)29 BlockPos (net.minecraft.util.math.BlockPos)27 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)23 Entity (net.minecraft.entity.Entity)21 EntityPlayer (net.minecraft.entity.player.EntityPlayer)13 TileEntity (net.minecraft.tileentity.TileEntity)13 WorldClient (net.minecraft.client.multiplayer.WorldClient)11 IBlockState (net.minecraft.block.state.IBlockState)10 Tessellator (net.minecraft.client.renderer.Tessellator)10 GCPlayerStatsClient (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient)8 ArrayList (java.util.ArrayList)6 Block (net.minecraft.block.Block)6 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)6 Vec3d (net.minecraft.util.math.Vec3d)6 World (net.minecraft.world.World)6 UUID (java.util.UUID)5 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)5