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

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

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

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