Jump to content

[SOLVED] Trouble With Creating Block Similar To Minecraft Torch


Recommended Posts

Posted (edited)

I am learning JAVA(from maybe a month now) so i am totally new to all forge things. So, I wanted to ask how do you get some properties, namely the minecraft torch property of different textures when placed on side of blocks and the one in which it pops off when the block it is placed on is broken. I tried copying some code which i thought was relavent to the property of placing on side of blocks, the one using enumfacing, but my game used to crash saying that enum is never used and is not in blockstate container i am currently on my phone so can't attach the files but will do so if requiered. Please do tell me if there is something i am doing stupidly wrong. i also tried adding all the torch code ,without the block properties and stuff of course, but it did not render the model tgis time. the enumfacing worked though. Any help will be greatly appreciated

[EDIT]

I forgot to mention that i am making a custom model block named 'Lantern'. Also, I wanted it to be placeble on the downside of blocks, which cannot be done with minecraft torch

Edited by Spacejet
forgot to write something important
Posted

Its usually customary to post your code and any errors you get, because we're not psychic.

I mean, you might be and won't need those things from people you're helping...

But we're not.

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.

Posted

My Apologies. Here is the code i mentioned. everything except the texture is working just fine.

  Reveal hidden contents

This is the blockstates json file:

  Reveal hidden contents

And this is the model file for lantern:

  Reveal hidden contents

And this for lantern_wall

  Reveal hidden contents

even enumfacing is working fine, but the models are not

this is how they look:2018-02-20_15_34_59.thumb.png.3d24f334633f9691f2ac74dc735e49ce.png2018-02-20_15_35_15.thumb.png.b66e2ecc7c249ebb78f7af51fae324b8.png

 

The model was working fine before i tried to add the torch functionality. Then it has stayed broken, even though i reverted all my changes. Hope this was enough.

Posted

Your blockstate doesn't have a modid for the model locations and your lantern_wall model doesn't have modids for the texture locations.

 

Also, in your normal lantern model, there's no reason to mask your modid with (modid). It only makes it harder for us to help you (e.g. spot typos).

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

sorry. i don't know what i was thinking when i masked my modid because it is visible throughout the other files.:PxD

and yes i noticed after i posted that the modid was missing. i'll  change that and update you guys

Posted

Hi. So I Put in the modid but it is still not working. The texture is still as it was. I think it has something to do with me copying the code from BlockTorch.java . Any help is greatly appriciated. :)

Posted

These type of errors are usually do to typos. So the only way we can debug is for you to post your EXACT code. If you've edited it for modid then please re-post it.

 

Otherwise, are there errors in your console? Is it complaining about a missing model, a missing model for a variant, or a missing texture? Or does it complain about a malformed JSON?

 

Also, I noticed your model has a lot of cubes with repeated names. I'm not sure but maybe they need to be unique -- I know in the past tools like Techne would complain if you have duplicate names.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

it does not matter if you have cubes with same name, feom my ecperience. I actually have not looked at the console but i was also thinking that it must be something with the model. I thinkthe game is searching for the model in minecraft's models folder rather than mine. The items could be showing up because the parent is set to my model. I'll change the cubes and check the console and report back.

Posted

hi. so i looked at the console and it says:

 

Caused by: net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model minecraft:block/lantern with loader VanillaLoader.INSTANCE, skipping

 

so i checked my blockstates file and found that i had not put the modid. actually i had put the modid there, but then the next day i replaced all of my lantern's files from local history, so it is now working :).

 

I am trying things to make my block placeable under blocks, unlike torches. will update real soon

Posted

and i did it! it is literally 5 seconds after i posted the last comment and i did it!

 

I replaced 

  On 2/20/2018 at 9:45 PM, Spacejet said:

public static final PropertyDirection FACING = PropertyDirection.create("facing", new Predicate<EnumFacing>()
    {
        public boolean apply(@Nullable EnumFacing p_apply_1_)
        {
            return p_apply_1_ != EnumFacing.DOWN;
        }
    });

Expand  

with

public static final PropertyDirection FACING = BlockDirectional.FACING;

 

and added

 

 
        else if (facing.equals(EnumFacing.DOWN))
        {
            return true;

        {

 

to 

 

  On 2/20/2018 at 9:45 PM, Spacejet said:

private boolean canPlaceAt(World worldIn, BlockPos pos, EnumFacing facing)
    {
        BlockPos blockpos = pos.offset(facing.getOpposite());
        IBlockState iblockstate = worldIn.getBlockState(blockpos);
        Block block = iblockstate.getBlock();
        BlockFaceShape blockfaceshape = iblockstate.getBlockFaceShape(worldIn, blockpos, facing);

        if (facing.equals(EnumFacing.UP) && this.canPlaceOn(worldIn, blockpos))
        {
            return true;
        }
        else if (facing != EnumFacing.UP && facing != EnumFacing.DOWN)
        {
            return !isExceptBlockForAttachWithPiston(block) && blockfaceshape == BlockFaceShape.SOLID;
        }
        else
        {
            return false;
        }
    }

Expand  

 

right below 

 

else if (facing != EnumFacing.UP && facing != EnumFacing.DOWN)
        {
            return !isExceptBlockForAttachWithPiston(block) && blockfaceshape == BlockFaceShape.SOLID;
        }

here is the whole code for anyone in trouble like me:P

  Reveal hidden contents

i have not set the correct values for axisalignedbb yet, but you wont need it anyway. the rotation was possible due to draco18s. Thanks a lot. in a different thread, he said

  On 11/1/2017 at 4:31 PM, Draco18s said:

2) Dispensers don't use horizontal facing, they use omnidirectional facing: that is, they can face UP and DOWN too.

Expand  

so i went to blockdispenser.java and got BlockDirectional.FACING;

 

Thanks a lot everybody. This means a lot to me!

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.