Search in sources :

Example 1 with ResourceLocation

use of net.minecraft.util.ResourceLocation in project LogisticsPipes by RS485.

the class FluidContainerRenderer method doRenderFluid.

public void doRenderFluid(FluidStack liquid, Minecraft mc, ItemRenderType type, Object[] data) {
    GL11.glPushMatrix();
    if (type == ItemRenderType.ENTITY) {
        GL11.glRotatef(((((EntityItem) data[1]).age) / 20.0F + ((EntityItem) data[1]).hoverStart) * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F);
        GL11.glScaled(0.063, 0.065, 1);
        GL11.glTranslated(-8, -4, -0.02);
    }
    GL11.glDisable(GL11.GL_LIGHTING);
    ResourceLocation resourcelocation = mc.renderEngine.getResourceLocation(liquid.getFluid().getSpriteNumber());
    mc.renderEngine.bindTexture(resourcelocation);
    int i1 = liquid.getFluid().getColor();
    float f = (i1 >> 16 & 255) / 255.0F;
    float f1 = (i1 >> 8 & 255) / 255.0F;
    float f2 = (i1 & 255) / 255.0F;
    GL11.glColor4f(f, f1, f2, 1.0F);
    IIcon icon = liquid.getFluid().getIcon();
    if (icon != null) {
        renderIcon(5, 2, icon, 6, 12, 0);
        if (type == ItemRenderType.ENTITY) {
            GL11.glPopMatrix();
            GL11.glPushMatrix();
            GL11.glRotatef(((((EntityItem) data[1]).age) / 20.0F + ((EntityItem) data[1]).hoverStart) * (180F / (float) Math.PI) + 180, 0.0F, 1.0F, 0.0F);
            GL11.glScaled(0.063, 0.065, 1);
            GL11.glTranslated(-8, -4, -0.042);
            renderIcon(5, 2, icon, 6, 12, 0);
        }
    }
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
}
Also used : IIcon(net.minecraft.util.IIcon) ResourceLocation(net.minecraft.util.ResourceLocation) EntityItem(net.minecraft.entity.item.EntityItem)

Example 2 with ResourceLocation

use of net.minecraft.util.ResourceLocation in project LogisticsPipes by RS485.

the class LogisticsNewRenderPipe method renderList.

private void renderList(TileEntity subTile, double x, double y, double z, GLRenderList renderList, List<RenderEntry> cachedRenderer, boolean recalculateList) {
    if (!renderList.isFilled() || recalculateList) {
        ResourceLocation oldTexture = null;
        renderList.startListCompile();
        SimpleServiceLocator.cclProxy.getRenderState().reset();
        SimpleServiceLocator.cclProxy.getRenderState().setUseNormals(true);
        SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0xff);
        int brightness = new DoubleCoordinates(subTile).getBlock(subTile.getWorldObj()).getMixedBrightnessForBlock(subTile.getWorldObj(), subTile.xCoord, subTile.yCoord, subTile.zCoord);
        SimpleServiceLocator.cclProxy.getRenderState().setBrightness(brightness);
        boolean tesselating = false;
        for (RenderEntry model : cachedRenderer) {
            ResourceLocation texture = model.getTexture();
            if (texture == null) {
                throw new NullPointerException();
            }
            if (texture != oldTexture || oldTexture == null) {
                if (tesselating) {
                    SimpleServiceLocator.cclProxy.getRenderState().draw();
                    tesselating = false;
                }
                oldTexture = texture;
                Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
                SimpleServiceLocator.cclProxy.getRenderState().reset();
                SimpleServiceLocator.cclProxy.getRenderState().setUseNormals(true);
                SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0xff);
                SimpleServiceLocator.cclProxy.getRenderState().setBrightness(brightness);
                SimpleServiceLocator.cclProxy.getRenderState().startDrawing();
                tesselating = true;
            }
            model.getModel().render(model.getOperations());
        }
        if (tesselating) {
            SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0xff);
            SimpleServiceLocator.cclProxy.getRenderState().draw();
        }
        renderList.stopCompile();
    }
    if (renderList != null) {
        GL11.glPushMatrix();
        GL11.glTranslated(x, y, z);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ZERO);
        renderList.render();
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glPopMatrix();
    }
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 3 with ResourceLocation

use of net.minecraft.util.ResourceLocation 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 4 with ResourceLocation

use of net.minecraft.util.ResourceLocation in project LogisticsPipes by RS485.

the class GuiCheckBox method drawButton.

/**
	 * Draws this button to the screen.
	 */
