Jump to content

Recommended Posts

Posted

Hi!

 

I wanted to add a few custom signs to my mod so I looked a little at the default code and tried to create them as I normally do.


    public static void init() {
public static Block spruce_standing_sign;
public static Block spruce_wall_sign;

    }
    public static void register() {
spruce_standing_sign = new BlockStandingSign().setUnlocalizedName("spruce_standing_sign");
spruce_wall_sign = new BlockWallSign().setUnlocalizedName("spruce_wall_sign");
    }

 

Since the BlockStandingSign and BlockWallSign were public and I didn't need to change anything in them I didn't create my own blockclasses for them. The only thing I changed was ItemSign were I overrode the "onItemUse" method so it would place my custom sign.

@Override
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
	if (side == EnumFacing.DOWN)
	{
		return false;
	}
	else if (!worldIn.getBlockState(pos).getBlock().getMaterial().isSolid())
	{
		return false;
	}
	else
	{
		pos = pos.offset(side);

		if (!playerIn.canPlayerEdit(pos, side, stack))
		{
			return false;
		}
		else if (!Blocks.standing_sign.canPlaceBlockAt(worldIn, pos))
		{
			return false;
		}
		else if (worldIn.isRemote)
		{
			return true;
		}
		else
		{
			if (side == EnumFacing.UP)
			{
				int i = MathHelper.floor_double((double)((playerIn.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
				worldIn.setBlockState(pos, SBMBlocks.spruce_standing_sign.getDefaultState().withProperty(BlockStandingSign.ROTATION, Integer.valueOf(i)), 3);
			}
			else
			{
				worldIn.setBlockState(pos, SBMBlocks.spruce_wall_sign.getDefaultState().withProperty(BlockWallSign.FACING, side), 3);
			}

			--stack.stackSize;
			TileEntity tileentity = worldIn.getTileEntity(pos);

			if (tileentity instanceof TileEntitySign && !ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack))
			{
				playerIn.openEditSign((TileEntitySign)tileentity);
			}

			return true;
		}
	}
}

}

This worked great on walls but when I tried to place a standing sign it had the right hitbox, was the right block according to F3 but it had no pole and wasn't rotated properly. Basically it was a floating wallsign. I cannot figure out what's wrong as I have not changed anything except the item which I have checked countless times. I'm a beginner though so it might just be some silly mistake I have missed.

 

Oh and also, how would I go about adding a custom texture to it? Signs don't seem to have models.

Posted

Signs are rendered by

TileEntitySignRenderer

, this only renders a standing sign if the

Block

is

Blocks.standing_sign

.

 

I suggest adapting the rendering code from this class into your own

TESR

that uses

instanceof

to check whether the sign is standing or not and uses your own texture. Use

ClientRegistry.bindTileEntitySpecialRenderer

from your client proxy to register the

TESR

.

 

You'll need to create your own

TileEntity

class that extends

TileEntitySign

and

Block

classes that extend

BlockWallSign

/

BlockStandingSign

and override

Block#createTileEntity(World, IBlockState)

to create your

TileEntity

instead of

TileEntitySign

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Signs are rendered by

TileEntitySignRenderer

, this only renders a standing sign if the

Block

is

Blocks.standing_sign

.

 

I suggest adapting the rendering code from this class into your own

TESR

that uses

instanceof

to check whether the sign is standing or not and uses your own texture. Use

ClientRegistry.bindTileEntitySpecialRenderer

from your client proxy to register the

TESR

.

 

You'll need to create your own

TileEntity

class that extends

TileEntitySign

and

Block

classes that extend

BlockWallSign

/

BlockStandingSign

and override

Block#createTileEntity(World, IBlockState)

to create your

TileEntity

instead of

TileEntitySign

.

 

That seems to have done it, thanks! :D Now my only problem is that the particle effects from breaking the block are pink and black. Since the signs don't have a blockmodel I'm not sure how to change that.

Posted

Signs are rendered by

TileEntitySignRenderer

, this only renders a standing sign if the

Block

is

Blocks.standing_sign

.

 

I suggest adapting the rendering code from this class into your own

TESR

that uses

instanceof

to check whether the sign is standing or not and uses your own texture. Use

ClientRegistry.bindTileEntitySpecialRenderer

from your client proxy to register the

TESR

.

 

You'll need to create your own

TileEntity

class that extends

TileEntitySign

and

Block

classes that extend

BlockWallSign

/

BlockStandingSign

and override

Block#createTileEntity(World, IBlockState)

to create your

TileEntity

instead of

TileEntitySign

.

 

That seems to have done it, thanks! :D Now my only problem is that the particle effects from breaking the block are pink and black. Since the signs don't have a blockmodel I'm not sure how to change that.

 

I actually noticed right now that the text on the sign doesn't save when i exit the world, the log says:

[19:18:04] [server thread/ERROR] [FML]: A TileEntity type nu.aksberg.sbm.tileentity.TileEntitySpruceSign has throw an exception trying to write state. It will not persist. Report this to the mod author
java.lang.RuntimeException: class nu.aksberg.sbm.tileentity.TileEntitySpruceSign is missing a mapping! This is a bug!

What's that all about? ???

Posted

That seems to have done it, thanks! :D Now my only problem is that the particle effects from breaking the block are pink and black. Since the signs don't have a blockmodel I'm not sure how to change that.

 

