Jump to content

EmperorZelos

Members
  • Posts

    148
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

EmperorZelos's Achievements

Creeper Killer

Creeper Killer (4/8)

1

Reputation

  1. I am working on my own kind of fluid blocks, partially because I think it's fun and partially because the current ones are utter shite in my opinion. I was working on it, getting the ISBRH being called and such, now however, it's never being called, I can go into debugging and it never gets called what so ever. I have checked the client registry thing, it is being registered and all but I simply cannot get it to be called for some reason, suggestions? What have I missed? Block: package aerosteam.fluid.liquid; import java.util.ArrayList; import java.util.List; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import aerosteam.AeroSteam; import aerosteam.blocks.BlocksGases; import aerosteam.blocks.BlocksLiquids; import aerosteam.functions.GeneralFunctions; import aerosteam.functions.OmniDirection; import aerosteam.proxy.ClientProxy; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockLiquid extends Block{ boolean source = false; private static int c = 0; BlockLiquid product; private float density; public static ForgeDirection[] forgeSides = {ForgeDirection.NORTH,ForgeDirection.WEST,ForgeDirection.SOUTH,ForgeDirection.EAST}; private OmniDirection[] omniSides = OmniDirection.ORDERED_LEVEL; private ForgeDirection[] omniToForge = {ForgeDirection.NORTH,ForgeDirection.NORTH,ForgeDirection.WEST,ForgeDirection.WEST,ForgeDirection.SOUTH,ForgeDirection.SOUTH,ForgeDirection.EAST,ForgeDirection.EAST}; public int maxFlow = 5; public BlockLiquid() { super(Material.water); BlocksLiquids.nrLiquids++; } public BlockLiquid setSource(Block liquid) { BlocksLiquids.nrSources++; this.product = (BlockLiquid) liquid; this.setCreativeTab(AeroSteam.gasTab); this.source = true; return this; } public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { return null; } public void velocityToAddToEntity(World world, int x, int y, int p_14964z0_4_, Entity ent, Vec3 vec) { } private ForgeDirection addDir(ForgeDirection dir1, ForgeDirection dir2){ if (dir1==ForgeDirection.DOWN || dir2 == ForgeDirection.DOWN) return ForgeDirection.DOWN; if (dir1==null) return dir2; if (dir2==null) return dir1; int i1 = dir1.ordinal()-2; int i2 = dir2.ordinal()-2; int d = (i2+i2)&6+2; return ForgeDirection.VALID_DIRECTIONS[d]; } public int flowDist(World world, int x, int y, int z){ c++; Block t = world.getBlock(x, y, z); if (!(t instanceof BlockLiquid)) return 0; BlockLiquid block = (BlockLiquid) t; if (block != this && block.product != this) return 0; if (block.source) return maxFlow; // Determines how far it can go int meta = world.getBlockMetadata(x, y, z); if (meta > 7) return 0; ForgeDirection dir = this.omniToForge[meta].getOpposite(); int r = c < 7 ? flowDist(world,x+dir.offsetX,y+dir.offsetY,z+dir.offsetZ)-1 : -5; c=0; if (r==-5){ System.out.println("bollcoks"); } return r > 0 ? r : 0; } private OmniDirection getDir(World world, int x, int y, int z){ int[] weight = new int[4]; for (int i=0;i<4;i++){// ForgeDirection check = this.forgeSides[i]; Block block = world.getBlock(x+check.offsetX, y+check.offsetY, z+check.offsetZ); if (block instanceof BlockLiquid){ BlockLiquid liq = (BlockLiquid) block; if (liq == this || liq.product == this){ weight[i] = flowDist(world,x+check.offsetX, y+check.offsetY, z+check.offsetZ); //test } }else if (block == Blocks.air){ } } OmniDirection dir=null; int we = weight[1]-weight[3]; //west - east int ns = weight[0]-weight[2]; //north - south int axdif = Math.abs(ns)-Math.abs(we); if (axdif == 0){ if (ns > 0 && we > 0 ) dir = OmniDirection.NORTHWEST; if (ns > 0 && we < 0) dir = OmniDirection.NORTHEAST; if (ns < 0 && we > 0) dir = OmniDirection.SOUTHWEST; if (ns < 0 && we < 0) dir = OmniDirection.SOUTHEAST; }else{ if (axdif > 0){ if (ns > 0) dir = OmniDirection.NORTH; if (ns < 0) dir = OmniDirection.SOUTH; }else{ if (we < 0) dir = OmniDirection.EAST; if (we > 0) dir = OmniDirection.WEST; } } return dir != null ? dir.getOpposite():null; } private int dirID(OmniDirection dir){ for (int i=0;i<8;i++){ if (dir == this.omniSides[i]) return i; } return 8; } @Override public void onBlockAdded(World world, int x, int y, int z) { world.scheduleBlockUpdate(x,y,z, this, 10); } @Override public void updateTick(World world, int x, int y, int z, Random rnd){ updateLiqState(world,x,y,z); /*ForgeDirection dir = null; for (ForgeDirection check: this.sides){ Block block = world.getBlock(x+check.offsetX, y+check.offsetY, z+check.offsetZ); if (block == this){ dir = addDir(dir,check.getOpposite()); }else if (block == Blocks.air){ } }*/ } @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityplayer,ItemStack itemstack){ if (this.source){ for (int i = 0; i< this.forgeSides.length;i++){ ForgeDirection check = this.forgeSides[i]; Block block = world.getBlock(x+check.offsetX, y+check.offsetY, z+check.offsetZ); if (block == Blocks.air){ world.setBlock(x+check.offsetX, y+check.offsetY, z+check.offsetZ, this.product,2*i,2); world.scheduleBlockUpdate(x+check.offsetX, y+check.offsetY, z+check.offsetZ, this.product, 10); } } } } private void updateLiqState(World world, int x, int y, int z){ int meta = dirID(getDir(world,x,y,z)); world.setBlockMetadataWithNotify(x, y, z, meta, 2); int flow = flowDist(world,x,y,z); ForgeDirection dir = null; if (flow > 1){ for (ForgeDirection check: this.forgeSides){ Block block = world.getBlock(x+check.offsetX, y+check.offsetY, z+check.offsetZ); if (block instanceof BlockLiquid){ BlockLiquid liq = (BlockLiquid) block; if (liq == this || liq.product == this){ } dir = addDir(dir,check.getOpposite()); }else if (block == Blocks.air){ OmniDirection d = getDir(world,x+check.offsetX, y+check.offsetY, z+check.offsetZ); int nmeta = dirID(d); Block liq = this.source ? this.product:this; world.setBlock(x+check.offsetX, y+check.offsetY, z+check.offsetZ, liq, nmeta, 2); } } }else if (flow == 0){ world.setBlock(x, y, z, Blocks.air); } } public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { if (!this.source){ if (block instanceof BlockLiquid){ BlockLiquid liq = (BlockLiquid) block; } world.scheduleBlockUpdate(x,y,z, this, 10); } } public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) {} /** * How bright to render this block based on the light its receiving. Args: iBlockAccess, x, y, z */ @SideOnly(Side.CLIENT) public int getMixedBrightnessForBlock(IBlockAccess p_149677_1_, int p_149677_2_, int p_149677_3_, int p_149677_4_) { int l = p_149677_1_.getLightBrightnessForSkyBlocks(p_149677_2_, p_149677_3_, p_149677_4_, 0); int i1 = p_149677_1_.getLightBrightnessForSkyBlocks(p_149677_2_, p_149677_3_ + 1, p_149677_4_, 0); int j1 = l & 255; int k1 = i1 & 255; int l1 = l >> 16 & 255; int i2 = i1 >> 16 & 255; return (j1 > k1 ? j1 : k1) | (l1 > i2 ? l1 : i2) << 16; } /** * The type of render function that is called for this block */ /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ public boolean renderAsNormalBlock() { return false; } public int getRenderType() { return ClientProxy.liquidRenderType; } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister icon) { this.blockIcon = icon.registerIcon(AeroSteam.MODID + ":" + "water"); } public boolean isOpaqueCube() { return false; } @Override public boolean canRenderInPass(int pass) { //Set the static var in the client proxy //ClientProxy.renderPass = pass; //the block can render in both passes, so return true always return pass == 1; } @Override public int getRenderBlockPass() { return 1; } } Client Proxy: public void setCustomRenderers() { gasRenderType = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(new RenderBlockGases()); liquidRenderType = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(new RenderBlockLiquid()); }
  2. I have noticed if I use GL11.glDisable(GL11.GL_LIGHTING); it looks good from the sides but underneath it gets too bright then.
  3. I am having problem with a custom rendering, I am using it to render blocks seemingly normally but with great diversity in a simple manner. The issue is that the sides come out darkened http://i1310.photobucket.com/albums/s644/EmperorZelos/2015-08-22_12.32.45_zpsvfkcwpoe.png[/img] Like this, this is my code package aerosteam.renderer.blocks; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; import aerosteam.AeroSteam; import aerosteam.model.blocks.ModelBarrel; import aerosteam.recipes.Beverages; import aerosteam.tileentity.TileEntityBarrel; public class RenderPipeBlock extends TileEntitySpecialRenderer{ float[] dx = {0.5F,0.5F,0F,0F,0.5F,0.5F}; float[] dy = {0F,0F,0.5F,0.5F,0.5F,0.5F}; float[] dz = {0.5F,0.5F,0.5F,0.5F,0F,0F}; Block test = Blocks.brick_block; public RenderPipeBlock(){ } @Override public void renderTileEntityAt(TileEntity entity, double x,double y, double z, float f) { //TileEntityBarrel barrel = (TileEntityBarrel) entity; IIcon icon = test.getIcon(5, 6); Tessellator t = Tessellator.instance; float minU = icon.getMinU(); float minV = icon.getMinV(); float maxU = icon.getMaxU(); float maxV = icon.getMaxV(); int sizeX = 16; int sizeY = 16; Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); GL11.glPushMatrix(); //GL11.glTranslatef((float)x+0.5F, (float)y+1.5F, (float)z+0.5F); //GL11.glRotatef(180, 0F, 0F, 1F); GL11.glTranslated(x, y, z); //GL11.glEnable(GL11.GL_BLEND); t.startDrawingQuads(); t.addVertexWithUV(1, 1, 0, minU, minV); //Top right t.addVertexWithUV(1, 0, 0, minU, maxV); //Bottom right t.addVertexWithUV(0, 0, 0, maxU, maxV); //Bottom left texture t.addVertexWithUV(0, 1, 0, maxU, minV); //Top left t.draw(); GL11.glPopMatrix(); } public void renderItem(TileEntity entity){ TileEntityBarrel ana = (TileEntityBarrel) entity; renderTileEntityAt(ana,0D,-0.5D,0D,0F); } } What is it missing that is causing this darkening? The "isOpaque" is set to false also.
  4. if I recall correctly NBT only works on stacks.
  5. Never crossed my mind, which are possible? And if both how are both done?
  6. Storing information in tile entities and get it back when the server loads (or chunk in their case) is relatively trivial. My question is, what if I want to have global variables? Like if one did some form of gate system to store the adresses which are then reloaded everytime the server is booted up again?
  7. Using it I can render the item but it seems to want to do a 3D model of it in the world =/ Which is not what I want sadly
  8. Which I have dangerously low experience with unfortunately, do you know any guide that can make this work where I can get the icon and all rendered and shown? If I got that far I could play around and learn it.
  9. I have looked into that one but I am uncertain how to render it on a Tessellator
  10. While that does certainly give me the texture of the block, it unfortunately does not give me the icon of the block one sees in the inventory. I mean the 3D rendition in the inventory one see of blocks, like for hte anvil and such.
  11. When I use blocks I get it trying to render items that is somewhere along and it doesn't seem to fit. ItemStack stack = new ItemStack(Item.getItemFromBlock(Blocks.brick_block), 1, 0); drawIcon(0,0,stack.getIconIndex(),ForgeDirection.SOUTH); private void drawIcon(int posX, int posY, IIcon icon, ForgeDirection side){ Tessellator t = Tessellator.instance; float minU = icon.getMinU(); float minV = icon.getMinV(); float maxU = icon.getMaxU(); float maxV = icon.getMaxV(); int sizeX = 16; int sizeY = 16; GL11.glTranslated(posX, posY, 0.0D); //GL11.glBindTexture(TextureMap.locationItemsTexture); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); //GL11.glEnable(GL11.GL_BLEND); t.startDrawingQuads(); t.addVertexWithUV(0, 0, 0, minU, maxV); //Bottom left texture t.addVertexWithUV(0, 1, 0, maxU, maxV); //Top left t.addVertexWithUV(1, 1, 0, maxU, minV); //Top right t.addVertexWithUV(1, 0, 0, minU, minV); //Bottom right /*t.addVertexWithUV(posX, posY+sizeY, 0D, minU, maxV); t.addVertexWithUV(posX + sizeX, posY + sizeY, 1D, maxU, maxV); t.addVertexWithUV(posX + sizeX, posY + 0, 1D, maxU, minV); t.addVertexWithUV(posX + 0, posY + 0, 0.0D, minU, minV);*/ t.draw(); }
  12. does that include ALL items, including those added by mods? Edit: It seems to work for that so thank you, but what about the icon of blocks? As they are rendered in inventories
  13. Hello! I am currently trying to make a block that shows the item content within it. I know how to get the item and all so that's not an issue. My issue is when it comes to rendering, I just cannot figure out a manner at which I grab the rendered icon for an item in inventory and render it on Tessellator. I have gotten a tessellator running but the issue is getting the texture. How would I do this for a given item or stack? Best regards and thanks in advance.
×
×
  • Create New...

Important Information

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