Search in sources :

Example 26 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project LogisticsPipes by RS485.

the class RenderTickHandler method renderWorldLast.

//private static final ResourceLocation TEXTURE = new ResourceLocation("logisticspipes", "textures/blocks/pipes/White.png");
@SubscribeEvent
public void renderWorldLast(RenderWorldLastEvent worldEvent) {
    if (LogisticsRenderPipe.config.isUseNewRenderer()) {
        if (displayPipeGhost()) {
            Minecraft mc = Minecraft.getMinecraft();
            EntityPlayer player = mc.thePlayer;
            MovingObjectPosition box = mc.objectMouseOver;
            if (box != null && box.typeOfHit == MovingObjectType.BLOCK) {
                ItemStack stack = FMLClientHandler.instance().getClient().thePlayer.inventory.mainInventory[FMLClientHandler.instance().getClient().thePlayer.inventory.currentItem];
                CoreUnroutedPipe pipe = ((ItemLogisticsPipe) stack.getItem()).getDummyPipe();
                int i = box.blockX;
                int j = box.blockY;
                int k = box.blockZ;
                World world = player.getEntityWorld();
                int side = box.sideHit;
                Block worldBlock = world.getBlock(i, j, k);
                if (worldBlock == Blocks.snow) {
                    side = 1;
                } else if (worldBlock != Blocks.vine && worldBlock != Blocks.tallgrass && worldBlock != Blocks.deadbush && (worldBlock == null || !worldBlock.isReplaceable(world, i, j, k))) {
                    if (side == 0) {
                        j--;
                    }
                    if (side == 1) {
                        j++;
                    }
                    if (side == 2) {
                        k--;
                    }
                    if (side == 3) {
                        k++;
                    }
                    if (side == 4) {
                        i--;
                    }
                    if (side == 5) {
                        i++;
                    }
                }
                double xCoord = i;
                double yCoord = j;
                double zCoord = k;
                boolean isFreeSpace = true;
                ITubeOrientation orientation = null;
                if (pipe instanceof CoreMultiBlockPipe) {
                    CoreMultiBlockPipe multipipe = (CoreMultiBlockPipe) pipe;
                    DoubleCoordinates placeAt = new DoubleCoordinates(xCoord, yCoord, zCoord);
                    LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> globalPos = new LPPositionSet<>(DoubleCoordinatesType.class);
                    globalPos.add(new DoubleCoordinatesType<>(placeAt, CoreMultiBlockPipe.SubBlockTypeForShare.NON_SHARE));
                    LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> positions = multipipe.getSubBlocks();
                    orientation = multipipe.getTubeOrientation(player, (int) xCoord, (int) zCoord);
                    if (orientation != null) {
                        orientation.rotatePositions(positions);
                        positions.stream().map(pos -> pos.add(placeAt)).forEach(globalPos::add);
                        globalPos.addToAll(orientation.getOffset());
                        for (DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare> pos : globalPos) {
                            if (!player.getEntityWorld().canPlaceEntityOnSide(LogisticsPipes.LogisticsPipeBlock, pos.getXInt(), pos.getYInt(), pos.getZInt(), false, side, player, stack)) {
                                TileEntity tile = player.getEntityWorld().getTileEntity(pos.getXInt(), pos.getYInt(), pos.getZInt());
                                boolean canPlace = false;
                                if (tile instanceof LogisticsTileGenericSubMultiBlock) {
                                    if (CoreMultiBlockPipe.canShare(((LogisticsTileGenericSubMultiBlock) tile).getSubTypes(), pos.getType())) {
                                        canPlace = true;
                                    }
                                }
                                if (!canPlace) {
                                    isFreeSpace = false;
                                    break;
                                }
                            }
                        }
                    } else {
                        return;
                    }
                } else {
                    if (!player.getEntityWorld().canPlaceEntityOnSide(LogisticsPipes.LogisticsPipeBlock, i, j, k, false, side, player, stack)) {
                        isFreeSpace = false;
                    }
                }
                if (isFreeSpace) {
                    GL11.glPushMatrix();
                    double x;
                    double y;
                    double z;
                    if (orientation != null) {
                        x = xCoord + orientation.getOffset().getXInt() - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.partialTicks);
                        y = yCoord + orientation.getOffset().getYInt() - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.partialTicks);
                        z = zCoord + orientation.getOffset().getZInt() - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.partialTicks);
                    } else {
                        x = xCoord - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.partialTicks);
                        y = yCoord - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.partialTicks);
                        z = zCoord - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.partialTicks);
                    }
                    GL11.glTranslated(x + 0.001, y + 0.001, z + 0.001);
                    GL11.glEnable(GL11.GL_BLEND);
                    //GL11.glDepthMask(false);
                    GL11.glDisable(GL11.GL_TEXTURE_2D);
                    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                    mc.renderEngine.bindTexture(new ResourceLocation("logisticspipes", "textures/blocks/pipes/White.png"));
                    Tessellator tess = Tessellator.instance;
                    CCRenderState.reset();
                    CCRenderState.useNormals = true;
                    CCRenderState.alphaOverride = 0xff;
                    GL11.glEnable(GL11.GL_TEXTURE_2D);
                    CCRenderState.alphaOverride = 0x50;
                    CCRenderState.useNormals = true;
                    CCRenderState.hasBrightness = false;
                    CCRenderState.startDrawing();
                    pipe.getHighlightRenderer().renderHighlight(orientation);
                    tess.draw();
                    CCRenderState.alphaOverride = 0xff;
                    GL11.glDisable(GL11.GL_BLEND);
                    GL11.glDepthMask(true);
                    GL11.glPopMatrix();
                }
            }
        }
    }
}
Also used : ItemLogisticsPipe(logisticspipes.items.ItemLogisticsPipe) EventPriority(cpw.mods.fml.common.eventhandler.EventPriority) Blocks(net.minecraft.init.Blocks) DoubleCoordinatesType(network.rs485.logisticspipes.world.DoubleCoordinatesType) LogisticsPipes(logisticspipes.LogisticsPipes) ActiveRenderInfo(net.minecraft.client.renderer.ActiveRenderInfo) RenderWorldLastEvent(net.minecraftforge.client.event.RenderWorldLastEvent) RenderTickEvent(cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent) ItemStack(net.minecraft.item.ItemStack) Block(net.minecraft.block.Block) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) LogisticsHUDRenderer(logisticspipes.renderer.LogisticsHUDRenderer) Minecraft(net.minecraft.client.Minecraft) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) LogisticsGuiOverrenderer(logisticspipes.renderer.LogisticsGuiOverrenderer) ClientViewController(logisticspipes.routing.debug.ClientViewController) CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) LogisticsRenderPipe(logisticspipes.renderer.LogisticsRenderPipe) FMLClientHandler(cpw.mods.fml.client.FMLClientHandler) Core(tv.twitch.Core) GL11(org.lwjgl.opengl.GL11) CoreMultiBlockPipe(logisticspipes.pipes.basic.CoreMultiBlockPipe) CCRenderState(codechicken.lib.render.CCRenderState) World(net.minecraft.world.World) ITubeOrientation(logisticspipes.interfaces.ITubeOrientation) CoordinateUtils(network.rs485.logisticspipes.world.CoordinateUtils) Phase(cpw.mods.fml.common.gameevent.TickEvent.Phase) LPPositionSet(logisticspipes.utils.LPPositionSet) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) Tessellator(net.minecraft.client.renderer.Tessellator) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) ResourceLocation(net.minecraft.util.ResourceLocation) TileEntity(net.minecraft.tileentity.TileEntity) MovingObjectType(net.minecraft.util.MovingObjectPosition.MovingObjectType) Tessellator(net.minecraft.client.renderer.Tessellator) World(net.minecraft.world.World) TileEntity(net.minecraft.tileentity.TileEntity) CoreMultiBlockPipe(logisticspipes.pipes.basic.CoreMultiBlockPipe) ResourceLocation(net.minecraft.util.ResourceLocation) ItemLogisticsPipe(logisticspipes.items.ItemLogisticsPipe) CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) ITubeOrientation(logisticspipes.interfaces.ITubeOrientation) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) Minecraft(net.minecraft.client.Minecraft) DoubleCoordinatesType(network.rs485.logisticspipes.world.DoubleCoordinatesType) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) LPPositionSet(logisticspipes.utils.LPPositionSet) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 27 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project SimplyJetpacks by Tonius.

