Search in sources :

Example 11 with EntityClientPlayerMP

use of net.minecraft.client.entity.EntityClientPlayerMP in project Minestuck by mraof.

the class ClientEditHandler method onTossEvent.

@SubscribeEvent
public void onTossEvent(ItemTossEvent event) {
    if (event.entity.worldObj.isRemote && event.player instanceof EntityClientPlayerMP && isActive()) {
        InventoryPlayer inventory = event.player.inventory;
        ItemStack stack = event.entityItem.getEntityItem();
        int ordinal = DeployList.getOrdinal(stack);
        if (ordinal >= 0) {
            if (Block.getBlockFromItem(stack.getItem()) == Blocks.air && GristHelper.canAfford(MinestuckPlayerData.getClientGrist(), Minestuck.clientHardMode && givenItems[ordinal] ? DeployList.getSecondaryCost(stack) : DeployList.getPrimaryCost(stack)))
                givenItems[ordinal] = true;
            else
                event.setCanceled(true);
        }
        if (event.isCanceled()) {
            if (inventory.getItemStack() != null)
                inventory.setItemStack(null);
            else
                inventory.setInventorySlotContents(inventory.currentItem, null);
            event.entityItem.setDead();
        }
    }
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 12 with EntityClientPlayerMP

use of net.minecraft.client.entity.EntityClientPlayerMP in project RFTools by McJty.

the class MatterBeamerRenderer method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
    ResourceLocation txt;
    boolean blending = GL11.glIsEnabled(GL11.GL_BLEND);
    Tessellator tessellator = Tessellator.instance;
    MatterBeamerTileEntity matterBeamerTileEntity = (MatterBeamerTileEntity) tileEntity;
    Coordinate destination = matterBeamerTileEntity.getDestination();
    if (destination != null) {
        int meta = tileEntity.getWorldObj().getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
        if ((meta & BlockTools.MASK_REDSTONE) != 0) {
            tessellator.startDrawingQuads();
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
            tessellator.setColorRGBA(255, 255, 255, 128);
            tessellator.setBrightness(240);
            GL11.glPushMatrix();
            this.bindTexture(redglow);
            Minecraft mc = Minecraft.getMinecraft();
            EntityClientPlayerMP p = mc.thePlayer;
            double doubleX = p.lastTickPosX + (p.posX - p.lastTickPosX) * f;
            double doubleY = p.lastTickPosY + (p.posY - p.lastTickPosY) * f;
            double doubleZ = p.lastTickPosZ + (p.posZ - p.lastTickPosZ) * f;
            GL11.glTranslated(-doubleX, -doubleY, -doubleZ);
            RenderHelper.Vector start = new RenderHelper.Vector(tileEntity.xCoord + .5f, tileEntity.yCoord + .5f, tileEntity.zCoord + .5f);
            RenderHelper.Vector end = new RenderHelper.Vector(destination.getX() + .5f, destination.getY() + .5f, destination.getZ() + .5f);
            RenderHelper.Vector player = new RenderHelper.Vector((float) doubleX, (float) doubleY, (float) doubleZ);
            RenderHelper.drawBeam(start, end, player, (meta & 1) != 0 ? .1f : .05f);
            tessellator.draw();
            GL11.glPopMatrix();
        }
    }
    Coordinate coord = new Coordinate(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
    if (coord.equals(RFTools.instance.clientInfo.getSelectedTE())) {
        txt = redglow;
    } else if (coord.equals(RFTools.instance.clientInfo.getDestinationTE())) {
        txt = blueglow;
    } else {
        txt = null;
    }
    if (txt != null) {
        this.bindTexture(txt);
        GL11.glPushMatrix();
        GL11.glTranslated(x, y, z);
        tessellator.startDrawingQuads();
        tessellator.setColorRGBA(255, 255, 255, 128);
        tessellator.setBrightness(240);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        DefaultISBRH.addSideFullTexture(tessellator, ForgeDirection.UP.ordinal(), 1.1f, -0.05f);
        DefaultISBRH.addSideFullTexture(tessellator, ForgeDirection.DOWN.ordinal(), 1.1f, -0.05f);
        DefaultISBRH.addSideFullTexture(tessellator, ForgeDirection.NORTH.ordinal(), 1.1f, -0.05f);
        DefaultISBRH.addSideFullTexture(tessellator, ForgeDirection.SOUTH.ordinal(), 1.1f, -0.05f);
        DefaultISBRH.addSideFullTexture(tessellator, ForgeDirection.WEST.ordinal(), 1.1f, -0.05f);
        DefaultISBRH.addSideFullTexture(tessellator, ForgeDirection.EAST.ordinal(), 1.1f, -0.05f);
        tessellator.draw();
        GL11.glPopMatrix();
    }
    if (!blending) {
        GL11.glDisable(GL11.GL_BLEND);
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) RenderHelper(mcjty.lib.gui.RenderHelper) Coordinate(mcjty.lib.varia.Coordinate) ResourceLocation(net.minecraft.util.ResourceLocation) Minecraft(net.minecraft.client.Minecraft)

Example 13 with EntityClientPlayerMP

use of net.minecraft.client.entity.EntityClientPlayerMP in project RFTools by McJty.

the class RenderGameOverlayEventHandler method renderBuffs.

private static void renderBuffs() {
    if (buffs == null || buffs.isEmpty()) {
        return;
    }
    EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
    PlayerPreferencesProperties properties = PlayerPreferencesProperties.getProperties(player);
    int x = properties.getPreferencesProperties().getBuffX();
    int y = properties.getPreferencesProperties().getBuffY();
    if (x == -1 || y == -1) {
        return;
    }
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(GL11.GL_LIGHTING);
    Minecraft.getMinecraft().renderEngine.bindTexture(texture);
    for (PlayerBuff buff : buffs) {
        Item item;
        switch(buff) {
            case BUFF_FEATHERFALLING:
                item = EnvironmentalSetup.featherFallingEModuleItem;
                break;
            case BUFF_FEATHERFALLINGPLUS:
                item = EnvironmentalSetup.featherFallingPlusEModuleItem;
                break;
            case BUFF_HASTE:
                item = EnvironmentalSetup.hasteEModuleItem;
                break;
            case BUFF_HASTEPLUS:
                item = EnvironmentalSetup.hastePlusEModuleItem;
                break;
            case BUFF_REGENERATION:
                item = EnvironmentalSetup.regenerationEModuleItem;
                break;
            case BUFF_REGENERATIONPLUS:
                item = EnvironmentalSetup.regenerationPlusEModuleItem;
                break;
            case BUFF_SATURATION:
                item = EnvironmentalSetup.saturationEModuleItem;
                break;
            case BUFF_SATURATIONPLUS:
                item = EnvironmentalSetup.saturationPlusEModuleItem;
                break;
            case BUFF_SPEED:
                item = EnvironmentalSetup.speedEModuleItem;
                break;
            case BUFF_SPEEDPLUS:
                item = EnvironmentalSetup.speedPlusEModuleItem;
                break;
            case BUFF_FLIGHT:
                item = EnvironmentalSetup.flightEModuleItem;
                break;
            case BUFF_PEACEFUL:
                item = EnvironmentalSetup.peacefulEModuleItem;
                break;
            case BUFF_WATERBREATHING:
                item = EnvironmentalSetup.waterBreathingEModuleItem;
                break;
            case BUFF_NIGHTVISION:
                item = EnvironmentalSetup.nightVisionEModuleItem;
                break;
            case BUFF_BLINDNESS:
                item = EnvironmentalSetup.blindnessEModuleItem;
                break;
            case BUFF_WEAKNESS:
                item = EnvironmentalSetup.weaknessEModuleItem;
                break;
            case BUFF_POISON:
                item = EnvironmentalSetup.poisonEModuleItem;
                break;
            case BUFF_SLOWNESS:
                item = EnvironmentalSetup.slownessEModuleItem;
                break;
            default:
                item = null;
        }
        if (item != null) {
            IIcon icon = item.getIconFromDamage(0);
            RenderHelper.renderIcon(Minecraft.getMinecraft(), itemRender, icon, x, y, false);
            x += BUFF_ICON_SIZE;
        }
    }
}
Also used : Item(net.minecraft.item.Item) RenderItem(net.minecraft.client.renderer.entity.RenderItem) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) IIcon(net.minecraft.util.IIcon) PlayerPreferencesProperties(mcjty.lib.preferences.PlayerPreferencesProperties)

Example 14 with EntityClientPlayerMP

use of net.minecraft.client.entity.EntityClientPlayerMP in project RFTools by McJty.

the class DimensionMonitorItem method getIconIndex.

@SideOnly(Side.CLIENT)
@Override
public IIcon getIconIndex(ItemStack stack) {
    EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
    int id = player.worldObj.provider.dimensionId;
    DimensionStorage storage = DimensionStorage.getDimensionStorage(player.worldObj);
    int energyLevel = storage.getEnergyLevel(id);
    int level = (9 * energyLevel) / DimletConfiguration.MAX_DIMENSION_POWER;
    if (level < 0) {
        level = 0;
    } else if (level > 8) {
        level = 8;
    }
    return powerLevel[8 - level];
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 15 with EntityClientPlayerMP

use of net.minecraft.client.entity.EntityClientPlayerMP in project RFTools by McJty.

the class RenderWorldLastEventHandler method renderProtectedBlocks.

private static void renderProtectedBlocks(RenderWorldLastEvent evt) {
    Minecraft mc = Minecraft.getMinecraft();
    EntityClientPlayerMP p = mc.thePlayer;
    ItemStack heldItem = p.getHeldItem();
    if (heldItem == null) {
        return;
    }
    if (heldItem.getItem() == ModItems.smartWrenchItem) {
        if (SmartWrenchItem.getCurrentMode(heldItem) == SmartWrenchMode.MODE_SELECT) {
            GlobalCoordinate current = SmartWrenchItem.getCurrentBlock(heldItem);
            if (current != null) {
                if (current.getDimension() == mc.theWorld.provider.dimensionId) {
                    TileEntity te = mc.theWorld.getTileEntity(current.getCoordinate().getX(), current.getCoordinate().getY(), current.getCoordinate().getZ());
                    if (te instanceof BlockProtectorTileEntity) {
                        BlockProtectorTileEntity blockProtectorTileEntity = (BlockProtectorTileEntity) te;
                        Set<Coordinate> coordinates = blockProtectorTileEntity.getProtectedBlocks();
                        if (!coordinates.isEmpty()) {
                            renderHighlightedBlocks(evt, p, new Coordinate(te.xCoord, te.yCoord, te.zCoord), coordinates);
                        }
                    }
                }
            }
        }
    } else if (heldItem.getItem() == ModItems.shapeCardItem) {
        int mode = ShapeCardItem.getMode(heldItem);
        if (mode == ShapeCardItem.MODE_CORNER1 || mode == ShapeCardItem.MODE_CORNER2) {
            GlobalCoordinate current = ShapeCardItem.getCurrentBlock(heldItem);
            if (current != null && current.getDimension() == mc.theWorld.provider.dimensionId) {
                Set<Coordinate> coordinates = new HashSet<Coordinate>();
                coordinates.add(new Coordinate(0, 0, 0));
                if (mode == ShapeCardItem.MODE_CORNER2) {
                    Coordinate cur = current.getCoordinate();
                    Coordinate c = ShapeCardItem.getCorner1(heldItem);
                    if (c != null) {
                        coordinates.add(new Coordinate(c.getX() - cur.getX(), c.getY() - cur.getY(), c.getZ() - cur.getZ()));
                    }
                }
                renderHighlightedBlocks(evt, p, current.getCoordinate(), coordinates);
            }
        }
    }
}
Also used : BlockProtectorTileEntity(mcjty.rftools.blocks.blockprotector.BlockProtectorTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) BlockProtectorTileEntity(mcjty.rftools.blocks.blockprotector.BlockProtectorTileEntity) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) Set(java.util.Set) HashSet(java.util.HashSet) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft)

Aggregations

EntityClientPlayerMP (net.minecraft.client.entity.EntityClientPlayerMP)34 Minecraft (net.minecraft.client.Minecraft)8 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)7 ItemStack (net.minecraft.item.ItemStack)6 SideOnly (cpw.mods.fml.relauncher.SideOnly)5 Coordinate (mcjty.lib.varia.Coordinate)3 Tessellator (net.minecraft.client.renderer.Tessellator)3 Item (net.minecraft.item.Item)3 TileEntity (net.minecraft.tileentity.TileEntity)3 GlobalCoordinate (mcjty.lib.varia.GlobalCoordinate)2 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)2 GuiScreen (net.minecraft.client.gui.GuiScreen)2 ClickEvent (net.minecraft.event.ClickEvent)2 HoverEvent (net.minecraft.event.HoverEvent)2 ChatComponentText (net.minecraft.util.ChatComponentText)2 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)2 World (net.minecraft.world.World)2 Vector3 (WayofTime.alchemicalWizardry.api.Vector3)1 IMasterRitualStone (WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone)1 RitualComponent (WayofTime.alchemicalWizardry.api.rituals.RitualComponent)1