Posted September 3, 201510 yr 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()); }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.