Jump to content

Niverton

Members
  • Posts

    12
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • Location
    France
  • Personal Text
    I am new!

Niverton's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Alright, spent a lot of time on this thing, but it was worth it ! Had some problems too with the render in inventory, thanks again TGG found a solution of yours on another topic. My block looks really nice now Code for my renderer, not really commented but you can find anything you need on TGG's blog package com.niverton.concretemod.client; import org.lwjgl.opengl.GL11; import com.niverton.concretemod.blocks.BlockScaffold; 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.util.IIcon; import net.minecraft.world.IBlockAccess; public class RendererScaffoldBlock implements ISimpleBlockRenderingHandler { public static int renderID; public RendererScaffoldBlock() { renderID = RenderingRegistry.getNextAvailableRenderId(); } @Override public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { GL11.glTranslatef(-0.5F, -0.5F, -0.5F); Tessellator tessellator = Tessellator.instance; //Get icons from custom register (useful for renderers and fluids) IIcon side = ConcreteModClientProxy.getIcon(BlockScaffold.name.toLowerCase() + "_side"); IIcon top = ConcreteModClientProxy.getIcon(BlockScaffold.name.toLowerCase() + "_top"); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, -1.0F, 0.0F); renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, top); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, top); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, -1.0F); renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, side); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, 1.0F); renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, side); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(-1.0F, 0.0F, 0.0F); renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, side); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(1.0F, 0.0F, 0.0F); renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, side); tessellator.draw(); GL11.glTranslatef(0.5F, 0.5F, 0.5F); } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { renderer.renderStandardBlock(block, x, y, z); Tessellator tes = Tessellator.instance; tes.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)); IIcon side = ConcreteModClientProxy.getIcon(BlockScaffold.name.toLowerCase() + "_side"); //South tes.addVertexWithUV(x+0, y+0, z+0.999, side.getMinU(), side.getMaxV()); //0.999 instead of 1 for Z fighting (textures overlapping) tes.addVertexWithUV(x+0, y+1, z+0.999, side.getMinU(), side.getMinV()); tes.addVertexWithUV(x+1, y+1, z+0.999, side.getMaxU(), side.getMinV()); tes.addVertexWithUV(x+1, y+0, z+0.999, side.getMaxU(), side.getMaxV()); //East tes.addVertexWithUV(x+0.999, y+0, z+1, side.getMinU(), side.getMaxV()); tes.addVertexWithUV(x+0.999, y+1, z+1, side.getMinU(), side.getMinV()); tes.addVertexWithUV(x+0.999, y+1, z+0, side.getMaxU(), side.getMinV()); tes.addVertexWithUV(x+0.999, y+0, z+0, side.getMaxU(), side.getMaxV()); //North tes.addVertexWithUV(x+1, y+0, z+0.001, side.getMinU(), side.getMaxV()); tes.addVertexWithUV(x+1, y+1, z+0.001, side.getMinU(), side.getMinV()); tes.addVertexWithUV(x+0, y+1, z+0.001, side.getMaxU(), side.getMinV()); tes.addVertexWithUV(x+0, y+0, z+0.001, side.getMaxU(), side.getMaxV()); //West tes.addVertexWithUV(x+0.001, y+0, z+0, side.getMinU(), side.getMaxV()); tes.addVertexWithUV(x+0.001, y+1, z+0, side.getMinU(), side.getMinV()); tes.addVertexWithUV(x+0.001, y+1, z+1, side.getMaxU(), side.getMinV()); tes.addVertexWithUV(x+0.001, y+0, z+1, side.getMaxU(), side.getMaxV()); IIcon top = ConcreteModClientProxy.getIcon(BlockScaffold.name.toLowerCase() + "_top"); //Top tes.addVertexWithUV(x+0, y+0.999, z+1, top.getMinU(), top.getMaxV()); tes.addVertexWithUV(x+0, y+0.999, z+0, top.getMinU(), top.getMinV()); tes.addVertexWithUV(x+1, y+0.999, z+0, top.getMaxU(), top.getMinV()); tes.addVertexWithUV(x+1, y+0.999, z+1, top.getMaxU(), top.getMaxV()); //Bottom tes.addVertexWithUV(x+0, y+0.001, z+0, top.getMinU(), top.getMaxV()); tes.addVertexWithUV(x+0, y+0.001, z+1, top.getMinU(), top.getMinV()); tes.addVertexWithUV(x+1, y+0.001, z+1, top.getMaxU(), top.getMinV()); tes.addVertexWithUV(x+1, y+0.001, z+0, top.getMaxU(), top.getMaxV()); return true; } @Override public boolean shouldRender3DInInventory(int modelId) { return true; } @Override public int getRenderId() { return renderID; } }
  2. Hey, thanks for the link ! I was curious and looked at your blog, found this very interesting post on the Tessellator. It explains everything I need, I'll try again using the Tesselator because it's really interesting and I might need it later on. Thanks a lot !
  3. Thanks everyone, I tried to use a custom renderer with a tessellator, couldn't really get how I was supposed to do it, so I tried TGG's solution, and added this to my block's class @Override public int getRenderBlockPass() { return 1; } @Override public boolean canRenderInPass(int pass) { return (pass == 1)? true : false; } But I don't think I'm doing this right, and it didn't change anything
  4. I just tried, it doesn't work I'm guessing it's because the textures are drawn on planes, which only have one side rendered
  5. Hey, I made a block with a transparent texture on the sides, but it looks ugly because it doesn't draw the textures on the inner sides : [/img] (I overrode the isOpaqueCube function to return false so it renders block that are next to mine) Is there a way I can render a texture inside the block ?
  6. Thanks, it worked ! NBTTagCompound concreteRecipe = new NBTTagCompound(); concreteRecipe.setInteger("energy", 300); concreteRecipe.setTag("input", (new ItemStack(concretePowder).writeToNBT(new NBTTagCompound()))); concreteRecipe.setTag("output", (new FluidStack(concreteFluid, 1000).writeToNBT(new NBTTagCompound()))); FMLInterModComms.sendMessage("ThermalExpansion", "CrucibleRecipe", concreteRecipe);
  7. Hello, I'm trying to add a smelting recipe to the Magma Crucible from TE, with a custom item and a custom fluid. I've been looking for an answer for a few hours now, and I'm pretty sure it has something to do with CoFHLib's helpers, but I just can't find a solution. Much appreciated
  8. I looked into the BlockDynamicLiquid, but it doesn't use Fluids, so buckets wouldn't work (or it meant I had to rewrite half my mod). Then I noticed BlockFluidClassic had an updateTick() function I could use with world.scheduleBlockUpdate(). Then I realized I can't store the age of the block in the metadata because it's already used by flowing mechanics, so finally I had to use TileEntities by implementing ITileEntityProvider in my BlockFluid, and store the data in NBT tags. I uses the updateEntity() function to add to the age and check if the source is old to replace it with a block, and it works ! Thanks
  9. Hello, I'm trying to have a fluid dry over time and get replaced by a block. How can I check how many ticks have passed since the fluid was placed ? I've found TickEvent, but I don't know what to do with it, how can I get all corresponding blocks ? Also, using the fluid's metadata seems to be a good idea to store the time since the block was placed, is World.setBlockMetadataWithNotify the right way to change it ? And how do I use it (in the doc the parameters are just four ints with random names) ? Thanks a lot
  10. After testing, the write function is called every 45 seconds, so I should probably override onChunkUnload() to write the inventory to NBT. The read function, however, is never called, so I have to call it manually when the TileEntity is created. The problem is to get the previous tag. They're stored in the world files, so I should be able to read it from a World object, right ? But I can't find a method that gives me the tag in that class
  11. I'd like to use my mod in Tekkit, but the modpack isn't updated to 1.7 But thanks for the heads up, didn't see this beta Can you be more sarcastic and less precise please ? When are those functions called by Minecraft ? What did I do wrong implementing them ? Are you talking about entities like players and mobs or does it apply to TileEntities as well ? Also, should I override onInventoryChanged() ?
  12. Hello, new to modding I'm making a ComputerCraft peripheral (that's why I use 1.6), and I followed many tutorials to get a working inventory in a block. I can put items in it, the problem is that the items are destroyed when the block is unloaded. I tried to save the ItemStack to NBT tag, but I can't find where I should get the tag to save in. Here is my TileEntity (scrapped all CC peripheral stuff) package niverton.ccscanner; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; public class TileEntityScanner extends TileEntity implements IInventory { public static final String tileid = "TileEntityScanner"; private ItemStack inventory; //Constructor TileEntityScanner() { super(); } //------------------ //Inventory functions @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); NBTTagCompound tag = nbt.getCompoundTag("Inventory"); inventory = ItemStack.loadItemStackFromNBT(tag); } @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); //Writing inventory to NBT if (inventory != null) { NBTTagCompound item = new NBTTagCompound(); //Writing inventory to new NBT tag inventory.writeToNBT(item); //Saving the tag to list nbt.setTag("Inventory", item); } //Should store each ItemStack tag to a NBTTagList if has multiple slots } @Override public ItemStack decrStackSize(int slot, int count) { ItemStack itemstack = getStackInSlot(slot); if(itemstack != null) { if(itemstack.stackSize <= count) setInventorySlotContents(slot, null); else itemstack = itemstack.splitStack(count); onInventoryChanged(); } return itemstack; } @Override public ItemStack getStackInSlotOnClosing(int i) { ItemStack itemstack = getStackInSlot(i); setInventorySlotContents(i, null); return itemstack; } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { inventory = itemstack; if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) itemstack.stackSize = getInventoryStackLimit(); onInventoryChanged(); } @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { return true; } @Override public int getSizeInventory() { return 1; } @Override public int getInventoryStackLimit() { return 64; } @Override public ItemStack getStackInSlot(int i) { return inventory; } @Override public String getInvName() { return "Scanner"; } @Override public boolean isInvNameLocalized() { return true; } @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { return entityplayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64; } @Override public void openChest() { } @Override public void closeChest() { } } I know my TileEntity is working properly, because the CC stuff works, I just can't get it to save the inventory when the block is unloaded. Thanks !
×
×
  • Create New...

Important Information

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