Jump to content

Recommended Posts

Posted

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

Posted

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.

Posted

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.

Posted

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

Posted

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

   

Posted

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?

Posted

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

 

 

Posted

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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