Jump to content

xilef11

Members
  • Posts

    83
  • Joined

  • Last visited

Everything posted by xilef11

  1. yes, that's what I did at first. I tried --refresh-dependencies after to see if it would download the missing file
  2. That mostly works, but it seems that all the dependencies are not downloaded with --refresh-dependencies, because when I try to run the client (or setup the workspace on an offline computer), it complains about a missinf Forgegradle jar
  3. Hello I was wondering if anyone had managed to setup a portable modding environment? The biggest problem seems to come from the gradle cache holding the Minecraft libraries. The goal would be to have a single folder that could be carried around and used/deployed on any computer (assuming eclipse and a JDK are avaliable), even with no Internet connection. I found this article on using Sonatype Nexus, but I couldn't get it to work. Thanks
  4. In the root minecraft directory or in, say, minecraft/config?
  5. Thanks for the fast reply! Do you have suggestions for where I should put this in the minecraft folder tree? I still have a few things to fix before trying this (1.8 changed a lot of things in my code, and the compiler errors make things hard to test ) but I feel a pointer to an example of something similar would make things easier
  6. Hello I have blocks that use runtime-generated textures (with multiple "layers"), and I was wondering if I could somehow save them, since they are static textures. The idea would be to generate the .png files on the first run, and then use them as any other texture. In 1.7, I had started messing around with the tesselator and an ISimpleBlockRenderingHandler, but I found it rather tedious and buggy (my blocks should be falling blocks, but their renderer would not render them properly when falling). I think the following workflow would work, but I have no clue where to save the images, and how that would play with Minecraft's resource system. try{ //attempt to register the block with the texture }catch(whatever error is thrown when the texture dosen't exist){ //generate the image using Java's standard image processing stuff //register the block with the texture } Is this a good idea? and how do the minecraft resource system translates to the "usual" Java file/image paths?
  7. (bump...) I would guess I have to override something in EntityFallingBlock, but I can't find what
  8. Update: it seems that removing the if(**Icon==null) statments before registering the textures fixed the problem. However, when the blocks fall, they get the sand texture. is there a (hopefully simple-ish) way to fix that?
  9. the texels are either fully opaque or fully transparent, so the problem must be somewhere else... It seems that the textures are not correctly loaded, since a println of them in the renderer returns the following: TextureAtlasSprite{name='runesofwizardry:dustStorage_bg', frameCount=0, rotated=false, x=0, y=0, height=0, width=0, u0=0.0, u1=0.0, v0=0.0, v1=0.0} however, the log shows no message about a missing texture. Here is my block class: package com.zpig333.runesofwizardry.api; import net.minecraft.block.BlockFalling; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.init.Blocks; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import com.zpig333.runesofwizardry.client.render.DustStorageRenderer; import com.zpig333.runesofwizardry.core.References; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public abstract class IDustStorageBlock extends BlockFalling { //Icons for the background and foreground private static IIcon bgIcon,fgIcon; public IDustStorageBlock(Material mat){ super(mat); } /** returns the dust that forms this block **/ public abstract IDust getIDust(); @Override public int damageDropped(int i) { return i; } public IIcon getBackgroundIcon(){ return bgIcon; } public IIcon getForegroundIcon(){ return fgIcon; } //TODO finish setting up the block //TODO Icons and stuff @Override public void registerBlockIcons(IIconRegister reg) { //sand icon, used only for the particles when breaking block blockIcon = Blocks.sand.getIcon(0, 0); if(bgIcon==null||fgIcon==null){ bgIcon = reg.registerIcon(References.texture_path+"dustStorage_bg"); fgIcon = reg.registerIcon(References.texture_path+"dustStorage_fg"); } } @Override public boolean renderAsNormalBlock() { return false; } @Override public int getRenderType() { return DustStorageRenderer.getRenderID(); } }
  10. After a bit more testing, it seems the problem is my textures, since it works fine when using vanilla textures. How should transparency be handled? I currently have two png files with transparent pixels.
  11. Definitely something wrong here, But I dont know enough to say what. my guess is that it is related to either having two "faces" per block side or the transparency. screenshot: (the color is fading in and out for some reason) http://prntscr.com/5hohza also, I would be very happy if someone would explain to me how to post images on this forum...
  12. yay, I managed to get a cube rendering! making a box with the coordinates of the different corners helped a lot. however, I can't get it to render the multiple textures, and my UP face is completely black when using my custom texture (it was working when I used the sand texture) renderer: package com.zpig333.runesofwizardry.client.render; import com.zpig333.runesofwizardry.api.IDust; import com.zpig333.runesofwizardry.api.IDustStorageBlock; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.RenderingRegistry; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import org.lwjgl.opengl.GL11; public class DustStorageRenderer implements ISimpleBlockRenderingHandler{ private static int dustStorageRenderID; //following a "singleton" pattern since I don't like having a public constructor changing a static variable (could mess stuff up) private static DustStorageRenderer instance = null; private DustStorageRenderer(){ dustStorageRenderID = RenderingRegistry.getNextAvailableRenderId(); } public static int getRenderID(){ return dustStorageRenderID; } public static DustStorageRenderer getInstance(){ if(instance==null){ instance=new DustStorageRenderer(); } return instance; } @Override public void renderInventoryBlock(Block ablock, int metadata, int modelId, RenderBlocks renderer) { if (ablock instanceof IDustStorageBlock) { IDustStorageBlock block = (IDustStorageBlock) ablock; //thanks to TheGreyGhost for this https://github.com/TheGreyGhost/ItemRendering/blob/master/src/TestItemRendering/blocks/BlockPyramidRenderer.java Tessellator tes = Tessellator.instance; // if you don't perform this translation, the item won't sit in the player's hand properly in 3rd person view GL11.glTranslatef(-0.5F, -0.5F, -0.5F); // for "inventory" blocks (actually for items which are equipped, dropped, or in inventory), should render in [0,0,0] to [1,1,1] tes.startDrawingQuads(); renderDustBlock(tes, 0.0, 0.0, 0.0, metadata, block); tes.draw(); // don't forget to undo the translation you made at the start GL11.glTranslatef(0.5F, 0.5F, 0.5F); } } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block ablock, int modelId, RenderBlocks renderer) { if (ablock instanceof IDustStorageBlock) { IDustStorageBlock block = (IDustStorageBlock) ablock; Tessellator tessellator = Tessellator.instance; // world blocks should render in [x,y,z] to [x+1, y+1, z+1] // tessellator.startDrawingQuads() has already been called by the caller int lightValue = block.getMixedBrightnessForBlock(world, x, y, z); tessellator.setBrightness(lightValue); tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); renderDustBlock(tessellator, (double)x, (double)y, (double) z, world.getBlockMetadata(x, y, z), block); // tessellator.draw() will be called by the caller after return return true; } return false; } @Override public boolean shouldRender3DInInventory(int modelId) { return true; } @Override public int getRenderId() { return dustStorageRenderID; } private void renderDustBlock(Tessellator tessellator, double x, double y, double z, int meta, IDustStorageBlock block) { //TODO most of the work: renderDustBlock IDust dust = block.getIDust(); ItemStack dustStack = new ItemStack(dust,1,meta); IIcon bgIcon = block.getBackgroundIcon(); IIcon fgIcon = block.getForegroundIcon(); int primaryColor = dust.getPrimaryColor(dustStack); int secondaryColor = dust.getSecondaryColor(dustStack); //bgIcon = Blocks.sand.getIcon(0, 0); //fgIcon = Blocks.bedrock.getIcon(0, 0); double minUBG = (double) bgIcon.getMinU(); double minVBG = (double) bgIcon.getMinV(); double maxUBG = (double) bgIcon.getMaxU(); double maxVBG = (double) bgIcon.getMaxV(); //foreground texture double minUFG = (double) fgIcon.getMinU(); double minVFG = (double) fgIcon.getMinV(); double maxUFG = (double) fgIcon.getMaxU(); double maxVFG = (double) fgIcon.getMaxV(); //NOrmals: X+ = east, Y+ =up, z+ = south // east face //background color tessellator.draw();//flush tessellator.startDrawingQuads(); tessellator.setNormal(1F, 0F, 0.0F); tessellator.setColorRGBA_I(primaryColor, 0xFF); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0, maxUBG, maxVBG); tessellator.addVertexWithUV(x + 1.0, y + 1.0, z + 0, maxUBG, minVBG); tessellator.addVertexWithUV(x + 1.0, y + 1.0, z + 1, minUBG, minVBG); tessellator.addVertexWithUV(x + 1.0, y + 0, z + 1, minUBG, maxVBG); tessellator.draw(); //fg color tessellator.startDrawingQuads(); tessellator.setNormal(1F, 0F, 0.0F); tessellator.setColorRGBA_I(secondaryColor, 0xFF); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0, maxUFG, maxVFG); tessellator.addVertexWithUV(x + 1.0, y + 1.0, z + 0, maxUFG, minVFG); tessellator.addVertexWithUV(x + 1.0, y + 1.0, z + 1, minUFG, minVFG); tessellator.addVertexWithUV(x + 1.0, y + 0, z + 1, minUFG, maxVFG); tessellator.draw(); // west face tessellator.startDrawingQuads(); tessellator.setNormal(-1, 0, 0.0F); tessellator.setColorRGBA_I(primaryColor, 0xFF); tessellator.addVertexWithUV(x + 0.0, y + 0.0, z + 1.0, maxUBG, maxVBG); tessellator.addVertexWithUV(x + 0.0, y + 1.0, z + 1.0, maxUBG, minVBG); tessellator.addVertexWithUV(x + 0.0, y + 1.0, z + 0, minUBG, minVBG); tessellator.addVertexWithUV(x + 0.0, y + 0.0, z + 0.0, minUBG, maxVBG); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(-1, 0, 0.0F); tessellator.setColorRGBA_I(secondaryColor, 0xFF); tessellator.addVertexWithUV(x + 0.0, y + 0.0, z + 1.0, maxUFG, maxVFG); tessellator.addVertexWithUV(x + 0.0, y + 1.0, z + 1.0, maxUFG, minVFG); tessellator.addVertexWithUV(x + 0.0, y + 1.0, z + 0, minUFG, minVFG); tessellator.addVertexWithUV(x + 0.0, y + 0.0, z + 0.0, minUFG, maxVFG); tessellator.draw(); // north face //NOrmals: X+ = east, Y+ =up, z+ = south //background color tessellator.startDrawingQuads(); tessellator.setNormal(0, 0F, 1); tessellator.setColorRGBA_I(primaryColor, 0xFF); tessellator.addVertexWithUV(x + 0, y + 0.0, z + 0.0, maxUBG, maxVBG); tessellator.addVertexWithUV(x + 0, y + 1, z + 0.0, maxUBG, minVBG); tessellator.addVertexWithUV(x + 1, y + 1.0, z + 0, minUBG, minVBG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0, minUBG, maxVBG); tessellator.draw(); //fg color tessellator.startDrawingQuads(); tessellator.setNormal(0, 0F, 1); tessellator.setColorRGBA_I(secondaryColor, 0xFF); tessellator.addVertexWithUV(x + 0, y + 0.0, z + 0.0, maxUFG, maxVFG); tessellator.addVertexWithUV(x + 0, y + 1, z + 0.0, maxUFG, minVFG); tessellator.addVertexWithUV(x + 1, y + 1.0, z + 0, minUFG, minVFG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0, minUFG, maxVFG); tessellator.draw(); // south face tessellator.startDrawingQuads(); //NOrmals: X+ = east, Y+ =up, z+ = south //background color tessellator.setNormal(0, 0F, 1); tessellator.setColorRGBA_I(dust.getPrimaryColor(dustStack), 0xFF); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 1, maxUBG, maxVBG); tessellator.addVertexWithUV(x + 1.0, y + 1, z + 1, maxUBG, minVBG); tessellator.addVertexWithUV(x + 0, y + 1.0, z + 1, minUBG, minVBG); tessellator.addVertexWithUV(x + 0, y + 0.0, z + 1.0, minUBG, maxVBG); tessellator.draw(); //fg color tessellator.startDrawingQuads(); tessellator.setNormal(0, 0F, 1); tessellator.setColorRGBA_I(secondaryColor, 0xFF); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 1, maxUFG, maxVFG); tessellator.addVertexWithUV(x + 1.0, y + 1, z + 1, maxUFG, minVFG); tessellator.addVertexWithUV(x + 0, y + 1.0, z + 1, minUFG, minVFG); tessellator.addVertexWithUV(x + 0, y + 0.0, z + 1.0, minUFG, maxVFG); tessellator.draw(); // bottom face tessellator.startDrawingQuads(); //NOrmals: X+ = east, Y+ =up, z+ = south //background color tessellator.setNormal(0, -1F, 0.0F); tessellator.setColorRGBA_I(primaryColor, 0xFF); tessellator.addVertexWithUV(x + 1, y + 0.0, z + 0, maxUBG, maxVBG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 1, maxUBG, minVBG); tessellator.addVertexWithUV(x + 0, y + 0, z + 1, minUBG, minVBG); tessellator.addVertexWithUV(x + 0, y + 0.0, z + 0, minUBG, maxVBG); tessellator.draw(); //fg color tessellator.startDrawingQuads(); tessellator.setNormal(0, -1F, 0.0F); tessellator.setColorRGBA_I(dust.getSecondaryColor(dustStack), 0xFF); tessellator.addVertexWithUV(x + 1, y + 0.0, z + 0, maxUFG, maxVFG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 1, maxUFG, minVFG); tessellator.addVertexWithUV(x + 0, y + 0, z + 1, minUFG, minVFG); tessellator.addVertexWithUV(x + 0, y + 0.0, z + 0, minUFG, maxVFG); tessellator.draw(); // UP face tessellator.startDrawingQuads(); //NOrmals: X+ = east, Y+ =up, z+ = south //background color tessellator.setNormal(0, 1F, 0.0F); tessellator.setColorRGBA_I(primaryColor, 0xFF); tessellator.addVertexWithUV(x + 1.0, y + 1, z + 1, maxUBG, maxVBG); tessellator.addVertexWithUV(x + 1.0, y + 1, z + 0.0, maxUBG, minVBG); tessellator.addVertexWithUV(x + 0, y + 1.0, z + 0, minUBG, minVBG); tessellator.addVertexWithUV(x + 0, y +1, z + 1.0, minUBG, maxVBG); tessellator.draw(); //fg color tessellator.startDrawingQuads(); tessellator.setNormal(0, 1F, 0.0F); tessellator.setColorRGBA_I(dust.getSecondaryColor(dustStack), 0xFF); tessellator.addVertexWithUV(x + 1.0, y + 1, z + 1, maxUFG, maxVFG); tessellator.addVertexWithUV(x + 1.0, y + 1, z + 0.0, maxUFG, minVFG); tessellator.addVertexWithUV(x + 0, y + 1.0, z + 0, minUFG, minVFG); tessellator.addVertexWithUV(x + 0, y +1, z + 1.0, minUFG, maxVFG); } }
  13. ok, so east = X+, up = Y+, south = Z+. therefore the (0,0,0) vertice would be the corner of the west south and down faces?
  14. I think I figured part of it out, but the results I get are not what I'd expect, and I can't find what I'm doing wrong. probably related to vertex position and normals though. ISimpleBlockRenderingHandler: (look at the last method. I also commented most faces out to try to get it right one face at a time) package com.zpig333.runesofwizardry.client.render; import com.zpig333.runesofwizardry.api.IDust; import com.zpig333.runesofwizardry.api.IDustStorageBlock; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.RenderingRegistry; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import org.lwjgl.opengl.GL11; public class DustStorageRenderer implements ISimpleBlockRenderingHandler{ private static int dustStorageRenderID; //following a "singleton" pattern since I don't like having a public constructor changing a static variable (could mess stuff up) private static DustStorageRenderer instance = null; private DustStorageRenderer(){ dustStorageRenderID = RenderingRegistry.getNextAvailableRenderId(); } public static int getRenderID(){ return dustStorageRenderID; } public static DustStorageRenderer getInstance(){ if(instance==null){ instance=new DustStorageRenderer(); } return instance; } @Override public void renderInventoryBlock(Block ablock, int metadata, int modelId, RenderBlocks renderer) { if (ablock instanceof IDustStorageBlock) { IDustStorageBlock block = (IDustStorageBlock) ablock; //thanks to TheGreyGhost for this https://github.com/TheGreyGhost/ItemRendering/blob/master/src/TestItemRendering/blocks/BlockPyramidRenderer.java Tessellator tes = Tessellator.instance; // if you don't perform this translation, the item won't sit in the player's hand properly in 3rd person view GL11.glTranslatef(-0.5F, -0.5F, -0.5F); // for "inventory" blocks (actually for items which are equipped, dropped, or in inventory), should render in [0,0,0] to [1,1,1] tes.startDrawingQuads(); renderDustBlock(tes, 0.0, 0.0, 0.0, metadata, block); tes.draw(); // don't forget to undo the translation you made at the start GL11.glTranslatef(0.5F, 0.5F, 0.5F); } } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block ablock, int modelId, RenderBlocks renderer) { if (ablock instanceof IDustStorageBlock) { IDustStorageBlock block = (IDustStorageBlock) ablock; Tessellator tessellator = Tessellator.instance; // world blocks should render in [x,y,z] to [x+1, y+1, z+1] // tessellator.startDrawingQuads() has already been called by the caller int lightValue = block.getMixedBrightnessForBlock(world, x, y, z); tessellator.setBrightness(lightValue); tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); renderDustBlock(tessellator, (double)x, (double)y, (double) z, world.getBlockMetadata(x, y, z), block); // tessellator.draw() will be called by the caller after return return true; } return false; } @Override public boolean shouldRender3DInInventory(int modelId) { return true; } @Override public int getRenderId() { return dustStorageRenderID; } private void renderDustBlock(Tessellator tessellator, double x, double y, double z, int meta, IDustStorageBlock block) { //TODO most of the work: renderDustBlock IDust dust = block.getIDust(); ItemStack dustStack = new ItemStack(dust,1); IIcon bgIcon = block.getBackgroundIcon(); IIcon fgIcon = block.getForegroundIcon(); bgIcon = Blocks.lapis_block.getIcon(0, 0); fgIcon = Blocks.bedrock.getIcon(0, 0); double minUBG = (double) bgIcon.getMinU(); double minVBG = (double) bgIcon.getMinV(); double maxUBG = (double) bgIcon.getMaxU(); double maxVBG = (double) bgIcon.getMaxV(); //foreground texture double minUFG = (double) fgIcon.getMinU(); double minVFG = (double) fgIcon.getMinV(); double maxUFG = (double) fgIcon.getMaxU(); double maxVFG = (double) fgIcon.getMaxV(); //NOrmals: X+ = east, Y+ =up, z+ = south // east face //background color tessellator.setNormal(1F, 0F, 0.0F); tessellator.setColorRGBA_I(dust.getPrimaryColor(dustStack), 0xFF); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0.0, maxUBG, maxVBG); tessellator.addVertexWithUV(x + 1.0, y + 1.0, z + 0.0, maxUBG, minVBG); tessellator.addVertexWithUV(x + 0, y + 1.0, z + 0, minUBG, minVBG); tessellator.addVertexWithUV(x + 0, y + 0, z + 0, minUBG, maxVBG); /* //fg color tessellator.setColorRGBA_I(dust.getSecondaryColor(dustStack), 0xFF); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0.0, maxUBG, maxVBG); tessellator.addVertexWithUV(x + 1.0, y + 1.0, z + 0.0, maxUBG, minVBG); tessellator.addVertexWithUV(x + 0, y + 1.0, z + 0, minUBG, minVBG); tessellator.addVertexWithUV(x + 0, y + 0, z + 0, minUBG, maxVBG); tessellator.draw(); // west face tessellator.startDrawingQuads(); tessellator.setNormal(-1, 0, 0.0F); tessellator.setColorRGBA_I(dust.getPrimaryColor(dustStack), 0xFF); tessellator.addVertexWithUV(x + 0.0, y + 0.0, z + 1.0, minUBG, maxVBG); tessellator.addVertexWithUV(x + 0.0, y + 0.0, z + 1.0, minUBG, minVBG); tessellator.addVertexWithUV(x + 1, y + 1.0, z + 1, maxUBG, minVBG); tessellator.addVertexWithUV(x + 0.0, y + 0.0, z + 0.0, maxUBG, maxVBG); tessellator.setColorRGBA_I(dust.getSecondaryColor(dustStack), 0xFF); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0.0, maxUFG, maxVFG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0.0, maxUFG, minVFG); tessellator.addVertexWithUV(x + 1, y + 1.0, z + 1, minUFG, minVFG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 1.0, minUFG, maxVFG); tessellator.draw(); // north face //NOrmals: X+ = east, Y+ =up, z+ = south //background color tessellator.startDrawingQuads(); tessellator.setNormal(0, 0F, 1); tessellator.setColorRGBA_I(dust.getPrimaryColor(dustStack), 0xFF); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0.0, maxUBG, maxVBG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0.0, maxUBG, minVBG); tessellator.addVertexWithUV(x + 1, y + 1.0, z + 1, minUBG, minVBG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 1.0, minUBG, maxVBG); //fg color tessellator.setColorRGBA_I(dust.getSecondaryColor(dustStack), 0xFF); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0.0, maxUFG, maxVFG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0.0, maxUFG, minVFG); tessellator.addVertexWithUV(x + 1, y + 1.0, z + 1, minUFG, minVFG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 1.0, minUFG, maxVFG); tessellator.draw(); // south face tessellator.startDrawingQuads(); //NOrmals: X+ = east, Y+ =up, z+ = south //background color tessellator.setNormal(0, 0F, 1); tessellator.setColorRGBA_I(dust.getPrimaryColor(dustStack), 0xFF); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0.0, maxUBG, maxVBG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0.0, maxUBG, minVBG); tessellator.addVertexWithUV(x + 1, y + 1.0, z + 1, minUBG, minVBG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 1.0, minUBG, maxVBG); //fg color tessellator.setColorRGBA_I(dust.getSecondaryColor(dustStack), 0xFF); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0.0, maxUFG, maxVFG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0.0, maxUFG, minVFG); tessellator.addVertexWithUV(x + 1, y + 1.0, z + 1, minUFG, minVFG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 1.0, minUFG, maxVFG); tessellator.draw(); // bottom face tessellator.startDrawingQuads(); //NOrmals: X+ = east, Y+ =up, z+ = south //background color tessellator.setNormal(0, -1F, 0.0F); tessellator.setColorRGBA_I(dust.getPrimaryColor(dustStack), 0xFF); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0.0, maxUBG, maxVBG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0.0, maxUBG, minVBG); tessellator.addVertexWithUV(x + 1, y + 1.0, z + 1, minUBG, minVBG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 1.0, minUBG, maxVBG); //fg color tessellator.setColorRGBA_I(dust.getSecondaryColor(dustStack), 0xFF); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0.0, maxUFG, maxVFG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0.0, maxUFG, minVFG); tessellator.addVertexWithUV(x + 1, y + 1.0, z + 1, minUFG, minVFG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 1.0, minUFG, maxVFG); tessellator.draw(); // UP face tessellator.startDrawingQuads(); //NOrmals: X+ = east, Y+ =up, z+ = south //background color tessellator.setNormal(0, 1F, 0.0F); tessellator.setColorRGBA_I(dust.getPrimaryColor(dustStack), 0xFF); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0.0, maxUBG, maxVBG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0.0, maxUBG, minVBG); tessellator.addVertexWithUV(x + 1, y + 1.0, z + 1, minUBG, minVBG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 1.0, minUBG, maxVBG); //fg color tessellator.setColorRGBA_I(dust.getSecondaryColor(dustStack), 0xFF); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0.0, maxUFG, maxVFG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 0.0, maxUFG, minVFG); tessellator.addVertexWithUV(x + 1, y + 1.0, z + 1, minUFG, minVFG); tessellator.addVertexWithUV(x + 1.0, y + 0.0, z + 1.0, minUFG, maxVFG); */ } } result (notice how the north/south face is rendering when I'm trying to render the east face) http://prntscr.com/5ff8xe (couldn't figure out how to post the image properly)
  15. Thanks. things look like they should work in 1.7, although I am still unsure of how to render the texture in layers (I should be able to figure it out eventually). I did hope I could create the final texture directly in the block class, but it does not look possible without using "regular" Java image modification (which can be painful/slow) unless there are methods to modify/create IIcons directly EDIT: also, is block metadata passed to renderWorldBlock ? I need it to get the right colors forget that, I got it (world.getBlockMetadata).
  16. Hello Could you point me to an example please? I've never used an ISimpleBlockRenderingHandler or the Tesselator
  17. thanks, although I don't see where to set the textures/colors in that. also, will i need one renderer per block? the goal is to simplify adding "dusts" to my mod, making it so the dusts are created by specifying background and foreground colors, and the item and storage block are automatically created.
  18. Hello Is there a way to create a block which has a texture composed of multiple layers and color overlays? i.e for items, I have a background and a foreground texture, both white, which are rendered with a different color (see below). I would like to do the same with a block. is that possible? in the Item class @Override public IIcon getIconFromDamageForRenderPass(int meta, int pass){ if(hasCustomIcon)return this.itemIcon; if(pass == 0){ return icon_foreground; }else { return icon_background; } } @Override public boolean requiresMultipleRenderPasses() { return true; } /** sets the item's color based on the itemstack * */ @Override @SideOnly(Side.CLIENT) public int getColorFromItemStack(ItemStack stack, int pass) { //if there is a custom icon registered, return the same thing as Item if(hasCustomIcon)return 16777215; //otherwise, return the colors of the dust IDust dust = DustRegistry.getDustFromItemStack(stack); return pass == 0 ? dust.getPrimaryColor(stack) : dust.getSecondaryColor(stack); } /** sets the icon of the dust. * default is based on the primary and secondary colors. * override for custom icon * * @param ireg */ @SideOnly(Side.CLIENT) @Override public void registerIcons(IIconRegister ireg){ hasCustomIcon=false; //just the plain one for now icon_foreground = ireg.registerIcon(References.texture_path + "dust_item_fore"); icon_background = ireg.registerIcon(References.texture_path + "dust_item_sub"); } thaks. also, sorry for the undescriptive title, I find this problem hard to explain for some reason.
  19. Hello I am using fontRendererObj.drawString("!", 98, 15, 0xFF0000); to draw a String in my GUI. however, I would like it to be larger. I do not see a method that allows to set the scale of the drawn String, which makes me think I need to create a new FontRenderer. however, I can not find the documentation for it. Thanks
  20. SOLVED. it seems the proper way of fixing the "ghost" tileEntity was to call super.breakBlock() also, harvesting problem was solved by using setHardness() and making canHarvest() always return true.
  21. adding tileentityDustDye.invalidate(); at the end of the the breakBlock method seems to fix the issue where the issue of the container staying the same after breaking it, although I am unsure of what this method does.
  22. here you go. also, I didn't notice before, but the block seems to be instantly broken (and does not drop) with the empty hand in survival mode, even though the harvest level has been set. package com.zpig333.runesofwizardry.block; import com.zpig333.runesofwizardry.RunesOfWizardry; import com.zpig333.runesofwizardry.core.ModLogger; import com.zpig333.runesofwizardry.gui.GuiDustDye; import com.zpig333.runesofwizardry.tileentity.TileEntityDustDye; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class BlockDustDye extends BlockContainer { private Random random = new Random(); public BlockDustDye(Material mat) { super(mat); setCreativeTab(RunesOfWizardry.wizardry_tab); setHarvestLevel("pickaxe", 0); } @Override public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { return new TileEntityDustDye(); } //drops the items when the block is broken (?) @Override public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) { TileEntityDustDye tileentityDustDye = (TileEntityDustDye) p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); if (tileentityDustDye != null) { for (int i1 = 0; i1 < tileentityDustDye.getSizeInventory(); ++i1) { ItemStack itemstack = tileentityDustDye.getStackInSlot(i1); if (itemstack != null) { float f = this.random.nextFloat() * 0.8F + 0.1F; float f1 = this.random.nextFloat() * 0.8F + 0.1F; EntityItem entityitem; for (float f2 = this.random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; p_149749_1_.spawnEntityInWorld(entityitem)) { int j1 = this.random.nextInt(21) + 10; if (j1 > itemstack.stackSize) { j1 = itemstack.stackSize; } itemstack.stackSize -= j1; entityitem = new EntityItem(p_149749_1_, (double) ((float) p_149749_2_ + f), (double) ((float) p_149749_3_ + f1), (double) ((float) p_149749_4_ + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); float f3 = 0.05F; entityitem.motionX = (double) ((float) this.random.nextGaussian() * f3); entityitem.motionY = (double) ((float) this.random.nextGaussian() * f3 + 0.2F); entityitem.motionZ = (double) ((float) this.random.nextGaussian() * f3); if (itemstack.hasTagCompound()) { entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); } } } } p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_); } } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int metadata, float what, float these, float are){ /* if (world.isRemote) { return true; } else { */ TileEntityDustDye tileentityDD = (TileEntityDustDye)world.getTileEntity(x,y,z); if (tileentityDD == null || player.isSneaking()) { return false; } player.openGui(RunesOfWizardry.instance, GuiDustDye.GUI_ID, world, x, y, z); return true; } }
  23. that is indeed what I did, and it works (also, the reply from the server does not seem necessary either). however, I noticed that if I break the tileEntity and place a new one in the same spot, the new one takes the properties of the old one, and if there was an ItemStack in it (dropped when the TE is broken), it is still there, although with only 1 item. Reloading the world between the breaking and placing of the TE fixes it. do I need to do something specific to reset the TileEntity when it is broken?
  24. thanks! I can now successfully save stuff in my TileEntity now, all I have to do is get those ItemStacks to change their NBT on button press...
  25. yep, that was it. However, for the packet that updates the GUI/TileEntity, should I register it on Side.SERVER or Side.CLIENT? if it is on Client, how do I access the TileEntity? the client handler (MessageContext.getClientHandler()) does not have access to the player/world to obtain the TE (and, of course, getServerHandler crashes since it's client-side)
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.