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,

 

I am making a "multiblock" structure that requires 3 blocks one of top of the other to make it full, if it full it changes a variable called fullPole to true

 

I aint sure why, i change the variable when the last block is placed, but when i try to read it from other class it doesnt work.

 

public class TileEntityShowerPole  extends TileEntity 
{
public  boolean fullPole;
public void readFromNBT(NBTTagCompound nbtdata)
    {
        super.readFromNBT(nbtdata);
        this.fullPole = nbtdata.getBoolean("fullPole");
    }

    public void writeToNBT(NBTTagCompound nbtdata)
    {
        super.writeToNBT(nbtdata);
        nbtdata.setBoolean("fullPole", this.fullPole);
    }
public TileEntityShowerPole()
{
	fullPole=false;
}
public  void TestFullPole(World world,int x,int y,int z)
{
	if (world.getBlock(x, y-1, z) == OthersMod.showerPole)
	{
		if (world.getBlock(x, y-2, z) == OthersMod.showerPole)
		{
			fullPole=true;
			return;
		}
	}
	fullPole=false;
}
}

 

 

When i try to read it like

 

@Override
    public boolean canPlaceBlockAt(World world, int x, int y, int z)
    {
TileEntityShowerPole tileEntityShowerPole = (TileEntityShowerPole)world.getTileEntity(x, y, z-1);
        	if (tileEntityShowerPole!=null)     
        		System.out.println(tileEntityShowerPole.fullPole);
}

i always get false. when i right click the block

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_)
{
	if(!world.isRemote){
        TileEntityShowerPole tileEntityShowerPole = (TileEntityShowerPole)world.getTileEntity(x, y, z);
        if (tileEntityShowerPole!=null) 
        	System.out.println(tileEntityShowerPole.fullPole);
	}
	return true;
}

 

i get true.

 

i am running the TestFullPole on the ShowerPole onBlockAdded

 

Someone know what i am doing wrong?

 

 

 

Edit: The z-1 thing on can place is intentional, after printing the coordinates its the exact same.

  • Author

I fixed the issue, thanks anyways. the problem was with syncing to server

 

@Override

    public Packet getDescriptionPacket()

    {

    NBTTagCompound var1 = new NBTTagCompound();

    this.writeToNBT(var1);

    return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 2, var1);

    }

    @Override

    public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet)

    {

    super.onDataPacket(net, packet);

readFromNBT(packet.func_148857_g());

    }

 

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.