Jump to content

Help to get custom red-stone lamp working


tamanor

Recommended Posts

Hi i'm have a problem with making custom Redstone Lamps. When i place the Lamp it shows the Active Lamp and not the inactive one and when i put a Lever on the block it disappears

 

Code for Lamp

 

package com.TMP.block;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import java.util.Random;

import com.TMP.creativetabs.TMPCreativeTabs;
import com.TMP.lib.Strings;



import net.minecraft.block.Block;
import net.minecraft.block.BlockRedstoneLight;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class RedRSlamp extends BlockRedstoneLight
{
    /** Whether this lamp block is the powered version. */
    private final boolean field_150171_a;

    public RedRSlamp(boolean p_i45421_1_)
    {
        super(p_i45421_1_);
        this.field_150171_a = p_i45421_1_;
	setCreativeTab(TMPCreativeTabs.TMPBlocks);
	setBlockName("RedLamp");

        if (p_i45421_1_)
        {
            this.setLightLevel(1.0F);
        }
    }
   
public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_)
    {
        if (!p_149726_1_.isRemote)
        {
            if (this.field_150171_a && !p_149726_1_.isBlockIndirectlyGettingPowered(p_149726_2_, p_149726_3_, p_149726_4_))
            {
                p_149726_1_.scheduleBlockUpdate(p_149726_2_, p_149726_3_, p_149726_4_, this, 4);
            }
            else if (!this.field_150171_a && p_149726_1_.isBlockIndirectlyGettingPowered(p_149726_2_, p_149726_3_, p_149726_4_))
            {
                p_149726_1_.setBlock(p_149726_2_, p_149726_3_, p_149726_4_, TMPBlocks.redrsActive, 0, 2);
            }
        }
    }

public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_)
    {
        if (!p_149695_1_.isRemote)
        {
            if (this.field_150171_a && !p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_))
            {
                p_149695_1_.scheduleBlockUpdate(p_149695_2_, p_149695_3_, p_149695_4_, this, 4);
            }
            else if (!this.field_150171_a && p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_))
            {
                p_149695_1_.setBlock(p_149695_2_, p_149695_3_, p_149695_4_, TMPBlocks.redrsActive, 0, 2);
            }
        }
    }

public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_)
    {
        if (!p_149674_1_.isRemote && this.field_150171_a && !p_149674_1_.isBlockIndirectlyGettingPowered(p_149674_2_, p_149674_3_, p_149674_4_))
        {
            p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, TMPBlocks.redrsIdle, 0, 2);
        }
    }

}

 

Code for Blocks Class

 

package com.TMP.block;

import com.TMP.creativetabs.TMPCreativeTabs;
import com.TMP.lib.Strings;

import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRedstoneLight;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;

public class TMPBlocks {

public static void mainRegistry(){
	initialiseBlock();
	registerBlock();

}

public static Block gitaniumOre;

public static Block redrsIdle;
public static Block redrsActive;


public static void initialiseBlock(){

	redrsActive = new RedRSlamp(true).setBlockTextureName(Strings.MODID + ":RedRSActive");
	redrsIdle = new RedRSlamp(false).setBlockTextureName(Strings.MODID + ":RedRSIdle");


}

public static void registerBlock(){

	GameRegistry.registerBlock(redrsIdle, redrsIdle.getUnlocalizedName());
	GameRegistry.registerBlock(redrsActive, redrsActive.getUnlocalizedName());


}
}

 

Edit: Just found out it not just when i put a lever on it. It disappears if i just right click it with anything even empty hand

Link to comment
Share on other sites

If i remove the this.field_150171_a = p_i45421_1_;

 

from the code it lets me place the block and place levers and right click it but the lever does not turn the lamp on or off and still when i place the lamp the places it as the Active Lamp and not the Idle Lamp???

Link to comment
Share on other sites

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.