Jump to content

[1.7.10] Custom signs


winnetrie

Recommended Posts

I'm trying to create custom signs but i have 2 problems:

1)-The sign that is on the ground has no stick attached

2)-The sign doesn't show the texture i say

 

I know i have to register the sign like this:

GameRegistry.registerBlock(wood_sign_wall= new CustomSign(TileEntitySign.class, false, Blocks.cobblestone,0).setBlockName("wood_sign_wall"), "wood_sign_wall" );
	GameRegistry.registerBlock(wood_sign_standing= new CustomSign(TileEntitySign.class, true, Blocks.cobblestone,0).setBlockName("wood_sign_standing"), "wood_sign_standing" );

And also an itemsign like this:

GameRegistry.registerItem(wood_item_sign = new CustomItemSign().setUnlocalizedName("wood_item_sign").setTextureName(tem.modid+":"+"flux"), "wood_item_sign");

The texture i give here for the item is just for testing purpose and i think it doesn't even matter.

now for the classes i have this

 

CustomSign (block):

 

public class CustomSign extends BlockSign{

private Block plank;
private int meta;
protected CustomSign(Class signclass, boolean bool, Block block, int meta) {
	super(signclass, bool);
	this.plank=block;
	this.meta=meta;

}

@Override
@SideOnly(Side.CLIENT)
    public IIcon getIcon(int side, int meta)
    {
	return this.plank.getIcon(side, this.meta);
    }

    @Override
    public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
    {
        return Items.sign;
    }

    
    
@Override
@SideOnly(Side.CLIENT)
    public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_)
    {
        return Items.sign;
    }

@Override
    @SideOnly(Side.CLIENT)
    public void registerBlockIcons(IIconRegister reg) {

}
}

 

 

and the itemclass:

 

public class CustomItemSign  extends ItemSign{

public CustomItemSign()
    {
        this.maxStackSize = 16;
        this.setCreativeTab(CreativeTabs.tabDecorations);
    }