@Override
public void drawButton(Minecraft minecraft, int par2, int par3) {
    if (visible) {
        boolean var5 = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height;
        int var6 = getHoverState(var5);
        //GL11.glBindTexture(GL11.GL_TEXTURE_2D, minecraft.renderEngine.getTexture("/logisticspipes/gui/checkbox-" + (state?"on":"out") + "" + (var6 == 2?"-mouse":"") + ".png"));
        minecraft.renderEngine.bindTexture(new ResourceLocation("logisticspipes", "textures/gui/checkbox-" + (state ? "on" : "out") + "" + (var6 == 2 ? "-mouse" : "") + ".png"));
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        Tessellator var9 = Tessellator.instance;
        var9.startDrawingQuads();
        var9.addVertexWithUV(xPosition, yPosition + height, zLevel, 0, 1);
        var9.addVertexWithUV(xPosition + width, yPosition + height, zLevel, 1, 1);
        var9.addVertexWithUV(xPosition + width, yPosition, zLevel, 1, 0);
        var9.addVertexWithUV(xPosition, yPosition, zLevel, 0, 0);
        var9.draw();
        /*
			            drawTexturedModalRect(xPosition  			, yPosition				, 0		, 0 ,0);
			            drawTexturedModalRect(xPosition + width / 2	, yPosition				, 0		, 1, 0);

			            drawTexturedModalRect(xPosition  			, yPosition + height / 2, 0		, 0 ,1);
			            drawTexturedModalRect(xPosition + width / 2	, yPosition + height / 2, 0		, 1, 1);
			 */
        mouseDragged(minecraft, par2, par3);
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 5 with ResourceLocation

use of net.minecraft.util.ResourceLocation in project malmo by Microsoft.

the class MinecraftTypeHelper method getDrawItemFromItemStack.

/** Attempt to break the item on this itemstack into a type/variant/colour which we can use for communication with the Malmo platform.
     * @param is the ItemStack containing the item we are attempting to deconstruct.
     * @return an XML DrawItem object containing the item's type, variant, colour etc.
     */
public static DrawItem getDrawItemFromItemStack(ItemStack is) {
    if (is == null)
        return null;
    DrawItem di = new DrawItem();
    // Get unlocalised name from the stack, not the stack's item - this ensures we keep the metadata.
    String name = is.getUnlocalizedName();
    if (is.getHasSubtypes()) {
        // If the item has subtypes, then there are varieties - eg different colours, types, etc.
        // Attempt to map from these subtypes back to variant/colour.
        // Do this by decomposing the unlocalised name:
        List<String> itemParts = new ArrayList<String>(Arrays.asList(name.split("\\.")));
        if (is.getItem() instanceof ItemMonsterPlacer) {
            // Special case for eggs:
            itemParts.add(ItemMonsterPlacer.getEntityName(is));
        }
        // First part will be "tile" or "item".
        // Second part will be the item itself (eg "dyePowder" or "stainedGlass" etc).
        // Third part will be the variant, colour etc.
        Colour col = null;
        Variation var = null;
        for (int part = 2; part < itemParts.size(); part++) {
            String section = itemParts.get(part);
            // First see if this matches a colour:
            if (col == null) {
                col = attemptToGetAsColour(section);
                if (// If it wasn't a colour, check to see if it was a variant:
                col == null && var == null)
                    var = attemptToGetAsVariant(section, is);
            } else if (var == null)
                var = attemptToGetAsVariant(section, is);
        }
        di.setColour(col);
        di.setVariant(var);
    }
    // Use the item registry name for the item - this is what we use in Types.XSD
    Object obj = Item.itemRegistry.getNameForObject(is.getItem());
    String publicName;
    if (obj instanceof ResourceLocation)
        publicName = ((ResourceLocation) obj).getResourcePath();
    else
        publicName = obj.toString();
    di.setType(publicName);
    return di;
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) ArrayList(java.util.ArrayList) DrawItem(com.microsoft.Malmo.Schemas.DrawItem) Variation(com.microsoft.Malmo.Schemas.Variation) ItemMonsterPlacer(net.minecraft.item.ItemMonsterPlacer) Colour(com.microsoft.Malmo.Schemas.Colour)

Aggregations

ResourceLocation (net.minecraft.util.ResourceLocation)272 ItemStack (net.minecraft.item.ItemStack)51 Block (net.minecraft.block.Block)47 Item (net.minecraft.item.Item)32 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)31 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)30 IBlockState (net.minecraft.block.state.IBlockState)17 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)15 ArrayList (java.util.ArrayList)14 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)14 Map (java.util.Map)11 EntityPlayer (net.minecraft.entity.player.EntityPlayer)11 ShaderLayer (blusunrize.immersiveengineering.api.shader.ShaderCase.ShaderLayer)10 IOException (java.io.IOException)10 TileEntity (net.minecraft.tileentity.TileEntity)9 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)8 EnumFacing (net.minecraft.util.EnumFacing)8 BlockPos (net.minecraft.util.math.BlockPos)8 Random (java.util.Random)7 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)7