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

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() {

 

}

 

 

 

}

 

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

 

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

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.