    /**
     * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
     * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
     */
@Override
    public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float pointX, float pointY, float pointZ)
    {
        if (side == 0)
        {
            return false;
        }
        else if (!world.getBlock(x, y, z).getMaterial().isSolid())
        {
            return false;
        }
        else
        {
            if (side == 1)
            {
                ++y;
            }

            if (side == 2)
            {
                --z;
            }

            if (side == 3)
            {
                ++z;
            }

            if (side == 4)
            {
                --x;
            }

            if (side == 5)
            {
                ++x;
            }

            if (!player.canPlayerEdit(x, y, z, side, stack))
            {
                return false;
            }
            else if (!TemBlocks.wood_sign_standing.canPlaceBlockAt(world, x, y, z))
            {
                return false;
            }
            else if (world.isRemote)
            {
                return true;
            }
            else
            {
                if (side == 1)
                {
                    int i1 = MathHelper.floor_double((double)((player.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
                    world.setBlock(x, y, z, TemBlocks.wood_sign_standing, i1, 3);
                }
                else
                {
                	world.setBlock(x, y, z, TemBlocks.wood_sign_wall, side, 3);
                }

                --stack.stackSize;
                TileEntitySign tileentitysign = (TileEntitySign)world.getTileEntity(x, y, z);

                if (tileentitysign != null)
                {
                	player.func_146100_a(tileentitysign);
                }

                return true;
            }
        }
    }

}

 

The function of the sign  is working good.

It just doesn't render well and /or is misplaced on the ground here a picture

 

0fztwmy

 

Link to comment
Share on other sites

Go through and deobfuscate that back to readable variable names. It'll be a lot easier for use to help you figure out what's wrong.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Go through and deobfuscate that back to readable variable names. It'll be a lot easier for use to help you figure out what's wrong.

 

i updated the code, but i do not know what func_146100_a is, but i think it doesn't matter.

 

I don't think does gives you a better view, why the pole isn't rendering and why my own texture isn't rendering, but you asked for readable variables, so here they are!

Link to comment
Share on other sites

I suspect that you're using Vanilla's renderer for this and it does a "if block is X { render standing } else { render wall }" type check.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Well, i was using no renderer. I didn't knew i had to. How should i know?  :P Thank you for pointing me in that direction.

I have created my signrendering class now, but i do not know how i register it?

Can you help me with that?

 

EDIT:

Ok i found how to register the render and it works,but....yeah there is a "but" again.

 

My sign still has not the custom texture and now my sign is acting strange.

If i place the sign i'll get the gui where i can type my text on the sign, but it appears the sign on the gui screen turns around his axis equal as the player's angle.

 

Customs signs are harder as i thought....

Link to comment
Share on other sites

Post code and picture.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I tried to play a mod for forge 1.20.2 and the mod didn't work, fix this please.
    • EntityRenders requires an EntityRenderProvider. This is what I have: @Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) public static class ClientModEvents { @SubscribeEvent public static void clientSetup(FMLClientSetupEvent event) { EntityRenderers.register(HOSE.get(), new HoseEntityRenderFactory()); } private static class HoseEntityRenderFactory implements EntityRendererProvider<HoseEntity> { @Override public EntityRenderer<HoseEntity> create(Context context) { return new HoseEntityRenderer<>(context); } } } Replace HoseEntity with your own entity. If you're doing multiple try doing generics (though untested).
    • First off, I know should probably be able to debug this on my own, but this is my first mod, and I couldn't figure it out for multiple days now. What I'm trying to do, is to modify the default minecart by replacing it with a slightly different version, but I'm stuck 1 step before that, that being "cloning" the minecart as a separate Entity/Item. Here you can see a GitHub gist of all relevant files: https://gist.github.com/Kipama/cd39127e8891715a3006fa990ca7ff14 If there are files missing or access isn't working as intended, please let me know! In the Gist you can find the following files: -CustomMinecartEntity.java:        This file extends AbstractMinecart and is a clone of the vanilla minecart entity. I know I should override the minecart entity directly, but as this should work rn, I didn't change it yet. -CustomMinecartRenderer.java:  Basically vanilla MinecartRenderer with a Custom slapped on it, extends MinecraftRenderer. -ModEntities.java:                         This is where the new Entity gets added to the deferred register ENTITY_TYPES. -ModernMinecarts.java:               The main mod file. Relevant part is at the bottom, where I try to use onClientSetup to register the new Entity using EntityRenderers.register(). That last part is where my problem begins. When I try to register the new entity using EntityRenderers.register(ModEntities.CUSTOM_MINECART_ENTITY.get(), CustomMinecartRenderer::new); I get a syntax Error saying the provided and required types don't match. These are the required and provided types: ModEntities.CUSTOM_MINECART_ENTITY.get(): Required: EntityType<? extends T> Provided:EntityType<CustomMinecartEntity> CustomMinecartRenderer::new: Required: EntityRendererProvider<T> Provided:<method reference   So far I looked at 2 different Git repositories implementing custom entities, but haven't been able to figure out what I'm doing wrong. Any answers, suggestions and ridicules appreciated.
    • Yes, it is. I found out how to do it. (for Forge 1.20.1) Add this to main class constructor: // ... MinecraftForge.EVENT_BUS.<PlayerInteractEvent.EntityInteract>addListener(e -> { Player playerWhoUsed = e.getEntity(); ItemStack usedItemStack = e.getItemStack(); Entity entityThatWasClicked = e.getTarget(); if (usedItemStack.getItem() instanceof YourItem item) { // your code... e.setCancelled(true); // you can remove this if you want to continue interaction } } // ...
    • Hi there, I'm hoping to create a block that renders a fake skybox, blocking anything behind it. There are a couple of mods that already do this, but they are very outdated. One example: https://github.com/Elix-x/Skyblocks/ https://www.curseforge.com/minecraft/mc-mods/skyblocks I'm not familiar enough with rendering to be able to port it. Is there anyone who can point me in the right direction? Any help would be appreciated.
  • Topics

×
×
  • Create New...

Important Information

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