the class RenderUtils method getArmorModel.

public static ModelBiped getArmorModel(PackBase pack, EntityLivingBase entity) {
    ModelBiped model = null;
    switch(pack.armorModel) {
        case JETPACK:
            model = ModelJetpack.INSTANCE;
            break;
        case FLUX_PACK:
            model = ModelFluxPack.INSTANCE;
        default:
    }
    if (model == null) {
        return null;
    }
    model.isSneak = entity.isSneaking();
    model.isRiding = entity.isRiding();
    model.isChild = entity.isChild();
    model.heldItemRight = entity.getEquipmentInSlot(0) != null ? 1 : 0;
    if (entity instanceof EntityPlayer) {
        model.aimedBow = ((EntityPlayer) entity).getItemInUseDuration() > 2;
    }
    return model;
}
Also used : ModelBiped(net.minecraft.client.model.ModelBiped) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 28 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project SimplyJetpacks by Tonius.

the class Jetpack method flyUser.

public void flyUser(EntityLivingBase user, ItemStack stack, ItemPack item, boolean force) {
    if (this.isOn(stack)) {
        boolean hoverMode = this.isHoverModeOn(stack);
        double hoverSpeed = Config.invertHoverSneakingBehavior == SyncHandler.isDescendKeyDown(user) ? this.speedVerticalHoverSlow : this.speedVerticalHover;
        boolean flyKeyDown = force || SyncHandler.isFlyKeyDown(user);
        boolean descendKeyDown = SyncHandler.isDescendKeyDown(user);
        double currentAccel = this.accelVertical * (user.motionY < 0.3D ? 2.5D : 1.0D);
        double currentSpeedVertical = this.speedVertical * (user.isInWater() ? 0.4D : 1.0D);
        if (flyKeyDown || hoverMode && !user.onGround) {
            if (this.usesFuel) {
                item.useFuel(stack, (int) (user.isSprinting() ? Math.round(this.getFuelUsage(stack) * this.sprintFuelModifier) : this.getFuelUsage(stack)), false);
            }
            if (item.getFuelStored(stack) > 0) {
                if (flyKeyDown) {
                    if (!hoverMode) {
                        user.motionY = Math.min(user.motionY + currentAccel, currentSpeedVertical);
                    } else {
                        if (descendKeyDown) {
                            user.motionY = Math.min(user.motionY + currentAccel, -this.speedVerticalHoverSlow);
                        } else {
                            user.motionY = Math.min(user.motionY + currentAccel, this.speedVerticalHover);
                        }
                    }
                } else {
                    user.motionY = Math.min(user.motionY + currentAccel, -hoverSpeed);
                }
                float speedSideways = (float) (user.isSneaking() ? this.speedSideways * 0.5F : this.speedSideways);
                float speedForward = (float) (user.isSprinting() ? speedSideways * this.sprintSpeedModifier : speedSideways);
                if (SyncHandler.isForwardKeyDown(user)) {
                    user.moveFlying(0, speedForward, speedForward);
                }
                if (SyncHandler.isBackwardKeyDown(user)) {
                    user.moveFlying(0, -speedSideways, speedSideways * 0.8F);
                }
                if (SyncHandler.isLeftKeyDown(user)) {
                    user.moveFlying(speedSideways, 0, speedSideways);
                }
                if (SyncHandler.isRightKeyDown(user)) {
                    user.moveFlying(-speedSideways, 0, speedSideways);
                }
                if (!user.worldObj.isRemote) {
                    user.fallDistance = 0.0F;
                    if (user instanceof EntityPlayerMP) {
                        ((EntityPlayerMP) user).playerNetServerHandler.floatingTickCount = 0;
                    }
                    if (Config.flammableFluidsExplode) {
                        if (!(user instanceof EntityPlayer) || !((EntityPlayer) user).capabilities.isCreativeMode) {
                            int x = Math.round((float) user.posX - 0.5F);
                            int y = Math.round((float) user.posY);
                            int z = Math.round((float) user.posZ - 0.5F);
                            Block fluidBlock = user.worldObj.getBlock(x, y, z);
                            if (fluidBlock instanceof IFluidBlock && fluidBlock.isFlammable(user.worldObj, x, y, z, ForgeDirection.UNKNOWN)) {
                                user.worldObj.playSoundAtEntity(user, "mob.ghast.fireball", 2.0F, 1.0F);
                                user.worldObj.createExplosion(user, user.posX, user.posY, user.posZ, 3.5F, false);
                                user.attackEntityFrom(new EntityDamageSource("jetpackexplode", user), 100.0F);
                            }
                        }
                    }
                }
            }
        }
    }
    if (!user.worldObj.isRemote && this.emergencyHoverMode && this.isEHoverOn(stack)) {
        if (item.getEnergyStored(stack) > 0 && (!this.isHoverModeOn(stack) || !this.isOn(stack))) {
            if (user.posY < -5) {
                this.doEHover(stack, user);
            } else if (user instanceof EntityPlayer) {
                if (!((EntityPlayer) user).capabilities.isCreativeMode && user.fallDistance - 1.2F >= user.getHealth()) {
                    for (int i = 0; i <= 16; i++) {
                        int x = Math.round((float) user.posX - 0.5F);
                        int y = Math.round((float) user.posY) - i;
                        int z = Math.round((float) user.posZ - 0.5F);
                        if (!user.worldObj.isAirBlock(x, y, z)) {
                            this.doEHover(stack, user);
                            break;
                        }
                    }
                }
            }
        }
    }
}
Also used : IFluidBlock(net.minecraftforge.fluids.IFluidBlock) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) EntityDamageSource(net.minecraft.util.EntityDamageSource)

