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 am working on making a lamp running on gas, I got 1 for it being inactive that has no light level, and I got 1 for when it is on with light level.

 

But when it renders I get no light spreading, I have checked it so it says "Light level 15"

 

package aerosteam.blocks;

import aerosteam.AeroSteam;
import aerosteam.items.ItemsAS;
import aerosteam.tileentity.TileEntityFirePlace;
import aerosteam.tileentity.TileEntityGasLamp;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import static net.minecraftforge.common.util.ForgeDirection.*;

public class DeviceGasLamp extends Block implements ITileEntityProvider
{
    private static final String __OBFID = "CL_00000325";
    public boolean isActive;
private static boolean keepInventory;
    
    public DeviceGasLamp(boolean active)
    {
        super(Material.circuits);
        this.setTickRandomly(true);
	System.out.println("state is: " + active);
        if (active){
        	this.setLightLevel(1F);    
    		System.out.println("light1");    	
        }
        if (!active){
        	this.setCreativeTab(AeroSteam.aeroTab);
        }else{
        	this.setLightLevel(1F);
        	this.setCreativeTab(AeroSteam.aeroTab);
    		System.out.println("light2");
        }
        this.isActive=active;
	System.out.println("light at: " + this.getLightValue());
    }
    public boolean isOpaqueCube()
    {
        return false;
    }

    /**
     * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
     */
    public boolean renderAsNormalBlock()
    {
        return false;
    }	
    public void ChangeState(World world, int x, int y, int z, boolean state){
    	int i=world.getBlockMetadata(x, y, z);
	if (!world.isRemote) System.out.println("Gas lamp changed state to " + state);
	TileEntity entity = world.getTileEntity(x, y, z);
	keepInventory=true;
	if(state){
		world.setBlock(x,y,z,BlocksAS.deviceGasLampactive);
	}else{
		world.setBlock(x,y,z,BlocksAS.deviceGasLampidle);
	}
	keepInventory=false;
	world.setBlockMetadataWithNotify(x, y, z, i, 3);
	if(entity != null){
		entity.validate();
		world.setTileEntity(x, y, z, entity);
	}
    }
    /**
     * The type of render function that is called for this block
     */
    public int getRenderType()
    {
        return -2;
    }
public boolean 	onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ){
	if (player.getHeldItem() != null){
		if (player.getHeldItem().getItem() == ItemsAS.toolWrench){
			if (!world.isRemote) System.out.println("light measurement: " + this.getLightValue());
		}
	}
	return true;
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
	return new TileEntityGasLamp();
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconregister){
	this.blockIcon = iconregister.registerIcon(AeroSteam.MODID + ":" + "GasLamp");
}
@SideOnly(Side.CLIENT)
    public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_)
    {
	if (this.isActive){
        double d0 = (double)((float)p_149734_2_ + 0.5F);
        double d1 = (double)((float)p_149734_3_ + 0.7F);
        double d2 = (double)((float)p_149734_4_ + 0.5F);
        double d3 = 0.2199999988079071D;
        double d4 = 0.27000001072883606D;

        p_149734_1_.spawnParticle("smoke", d0, d1, d2+0.1F, 0.0D, 0.0D, 0.0D);
        p_149734_1_.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
        p_149734_1_.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
        p_149734_1_.spawnParticle("flame", d0, d1-0.15F, d2, 0.0D, 0.0D, 0.0D);			
	}
    }
}

Hi

 

Are you sure you're placing BlocksAS.deviceGasLampactive in the world, and are you sure that you created deviceGasLampactive with true in the constructor?

 

I'd suggest you comment out all that switching logic first off and just try to create a block with light level 15.  If that doesn't work, there's a bigger problem somewhere

 

BTW delete this -

private static final String __OBFID = "CL_00000325";

it is used by the (de)obfuscation process for vanilla blocks only and will cause you problems if you include it in your own classes.

 

-TGG

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.