Jump to content

Recommended Posts

Posted

Hello, i'm new to modding and i want to make my custom textured redstone lamp. From my knowledge i know that the blocks needs extending from other if you want to add similar. I get the lamp working, but when activate it, she puts the original redstone lamp texture and dont use mine. So can anyone help me ? :)

Posted

How about you post some code of what you've done :) ?

Sure :)

Here is my MainClass

 

 

 

package net.rufus.mb;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.rufus.mb.blocks.BlueBrick;
import net.rufus.mb.blocks.GreenBrick;
import net.rufus.mb.blocks.GreenLamp;
import net.rufus.mb.blocks.RedBrick;
import net.rufus.mt.CommonProxy;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod(modid = MainClass.modid, version = MainClass.version)
public class MainClass {

@SidedProxy(clientSide = "net.rufus.mb.ClientProxy", serverSide = "net.rufus.mb.CommonProxy")
public static CommonProxy proxy;

public static final String modid = "mb";
public static final String version = "1.0";

public static Block GreenBrick;
public static Block BlueBrick;
public static Block RedBrick;

public static Block GreenLamp;
public static Block GreenOre;

public static CreativeTabs MoreBlocks = new CreativeTabs("MoreBlocks"){
	public Item getTabIconItem() {
		return Item.getItemFromBlock(Blocks.acacia_stairs);
	}
};

public MainClass(){

	GreenBrick = new GreenBrick(Material.rock);
	BlueBrick = new BlueBrick(Material.rock);
	RedBrick = new RedBrick(Material.rock);

	GreenLamp = new GreenLamp(false);
	GreenOre = new GreenOre(Material.rock);

	GameRegistry.registerBlock(GreenBrick, "GreenBrick");
	GameRegistry.registerBlock(BlueBrick, "BlueBrick");
	GameRegistry.registerBlock(RedBrick, "RedBrick");

	GameRegistry.registerBlock(GreenLamp, "GreenLamp");
	GameRegistry.registerBlock(GreenOre, "GreenOre");

	GameRegistry.registerWorldGenerator(new OreGenerator(), 1);
}
}

 

 

 

And here is my GreenLamp class

 

 

package net.rufus.mb.blocks;

import net.minecraft.block.BlockRedstoneLight;
import net.minecraft.world.IBlockAccess;
import net.rufus.mb.MainClass;

public class GreenLamp extends BlockRedstoneLight {
public GreenLamp(boolean p_i45421_1_) {
	super(p_i45421_1_);
	setCreativeTab(MainClass.MoreBlocks);
	setBlockName("GreenLamp");
	setBlockTextureName(MainClass.modid + ":GreenLampIdle");
}
}

 

 

Posted

Taking a quick look at the redstone lamp code, check the onBlockAdded, onNeighborChange, and updateTick code.  You will see it is changing it to a different lamp object.  Change that to your active lamp object and everything will be all good.

width=320 height=64http://www.slothygaming.com/img/ota.png[/img]

If your grammar is shit and you blatantly don't know what you're doing, I will not help you.

Posted

Taking a quick look at the redstone lamp code, check the onBlockAdded, onNeighborChange, and updateTick code.  You will see it is changing it to a different lamp object.  Change that to your active lamp object and everything will be all good.

 

Ok, but when its ones activated then stays in that texture .. For testing i putted 3 various textures. Here is the code :

package net.rufus.mb.blocks;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockRedstoneLight;
import net.minecraft.init.Blocks;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.rufus.mb.MainClass;

public class GreenLamp extends BlockRedstoneLight {
private boolean field_150171_a;
public GreenLamp(boolean p_i45421_1_) {
	super(p_i45421_1_);
	setCreativeTab(MainClass.MoreBlocks);
	setBlockName("GreenLamp");
	setBlockTextureName(MainClass.modid + ":GreenLampIdle");
}
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_, MainClass.BlueBrick, 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_, MainClass.RedBrick, 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_, MainClass.GreenLamp, 0, 2);
        }
    }

}

Posted

Your problem is you're turning them into the other objects which are incapable of turning into lamps.  You need to declare two(2) lamps in your MainClass.  IdleLamp and ActiveLamp.  Change the code based on that.