Example 29 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project SimplyJetpacks by Tonius.

the class JetpackPotato method flyUser.

@Override
public void flyUser(EntityLivingBase user, ItemStack stack, ItemPack item, boolean force) {
    if (this.isFired(stack)) {
        super.flyUser(user, stack, item, true);
        user.rotationYawHead += 37.5F;
        if (item.getFuelStored(stack) <= 0) {
            user.setCurrentItemOrArmor(3, null);
            if (!user.worldObj.isRemote) {
                user.worldObj.createExplosion(user, user.posX, user.posY, user.posZ, 4.0F, false);
                for (int i = 0; i <= MathHelper.RANDOM.nextInt(3) + 4; i++) {
                    ItemStack firework = FireworksHelper.getRandomFireworks(0, 1, MathHelper.RANDOM.nextInt(6) + 1, 1);
                    user.worldObj.spawnEntityInWorld(new EntityFireworkRocket(user.worldObj, user.posX + MathHelper.RANDOM.nextDouble() * 6.0D - 3.0D, user.posY, user.posZ + MathHelper.RANDOM.nextDouble() * 6.0D - 3.0D, firework));
                }
                user.attackEntityFrom(new EntityDamageSource("jetpackpotato", user), 100.0F);
                if (user instanceof EntityPlayer) {
                    user.dropItem(Items.baked_potato, 1);
                }
            }
        }
    } else {
        if (force || SyncHandler.isFlyKeyDown(user)) {
            if (this.isTimerSet(stack)) {
                this.decrementTimer(stack, user);
            } else {
                this.setTimer(stack, 50);
            }
        }
    }
}
Also used : EntityFireworkRocket(net.minecraft.entity.item.EntityFireworkRocket) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) EntityDamageSource(net.minecraft.util.EntityDamageSource)

