Jump to content

Recommended Posts

Posted

I have been having trouble  making a water block that like the vanilla block has certain heights it can achieve. But unlike the normal water block this block degrades the height of the parent block as it sets the preceding blocks. Also it moves blocks as well (you don't have to worry about that that is not the problem nor is it yet been added).

 

it does not duplicate but just sits except when you place it near other normal water blocks.

 

package IVWeather.iv.block;

 

import net.minecraft.block.Block;

import net.minecraft.block.BlockLiquid;

import net.minecraft.block.material.Material;

import net.minecraft.init.Blocks;

import net.minecraft.world.IBlockAccess;

import net.minecraft.world.World;

 

public class BlockRushingWater extends BlockLiquid{

 

public float LiquidHieght;

 

public BlockRushingWater(Material m_1) {

super(m_1);

LiquidHieght = .1F;

setBlockBounds(0, 0, 0, 1, LiquidHieght, 1);

}

 

public void spreadOverArea(int par1, int par2, int par3, IBlockAccess iba, World world) {

 

 

 

int a1 = par1;

int a2 = par1;

int a3 = par1;

Block blockA = iba.getBlock(a1 - 1, a2, a3);

Block blockB = iba.getBlock(a1 + 1, a2, a3);

Block blockC = iba.getBlock(a1, a2, a3 - 1);

Block blockD = iba.getBlock(a1, a2, a3 + 1);

 

    int i = world.getBlockMetadata( par1, par2, par3);

 

 

if(this.LiquidHieght > .05) {

if(blockA == Blocks.air) {

  world.setBlock(a1 - 1, a2, a3, Block.getBlockById(Block.getIdFromBlock(this) - 1), i, 2);

    world.scheduleBlockUpdate(par1, par2, par3, Block.getBlockById(Block.getIdFromBlock(this) - 1), tickRate(world));

  this.LiquidHieght = LiquidHieght/ 2;

}

 

if(blockB == Blocks.air) {

world.setBlock(a1 + 1, a2, a3, Block.getBlockById(Block.getIdFromBlock(this) - 1), i, 2);

world.scheduleBlockUpdate(par1, par2, par3, Block.getBlockById(Block.getIdFromBlock(this) - 1), tickRate(world));

this.LiquidHieght = LiquidHieght/ 2;

}

 

if(blockC == Blocks.air) {

world.setBlock(a1, a2, a3 + 1, Block.getBlockById(Block.getIdFromBlock(this) - 1), i, 2);

world.scheduleBlockUpdate(par1, par2, par3, Block.getBlockById(Block.getIdFromBlock(this) - 1), tickRate(world));

this.LiquidHieght = LiquidHieght/ 2;

}

 

if(blockD == Blocks.air) {

world.setBlock(a1, a2, a3 - 1, Block.getBlockById(Block.getIdFromBlock(this) - 1), i, 2);

world.scheduleBlockUpdate(par1, par2, par3, Block.getBlockById(Block.getIdFromBlock(this) - 1), tickRate(world));

this.LiquidHieght = LiquidHieght/ 2;

}

}

}

 

public void MakeHieghtAmount() {

this.setBlockBounds(0, 0, 0, 1, LiquidHieght, 1);

}

 

public void accumulate() {

 

}

 

 

 

}

 

Posted

Hi

 

I'm not sure I understand your code.

What are you expecting to call spreadOverArea?

 

Forge has something similar to this already.  Look at BlockFluidFinite  (and in the minecraftforge\fluids package in general).  I don't know how to use it properly myself, never tried, but it's intended for exactly this sort of thing.  A google will probably show up a tutorial or at least a few GitHubs where people have used it before.

 

-TGG

 

Posted

WTF Does this code mean:

Block.getBlockById(Block.getIdFromBlock(this)

??? You are basicly getting a block from a id which you get from a block. You could've just used

this

instead of that chain of code....

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/

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.