Ok, but i maked to lamps : GreenLampON and GreenLampOFF. It works perfect but the texture isn't updating :/ And also in MainClass where i usually put the material of a block it wants boolean... When i click the fix thing it puts "false" in the brackets. And one last question. All of this needs to be in GreenLamp class right ? Then what setBlockName should i put and the texture name ?

Posted

setBlockTextureName(MainClass.modid + ":GreenLampIdle");

You are setting the texture to be GreenLampIdle.  You need to have the texture be based on the lamps state.  Do what the redstone lamp does,

.setTextureName("redstone_lamp_off")
.setTextureName("redstone_lamp_on")

You set the texture names when you initialize the redstone lamp variables.  So,

public static Block myLampOn = new BlockMyLamp(var...).setTextureName(modid + ":GreenLampIdle");
public static Block myLampOff = new BlockMyLamp(var...).setTextureName(modid + ":GreenLampActive");

 

Quick Edit: Remove

setBlockTextureName(MainClass.modid + ":GreenLampIdle");

from your BlockLamp class.

width=320 height=64http://www.slothygaming.com/img/ota.png[/img]

If your grammar is shit and you blatantly don't know what you're doing, I will not help you.

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi,  I'm using Forge 47.3.0 for Minecraft 1.20.1 I apologise if this is obvious I am very new to modding for Minecraft. I sucessfully made a mod that launched without errors or crashes (without it doing anything) but in order to add the features I need, I need to add "Custom Portal API [Forge]" as a dependency. However no matter the way I've tried to acheive this, it crashes. I am pretty sure it's not the way I'm putting it in the repositories, the dependencies or the way I'm refrencing it, as I've a hundred diffrent combinations and multiple Maven methods. And on all those diffrent variations I still get this crash: pastebin.com/UhumzZCZ Any tips would be invaluable as I've been loosing my mind over this!
    • Hi, i'm really having problems trying to set the texture to my custom item. I thought i'm doing everything correctly, but all i see is the missing texture block for my item. I am trying this for over a week now and getting really frustrated. The only time i could make the texture work, was when i used an older Forge version (52.0.1) for Minecraft (1.21.4). Was there a fundamental change for textures and models somewhere between versions that i'm missing? I started with Forge 54.1.0 and had this problem, so in my frustration i tried many things: Upgrading to Forge 54.1.1, created multiple new projects, workspaces, redownloaded everything and setting things up multiple times, as it was suggested in an older thread. Therea are no errors in the console logs, but maybe i'm blind, so i pasted the console logs to pastebin anyway: https://pastebin.com/zAM8RiUN The only time i see an error is when i change the models JSON file to an incorrect JSON which makes sense and that suggests to me it is actually reading the JSON file.   I set the github repository to public, i would be so thankful if anyone could take a look and tell me what i did wrong: https://github.com/xLorkin/teleport_pug_forge   As a note: i'm pretty new to modding, this is my first mod ever. But i'm used to programming. I had some up and downs, but through reading the documentation, using google and experimenting, i could solve all other problems. I only started modding for Minecraft because my son is such a big fan and wanted this mod.
    • Please read the FAQ (link in orange bar at top of page), and post logs as described there.
    • Hello fellow Minecrafters! I recently returned to Minecraft and realized I needed a wiki that displays basic information easily and had great user navigation. That’s why I decided to build: MinecraftSearch — a site by a Minecraft fan, for Minecraft fans. Key Features So Far Straight-to-the-Point Info: No extra fluff; just the essentials on items, mobs, recipes, loot and more. Clean & Intuitive Layout: Easy navigation so you spend less time scrolling and more time playing. Optimized Search: Search for anything—items, mobs, blocks—and get results instantly. What I’m Thinking of Adding More data/information: Catch chances for fishing rod, traveling villager trades, biomes info and a lot more. The website is still under development and need a lot more data added. Community Contributions: Potential for user-uploaded tips for items/mobs/blocks in the future. Feature Requests Welcome: Your ideas could shape how the wiki evolves! You can see my roadmap at the About page https://minecraftsearch.com/about I’d love for you to check out MinecraftSearch and see if it helps you find the info you need faster. Feedback is crucial—I want to develop this further based on what the community needs most, so please let me know what you think. Thanks, and happy crafting!
    • Instructions on how to install newer Java can be found in the FAQ
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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