Posted January 12, 201411 yr Hello everybody! I am making a mod with gasses but I want them to stay in the world and not dissapear when they reach the top. I need to know how to make a block generate on 100% of layer 255?
January 12, 201411 yr You could use a loop, and set all the blocks from your starting point as air, until it reaches the height of 255.
January 12, 201411 yr Try the onBlockPlacedBy method, when the gas block comes into the world have it check to see if the block above it is air, if its air set current block to air and set the block above it to the gas block and just make sure the block won't go higher than 255 or whatever you want it to sit at. so if the block above it is air and not greater than 255 it will go up
January 12, 201411 yr Author Sorry, i have 2 more questions. 1. Is there a thing that returns the name of the block above another block? Example: C = custom block that returns the name of the above block, A = air A C It would say "air" in the eclipse console if you hooked it up to a printline thing? 2. How do I make the gas stop when the said air block is on layer 255? And can I please have some code pieces? I don't really know advanced java.
January 12, 201411 yr 2. How do I make the gas stop when the said air block is on layer 255? if(y >= 255) { return; } 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.
January 13, 201411 yr Try if (par1World.getBlockId(par2, par3 + 1, par4) == 0 && par3 <= 255) { par1World.setBlock(par2, par3 + 1, par4, yourgasblock); par1World.setBlock(par2, par3, par4, 0); } par2, par3, par4 are x, y, z
January 18, 201411 yr In the updateTick (right method name?) method in your block class. 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/
January 18, 201411 yr Author So do i put public void updateTick() { if (par1World.getBlockId(par2, par3 + 1, par4) == 0 && par3 <= 255) { par1World.setBlock(par2, par3 + 1, par4, BlockGasSteam); par1World.setBlock(par2, par3, par4, 0); } }
January 18, 201411 yr That should work, but that's going 20 blocks up in a second, so you might want to add a timer. 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/
January 21, 201411 yr Author Heres my code for the Gas Block file: package miner.miner.technicraft.oceans.blocks; import java.util.Random; import miner.miner.technicraft.oceans.client.gui.creativetabs.TCOceansCreativeTabs; import miner.miner.technicraft.oceans.TechnicCraftOceans; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.EntityLiving; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fluids.BlockFluidClassic; import net.minecraftforge.fluids.BlockFluidFinite; import net.minecraftforge.fluids.Fluid; public class BlockGasSteam extends BlockFluidFinite { public String texture; public BlockGasSteam(int id, String key, Fluid fluid) { super(id, fluid, Material.water); this.texture = key; this.setCreativeTab(TCOceansCreativeTabs.blocksTab); fluid.setBlockID(this); setUnlocalizedName(key); } @Override public void registerIcons(IconRegister register) { blockIcon = register.registerIcon(TechnicCraftOceans.modID + ":" + texture); getFluid().setIcons(blockIcon); } @Override public int colorMultiplier(IBlockAccess world, int x, int y, int z) { return 0xaaaaaa; } public void updateTick() { if (par1World.getBlockId(par2, par3 + 1, par4) == 0 && par3 <= 255) { par1World.setBlock(par2, par3 + 1, par4, BlockGasSteam); par1World.setBlock(par2, par3, par4, 0); } } } I am getting errors on par1World, par2, par3, par4 then the other par3 and just about everything else! Is there anything I need to change or move? Or do i just need to add ints/variables?
January 22, 201411 yr Hi I think the core of the problem here is that we're not really understanding what you want to do. i.e. you're making a block that is a gas, but then you mention something about the block moving upwards and stopping at layer 255? So my impression is that you want something like eg a toxic bog of eternal stench that belches out a block of gas occasionally which slowly rises its way up to layer 255 then stops and just sits there. Is that right? Perhaps if you provide a bit more explanation and background we can help you more... -TGG
January 23, 201411 yr Heres my code for the Gas Block file: public void updateTick() { if (par1World.getBlockId(par2, par3 + 1, par4) == 0 && par3 <= 255) { par1World.setBlock(par2, par3 + 1, par4, BlockGasSteam); par1World.setBlock(par2, par3, par4, 0); } } I am getting errors on par1World, par2, par3, par4 then the other par3 and just about everything else! Is there anything I need to change or move? Or do i just need to add ints/variables? First you will need to understand basic Java, then you will immediately understand why you are getting errors with par1World, etc. Second, you can't just add any method you want and expect it to run automatically. Sure, there is a method named updateTick in Block, but you don't have any of the arguments. Look in the Block class and you will see: @Override public void updateTick(World world, int x, int y, int z, Random rand) {} That's the correct method signature, and if you deviate at all from that your method is no longer a Block class method, meaning you'd have to call it yourself. Now that you have the correct method signature, you just have to make your block tick randomly or schedule ticks for it. Look at some ticking vanilla blocks to see how they do it. http://i.imgur.com/NdrFdld.png[/img]
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.