Example 30 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project malmo by Microsoft.

the class MovingTargetDecoratorImplementation method pinchedByPlayer.

private boolean pinchedByPlayer(World world) {
    for (BlockPos bp : this.path) {
        //Block b = world.getBlockState(bp).getBlock();
        //AxisAlignedBB aabb = b.getCollisionBoundingBox(world, bp, b.getDefaultState());
        //aabb.expand(0, 1, 0);
        BlockPos bp2 = new BlockPos(bp.getX() + 1, bp.getY() + 2, bp.getZ() + 1);
        AxisAlignedBB aabb = new AxisAlignedBB(bp, bp2);
        List<Entity> entities = world.getEntitiesWithinAABBExcludingEntity(null, aabb);
        for (Entity ent : entities) if (ent instanceof EntityPlayer)
            return true;
    }
    return false;
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) Entity(net.minecraft.entity.Entity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.BlockPos)

Aggregations

EntityPlayer (net.minecraft.entity.player.EntityPlayer)524 ItemStack (net.minecraft.item.ItemStack)141 EntityLivingBase (net.minecraft.entity.EntityLivingBase)95 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)68 Entity (net.minecraft.entity.Entity)64 BlockPos (net.minecraft.util.math.BlockPos)53 World (net.minecraft.world.World)50 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)42 TileEntity (net.minecraft.tileentity.TileEntity)36 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)34 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)34 ArrayList (java.util.ArrayList)33 EntityItem (net.minecraft.entity.item.EntityItem)31 PotionEffect (net.minecraft.potion.PotionEffect)28 Block (net.minecraft.block.Block)25 IBlockState (net.minecraft.block.state.IBlockState)24 List (java.util.List)23 TextComponentString (net.minecraft.util.text.TextComponentString)23 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)20 WrongUsageException (net.minecraft.command.WrongUsageException)19