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'm trying to make a block that, depending on its metadata, can have any light level from 0 to 15. Since each of these blocks can have a different light level, I figure I need a tile entity. But how can I make the tile entity set the light level properly? I've tried using World#setLightValue(), but that doesn't seem to have any effect, even if I add a call to World#updateLightByType() after it. How can I make this work properly? (Also, do I even need a tile entity for this, or is there a more efficient way of handling it?)

 

Here's the tile entity's code:

 

package com.IceMetalPunk.weatherworks;

import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.EnumSkyBlock;

public class TileEntitySunstone extends TileEntity {
private int metaData=0;
@Override
public void updateEntity() {
	if (this.worldObj.isRemote) { return; }
	int thisMeta=this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
	if (thisMeta!=this.metaData) {
		this.worldObj.setLightValue(EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord, thisMeta);
		this.worldObj.markBlockRangeForRenderUpdate(this.xCoord-thisMeta, this.yCoord-thisMeta, this.zCoord-thisMeta, this.xCoord+thisMeta, this.yCoord+thisMeta, this.zCoord+thisMeta);
		this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord);
		this.metaData=thisMeta;
	}
}
}

Whatever Minecraft needs, it is most likely not yet another tool tier.

You shouldn't need a TileEntity nor to set the light value, just use the method added by Forge that gives you the world and coordinates:

public int getLightValue(IBlockAccess world, int x, int y, int z) {
  int meta = world.getBlockMetadata(x, y, z);
  return value based on metadata;
}

  • Author

>_< Of course it's that simple... I didn't even know that method existed. Sorry for my noobishness, but thank you for the help! :D

Whatever Minecraft needs, it is most likely not yet another tool tier.

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.