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

This doesn't work...I did try again though

 

Block Class

 

 

public class Forge extends BlockContainer{

public Forge(int id, Material material){
	super(material);
	this.setCreativeTab(TestCraft.TestCraftTab);
}

public void onBlockAdded(World world, int x, int y, int z){
	TileEntityForge tile = new TileEntityForge();
	if(!tile.shouldRender){
		if(world.getBlock(x, y, z) == Blocks.stone
    			&& world.getBlock(x, y-1, z) == Blocks.stone
    			&& world.getBlock(x, y+1, z) == Blocks.stone
    			&& world.getBlock(x-1, y, z) == Blocks.stone
    			&& world.getBlock(x-1, y-1, z) == Blocks.stone
    			&& world.getBlock(x-1, y+1, z) == Blocks.stone
    			&& world.getBlock(x+1, y, z) == Blocks.stone
    			&& world.getBlock(x+1, y-1, z) == Blocks.stone
    			&& world.getBlock(x+1, y+1, z) == Blocks.stone){
			System.out.println("I am put together!");
    		((TileEntityForge)tile).shouldRender = true; 
		}
	}

}

@Override
public TileEntity createNewTileEntity(World var1, int var2) {
	return new TileEntityForge();
}
}

 

 

 

And the TileEntity Class

 

 

public class TileEntityForge extends TileEntity{
public boolean shouldRender = false;

@Override
public Packet getDescriptionPacket()
{
	NBTTagCompound tag = new NBTTagCompound();
	this.writeToNBT(tag);
	return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, tag);
}

@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
{
	NBTTagCompound tag = pkt.func_148857_g();
	this.readFromNBT(tag);
}

@Override
public void readFromNBT(NBTTagCompound tagCompound)
{
	super.readFromNBT(tagCompound);
	this.shouldRender = tagCompound.getBoolean("shouldRender");
}

@Override
public void writeToNBT(NBTTagCompound tagCompound)
{
	super.writeToNBT(tagCompound);
	tagCompound.setBoolean("shouldRender", this.shouldRender);
}
}

 

 

 

Any help? I have tried many methods...

TileEntityForge tile = new TileEntityForge();

Why are you making a brand new instance instead of getting the block's actual tile entity? ><

TileEntityForge blockTile = (TileEntityForge) world.getTileEntity(x, y, z);

Also, I why are you checking in your block added section instead of the checkMultiBlockForm from the tile (assuming you're using the tutorial). Judging by your code, you want your block to be surrounded by stone. If you followed the tutorial, all you would have to do to check if it formed was change that method to the following:

public boolean checkMultiBlockForm() {
    int i = 0;
    // Scan a 3x3x3 area, starting with the bottom left corner
    for (int x = xCoord - 1; x < xCoord + 2; x++)
        for (int y = yCoord -1; y < yCoord + 2; y++)
            for (int z = zCoord - 1; z < zCoord + 2; z++) {
                if (world.getBlock(x, y, z) == Blocks.stone)
                    i++;
            }
    return i == 26;
}

This would allow your block to constantly check around itself to make sure it's surrounded by stone.

 

Edit: Since you guys seem to have trouble grasping how this simple implementation works. I made an example mod that adds two types of multiblock blocks. The 1st requires you make a 3x3x3 structure with a hollow center using the block and it'll spawn a diamond block 6 blocks above the master. The 2nd require you surround it with stone and will turn said stone into diamonds once it sees that the structure is formed.

 

https://github.com/Lomeli12/MultiBlock-Tutorial

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.