Search in sources :

Example 1 with IPositionProvider

use of me.desht.pneumaticcraft.api.item.IPositionProvider 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)

Example 2 with IPositionProvider

use of me.desht.pneumaticcraft.api.item.IPositionProvider in project pnc-repressurized by TeamPneumatic.

the class GuiAmadronAddTrade method actionPerformed.

@Override
public void actionPerformed(IGuiWidget widget) {
    if (widget.getID() == 6 || widget.getID() == 7) {
        gpsSearchGui = new GuiInventorySearcher(FMLClientHandler.instance().getClientPlayerEntity());
        gpsSearchGui.setStackPredicate(itemStack -> itemStack.getItem() instanceof IPositionProvider);
        isSettingInput = widget.getID() == 6;
        ItemStack gps = new ItemStack(Itemss.GPS_TOOL);
        BlockPos pos;
        if (widget.getID() == 6) {
            pos = getInputPosition();
        } else {
            pos = getOutputPosition();
        }
        if (pos != null)
            ItemGPSTool.setGPSLocation(gps, pos);
        gpsSearchGui.setSearchStack(ItemGPSTool.getGPSLocation(gps) != null ? gps : ItemStack.EMPTY);
        FMLClientHandler.instance().showGuiScreen(gpsSearchGui);
    }
    super.actionPerformed(widget);
}
Also used : IPositionProvider(me.desht.pneumaticcraft.api.item.IPositionProvider) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Example 3 with IPositionProvider

use of me.desht.pneumaticcraft.api.item.IPositionProvider in project pnc-repressurized by TeamPneumatic.

the class GuiProgWidgetArea method actionPerformed.

@Override
public void actionPerformed(GuiButton button) throws IOException {
    if (button.id == 0 || button.id == 1) {
        invSearchGui = new GuiInventorySearcher(FMLClientHandler.instance().getClient().player);
        invSearchGui.setStackPredicate(itemStack -> itemStack.getItem() instanceof IPositionProvider);
        ItemStack gps = new ItemStack(Itemss.GPS_TOOL);
        if (button.id == 0) {
            ItemGPSTool.setGPSLocation(gps, new BlockPos(widget.x1, widget.y1, widget.z1));
        } else {
            ItemGPSTool.setGPSLocation(gps, new BlockPos(widget.x2, widget.y2, widget.z2));
        }
        invSearchGui.setSearchStack(ItemGPSTool.getGPSLocation(gps) != null ? gps : ItemStack.EMPTY);
        FMLClientHandler.instance().showGuiScreen(invSearchGui);
        pointSearched = button.id;
    }
    if (button.id == 1000) {
        // When the area is going to be displayed.
        saveWidgets();
    }
    super.actionPerformed(button);
}
Also used : IPositionProvider(me.desht.pneumaticcraft.api.item.IPositionProvider) GuiInventorySearcher(me.desht.pneumaticcraft.client.gui.GuiInventorySearcher) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Example 4 with IPositionProvider

use of me.desht.pneumaticcraft.api.item.IPositionProvider in project pnc-repressurized by TeamPneumatic.

the class GuiProgWidgetCoordinate method actionPerformed.

@Override
public void actionPerformed(GuiButton button) throws IOException {
    if (button.id == 0) {
        invSearchGui = new GuiInventorySearcher(FMLClientHandler.instance().getClient().player);
        invSearchGui.setStackPredicate(itemStack -> itemStack.getItem() instanceof IPositionProvider);
        BlockPos area = widget.getRawCoordinate();
        ItemStack gps = new ItemStack(Itemss.GPS_TOOL);
        ItemGPSTool.setGPSLocation(gps, area);
        invSearchGui.setSearchStack(ItemGPSTool.getGPSLocation(gps) != null ? gps : ItemStack.EMPTY);
        FMLClientHandler.instance().showGuiScreen(invSearchGui);
    }
    super.actionPerformed(button);
}
Also used : IPositionProvider(me.desht.pneumaticcraft.api.item.IPositionProvider) GuiInventorySearcher(me.desht.pneumaticcraft.client.gui.GuiInventorySearcher) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Aggregations

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