It looks like Minecraft hardcodes the textures for its blocks that don't use a standard model (e.g. signs, liquids). You can probably create a dummy JSON model and specify its

"particle"

texture. You'll need a blockstates file that tells Minecraft to use the model (which won't actually be rendered) and an

IStateMapper

that ignores the state and always maps to the same variant of the blockstates file.

 

I actually noticed right now that the text on the sign doesn't save when i exit the world, the log says:

[19:18:04] [server thread/ERROR] [FML]: A TileEntity type nu.aksberg.sbm.tileentity.TileEntitySpruceSign has throw an exception trying to write state. It will not persist. Report this to the mod author
java.lang.RuntimeException: class nu.aksberg.sbm.tileentity.TileEntitySpruceSign is missing a mapping! This is a bug!

What's that all about? ???

 

Every

TileEntity

you add must be registered using

GameRegister.registerTileEntity

. Make sure you include your mod ID in the

TileEntity

's ID so you don't conflict with other mods.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

It looks like Minecraft hardcodes the textures for its blocks that don't use a standard model (e.g. signs, liquids). You can probably create a dummy JSON model and specify its

"particle"

texture. You'll need a blockstates file that tells Minecraft to use the model (which won't actually be rendered) and an

IStateMapper

that ignores the state and always maps to the same variant of the blockstates file.

I have made a model file called spruce_sign.json:

{
    "parent": "block/cube_all",
    "textures": {
        "particle": "blocks/planks_spruce"
    }
}

and a blockstate also called spruce_sign.json:

{
    "variants": {
        "normal": { "model": "sbm:spruce_sign" }
    }
}

but I don't quite understand how to use

IStateMapper

. Could you explain in a little more detail?

Posted

but I don't quite understand how to use

IStateMapper

. Could you explain in a little more detail?

 

Create an anonymous class that extends

StateMapperBase

and override the

getModelResourceLocation

method to return a

ModelResourceLocation

pointing to the variant in your blockstates file. In this case, use the

ModelResourceLocation(String resourceName, String variant)

constructor with

"sbm:spruce_sign"

as the resource name (i.e. assets/sbm/blockstates/spruce_sign.json)  and

"normal"

as the variant.

 

Call

ModelLoader.setCustomStateMapper

from your client proxy in preInit with your

Block

as the first argument and this anonymous class as the second argument.

 

I do something similar for my fluid blocks here.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

but I don't quite understand how to use

IStateMapper

. Could you explain in a little more detail?

 

Create an anonymous class that extends

StateMapperBase

and override the

getModelResourceLocation

method to return a

ModelResourceLocation

pointing to the variant in your blockstates file. In this case, use the

ModelResourceLocation(String resourceName, String variant)

constructor with

"sbm:spruce_sign"

as the resource name (i.e. assets/sbm/blockstates/spruce_sign.json)  and

"normal"

as the variant.

 

Call

ModelLoader.setCustomStateMapper

from your client proxy in preInit with your

Block

as the first argument and this anonymous class as the second argument.

 

I do something similar for my fluid blocks here.

 

Okay, everything seems to work now! :D Thanks a bunch for all the help, I wouldn't have been able to do this without it.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • "I want to understand how complex mods with ASM transformation and coremods work, such as Xray or AntiXray. Why do they break when you simply rename packages? What features of their architecture make refactoring difficult? And what techniques are used to protect these mods? I am interested in technical aspects in order to better understand the bytecode and Forge loader system."
    • I can't figure out if you're looking for help trying to steal someone elses work, or cheat at the game....
    • Title: Why Is It So Hard to Rename and Restructure Mods Like Xray or AntiXray? 🤔 Post text: Hey everyone! I’ve been digging into Minecraft modding for a while and have one big question that I can’t figure out on my own. Maybe someone with more experience could help or give me some advice. Here’s the issue: When I take a “normal” Minecraft mod — for example, one that just adds some blocks or new items — I can easily change its structure, package names, or even rebrand it entirely. It’s straightforward. But as soon as I try this with cheat-type mods like XrayMod or AntiXray, everything falls apart. Even if I just rename the classes, refactor the packages, or hide its identity somehow, the mod either breaks or stops working properly. XrayMod in particular is proving to be a nightmare to modify without losing its core function. So my question is — why is this so much harder with cheat mods like Xray? Is there something fundamentally different about how they’re coded, loaded, or protected that prevents simple renaming or restructuring? And if so, how can I actually learn to understand someone else’s cheat mod enough to safely refactor it without breaking the core features? I’ve already been spending over two months trying to figure this out and haven’t gotten anywhere. It feels like there must be some trick or knowledge I’m missing. Would really appreciate any thoughts, tips, or references — maybe there are guides or techniques for understanding cheat-mod internals? Or if you’ve successfully “disguised” a cheat mod like Xray before, I’d love to hear how you did it. Thanks in advance for any help or discussion. ✌️
    • just started making cinamatic contect check it out on my channel or check out my facebook page    Humbug City Minecraft Youtube https://www.youtube.com/watch?v=v2N6OveKwno https://www.facebook.com/profile.php?id=61575866982337  
    • Where did you get the schematic? Source/Link? And do use an own modpack or a pre-configured from curseforge? If yes, which one On a later time, I can make some tests on my own - but I need the schematic and the modpack name
  • Topics

×
×
  • Create New...

Important Information

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