Search in sources :

Example 1 with PlayerArmorInvWrapper

use of net.minecraftforge.items.wrapper.PlayerArmorInvWrapper in project pnc-repressurized by TeamPneumatic.

the class AreaShowManager method renderWorldLastEvent.

@SubscribeEvent
public void renderWorldLastEvent(RenderWorldLastEvent event) {
    Minecraft mc = FMLClientHandler.instance().getClient();
    EntityPlayer player = mc.player;
    double playerX = player.prevPosX + (player.posX - player.prevPosX) * event.getPartialTicks();
    double playerY = player.prevPosY + (player.posY - player.prevPosY) * event.getPartialTicks();
    double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * event.getPartialTicks();
    GlStateManager.pushMatrix();
    GlStateManager.translate(-playerX, -playerY, -playerZ);
    GlStateManager.disableTexture2D();
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    for (AreaShowHandler handler : showHandlers.values()) {
        handler.render();
    }
    ItemStack curItem = player.getHeldItemMainhand();
    if (curItem.getItem() instanceof IPositionProvider) {
        IPositionProvider positionProvider = (IPositionProvider) curItem.getItem();
        List<BlockPos> posList = positionProvider.getStoredPositions(curItem);
        if (posList != null) {
            if (!posList.equals(cachedPositionProviderData)) {
                // Cache miss
                TIntObjectMap<Set<BlockPos>> colorsToPositions = new TIntObjectHashMap<>();
                for (int i = 0; i < posList.size(); i++) {
                    int renderColor = positionProvider.getRenderColor(i);
                    if (posList.get(i) != null && renderColor != 0) {
                        Set<BlockPos> positionsForColor = colorsToPositions.get(renderColor);
                        if (positionsForColor == null) {
                            positionsForColor = new HashSet<BlockPos>();
                            colorsToPositions.put(renderColor, positionsForColor);
                        }
                        positionsForColor.add(posList.get(i));
                    }
                }
                cachedPositionProviderData = posList;
                cachedPositionProviderShowers = new ArrayList<>(colorsToPositions.size());
                colorsToPositions.forEachEntry((color, positions) -> {
                    cachedPositionProviderShowers.add(new AreaShowHandler(positions, color, positionProvider.disableDepthTest()));
                    return true;
                });
            }
            cachedPositionProviderShowers.forEach(AreaShowHandler::render);
        }
    } else if (curItem.getItem() == Itemss.CAMO_APPLICATOR) {
        Set<BlockPos> posSet = CamoTECache.getCamouflageableBlockPos(world, player);
        if (!posSet.isEmpty()) {
            new AreaShowHandler(posSet, 0x2080FFFF, 0.75, true).render();
        }
    }
    if (curItem.getItem() != Itemss.CAMO_APPLICATOR)
        CamoTECache.clearCache();
    PlayerArmorInvWrapper armor = new PlayerArmorInvWrapper(player.inventory);
    ItemStack helmet = armor.getStackInSlot(3);
    if (helmet.getItem() == Itemss.PNEUMATIC_HELMET) {
        if (droneDebugger == null)
            droneDebugger = HUDHandler.instance().getSpecificRenderer(DroneDebugUpgradeHandler.class);
        Set<BlockPos> set = droneDebugger.getShowingPositions();
        new AreaShowHandler(set, 0x90FF0000, true).render();
    }
    GlStateManager.enableTexture2D();
    GlStateManager.disableBlend();
    GlStateManager.popMatrix();
}
Also used : PlayerArmorInvWrapper(net.minecraftforge.items.wrapper.PlayerArmorInvWrapper) Minecraft(net.minecraft.client.Minecraft) IPositionProvider(me.desht.pneumaticcraft.api.item.IPositionProvider) TIntObjectHashMap(gnu.trove.map.hash.TIntObjectHashMap) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

TIntObjectHashMap (gnu.trove.map.hash.TIntObjectHashMap)1 IPositionProvider (me.desht.pneumaticcraft.api.item.IPositionProvider)1 Minecraft (net.minecraft.client.Minecraft)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 BlockPos (net.minecraft.util.math.BlockPos)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 PlayerArmorInvWrapper (net.minecraftforge.items.wrapper.PlayerArmorInvWrapper)1