Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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?

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

  • 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.

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.

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

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/

  • 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);
    	}
    }

   

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/

  • 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?

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

 

 

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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.