Posted February 14, 201411 yr i want this block to be seen but can also be passed through by the player. package a.Screens; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; public class Ghost extends Block { public static Block instance; public int renderType = 0; public Ghost(int par1, Material air) { super(par1, Material.rock); setUnlocalizedName("Ghost"); setResistance(2F); setHardness(0.5F); this.setCreativeTab(CreativeTabs.tabBlock); } @Override public void registerIcons(IconRegister iconRegister) { blockIcon = iconRegister.registerIcon("oomod:Ghost"); } @Override public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) { return true; } public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side) { //int mymeta = world.getBlockMetadata(x, y, z); //if(mymeta == 0) { int[] id = {world.getBlockId(x, y-1, z),world.getBlockId(x-1, y, z),world.getBlockId(x+1, y, z),world.getBlockId(x, y, z-1),world.getBlockId(x, y, z+1),world.getBlockId(x, y+1, z)}; int[] meta = {world.getBlockMetadata(x, y-1, z),world.getBlockMetadata(x-1, y, z),world.getBlockMetadata(x+1, y, z),world.getBlockMetadata(x, y, z-1),world.getBlockMetadata(x, y, z+1),world.getBlockMetadata(x, y+1, z)}; //.get.getBlockTextureFromSideAndMetadata(par5, par1IBlockAccess.getBlockMetadata(par2, par3, par4)); for(int i = 0; i < id.length; i++) { Block block = Block.blocksList[id]; if(block != null) { if(block != this && block.isOpaqueCube()) { Icon icon = block.getIcon(side, meta); if(icon != null) { return icon; } } else if(block == this) { Icon icon = Block.grass.getBlockTextureFromSide(1); switch(i) { case 0: icon = ((Light)block).getBlockTextureDirectional(world, x, y-1, z, side, 0); break; case 1: icon = ((Light)block).getBlockTextureDirectional(world, x-1, y, z, side, 2); break; case 2: icon = ((Light)block).getBlockTextureDirectional(world, x+1, y, z, side, 3); break; case 3: icon = ((Light)block).getBlockTextureDirectional(world, x, y, z-1, side, 4); break; case 4: icon = ((Light)block).getBlockTextureDirectional(world, x, y, z+1, side, 5); break; case 5: icon = ((Light)block).getBlockTextureDirectional(world, x, y+1, z, side, 1); break; } if(icon != null && icon != Block.grass.getBlockTextureFromSide(1)) { return icon; } } } } return Block.grass.getBlockTextureFromSide(1); /*} else { return blockIcon; }*/ } public Icon getBlockTextureDirectional(IBlockAccess world, int x, int y, int z, int side, int direction) { int id = world.getBlockId(x, y, z); int meta = world.getBlockMetadata(x, y, z); Block block = Block.blocksList[id]; if(block != null) { if(block != this) { Icon icon = block.getIcon(side, meta); if(icon != null) { return icon; } } else { Icon icon = Block.grass.getBlockTextureFromSide(1); switch(direction) { case 0: icon = ((Light)block).getBlockTextureDirectional(world, x, y-1, z, side, 0); break; case 1: icon = ((Light)block).getBlockTextureDirectional(world, x, y+1, z, side, 1); break; case 2: icon = ((Light)block).getBlockTextureDirectional(world, x-1, y, z, side, 2); break; case 3: icon = ((Light)block).getBlockTextureDirectional(world, x+1, y, z, side, 3); break; case 4: icon = ((Light)block).getBlockTextureDirectional(world, x, y, z-1, side, 4); break; case 5: icon = ((Light)block).getBlockTextureDirectional(world, x, y, z+1, side, 5); break; } return icon; } } return Block.grass.getBlockTextureFromSide(1); } public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { return null; } public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } public boolean isOpaqueCube() { return false; } public boolean getBlocksMovement(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { return false; } /** * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha */ public int getRenderBlockPass() { return 1; } public boolean renderAsNormalBlock() { return false; } @Override public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) { if(world.getBlockId(x, y, z) == blockID || world.isBlockOpaqueCube(x, y, z)) return false; return true; } @Override public int getRenderType() { return renderType; } @Override public int quantityDropped(Random par1Random) { return 0; } }
February 14, 201411 yr Try comparing with this: https://github.com/Draco18s/Artifacts/blob/master/draco18s/artifacts/block/BlockIllusionary.java Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
February 14, 201411 yr What's the block doing right now? Are you getting a crash? Please provide some useful information for us so we can help. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
February 14, 201411 yr Author The blocks in game works fine as a normal block with textures i just want the palyer to be able to go through it.
February 14, 201411 yr dude, look at Draco's code, I think it does exactly what you want and it's not very complicated. -TGG
February 15, 201411 yr dude, look at Draco's code, I think it does exactly what you want and it's not very complicated. The most complicated thing in it is the camouflage code (getTexture). And that's not even relevant here. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
February 15, 201411 yr Author ok, the block now works in most cases as i want but I require it to do leaves but they greyscale. package a.Screens; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; public class Ghost extends Block { public static Block instance; public int renderType = 0; public Ghost(int par1, Material rock) { super(par1, Material.rock); setUnlocalizedName("Ghost"); this.setCreativeTab(CreativeTabs.tabBlock); } @Override public void registerIcons(IconRegister iconRegister) { blockIcon = iconRegister.registerIcon("oomod:ghost"); } @Override public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) { return true; } public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side) { int[] id = {world.getBlockId(x, y-1, z),world.getBlockId(x-1, y, z),world.getBlockId(x+1, y, z),world.getBlockId(x, y, z-1),world.getBlockId(x, y, z+1),world.getBlockId(x, y+1, z)}; int[] meta = {world.getBlockMetadata(x, y-1, z),world.getBlockMetadata(x-1, y, z),world.getBlockMetadata(x+1, y, z),world.getBlockMetadata(x, y, z-1),world.getBlockMetadata(x, y, z+1),world.getBlockMetadata(x, y+1, z)}; for(int i = 0; i < id.length; i++) { Block block = Block.blocksList[id]; if(block != null) { if(block != this && block.isOpaqueCube()) { Icon icon = block.getIcon(side, meta); if(icon != null) { return icon; } } else if(block == this) { Icon icon = Block.grass.getBlockTextureFromSide(1); switch(i) { case 0: icon = ((Ghost)block).getBlockTextureDirectional(world, x, y-1, z, side, 0); break; case 1: icon = ((Ghost)block).getBlockTextureDirectional(world, x-1, y, z, side, 2); break; case 2: icon = ((Ghost)block).getBlockTextureDirectional(world, x+1, y, z, side, 3); break; case 3: icon = ((Ghost)block).getBlockTextureDirectional(world, x, y, z-1, side, 4); break; case 4: icon = ((Ghost)block).getBlockTextureDirectional(world, x, y, z+1, side, 5); break; case 5: icon = ((Ghost)block).getBlockTextureDirectional(world, x, y+1, z, side, 1); break; } if(icon != null && icon != Block.grass.getBlockTextureFromSide(1)) { return icon; } } } } return Block.grass.getBlockTextureFromSide(1); } public Icon getBlockTextureDirectional(IBlockAccess world, int x, int y, int z, int side, int direction) { int id = world.getBlockId(x, y, z); int meta = world.getBlockMetadata(x, y, z); Block block = Block.blocksList[id]; if(block != null) { if(block != this) { Icon icon = block.getIcon(side, meta); if(icon != null) { return icon; } } else { Icon icon = Block.grass.getBlockTextureFromSide(1); switch(direction) { case 0: icon = ((Ghost)block).getBlockTextureDirectional(world, x, y-1, z, side, 0); break; case 1: icon = ((Ghost)block).getBlockTextureDirectional(world, x, y+1, z, side, 1); break; case 2: icon = ((Ghost)block).getBlockTextureDirectional(world, x-1, y, z, side, 2); break; case 3: icon = ((Ghost)block).getBlockTextureDirectional(world, x+1, y, z, side, 3); break; case 4: icon = ((Ghost)block).getBlockTextureDirectional(world, x, y, z-1, side, 4); break; case 5: icon = ((Ghost)block).getBlockTextureDirectional(world, x, y, z+1, side, 5); break; } return icon; } } return Block.grass.getBlockTextureFromSide(1); } public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { return null; } public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } public boolean isOpaqueCube() { return false; } public boolean getBlocksMovement(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { return false; } public int getRenderBlockPass() { return 1; } public boolean renderAsNormalBlock() { return false; } @Override public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) { if(world.getBlockId(x, y, z) == blockID || world.isBlockOpaqueCube(x, y, z)) return false; return true; } @Override public int getRenderType() { return renderType; } @Override public int quantityDropped(Random par1Random) { return 0; } }
February 15, 201411 yr You'd need to override the getColor() function. Not sure if there's one that passes the world object to it or not. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
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.