Jump to content

[1.8][SOLVED]A textured block that changes relative to the players position?


Looke81

Recommended Posts

Due to the texture changes in 1.8 with .json files i have not been able to update my block that when placed faces the player. The only working example i can find of this is the vanilla furnace but I cant see were it references the json file for the furnace. If anyone has a working example or explain to me how you go about doing this now that would be very usefull.

BioWarfare Mod: http://goo.gl/BYWQty

Link to comment
Share on other sites

Hi

 

They use a FACING variant.

 

You might find this tutorial project useful - see MBE03

https://github.com/TheGreyGhost/MinecraftByExample

 

Alternatively, if you want to look at the vanilla furnace, the key bits are

 

furnace.json::
{
    "variants": {
        "facing=north": { "model": "furnace" },
        "facing=south": { "model": "furnace", "y": 180 },
        "facing=west":  { "model": "furnace", "y": 270 },
        "facing=east":  { "model": "furnace", "y": 90 }
    }
}

BlockFurnace::
    public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);

    private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state)

    public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
    {
        worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);  // here

 

You might need to do some background reading first if you're new to BlockStates; there are quite a few things you have to get exactly right before it will work.

 

-TGG

Link to comment
Share on other sites

  • 2 weeks later...

Ok i think i am almost there but now the texture doesnt load and i get this message in the console and i know it cant load the block model but i dont have a clue why not.

 

[18:41:55] [Client thread/ERROR] [FML]: Exception loading model biowarfare:block/block_MicrobeExtractorIdle with loader instance, skipping

com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated object at line 5 column 4

at com.google.gson.internal.Streams.parse(Streams.java:56) ~[streams.class:?]

at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:54) ~[TreeTypeAdapter.class:?]

at com.google.gson.Gson.fromJson(Gson.java:803) ~[Gson.class:?]

at com.google.gson.Gson.fromJson(Gson.java:741) ~[Gson.class:?]

at net.minecraft.client.renderer.block.model.ModelBlock.deserialize(ModelBlock.java:47) ~[ModelBlock.class:?]

at net.minecraft.client.resources.model.ModelBakery.loadModel(ModelBakery.java:269) ~[ModelBakery.class:?]

at net.minecraftforge.client.model.ModelLoader.access$900(ModelLoader.java:65) ~[ModelLoader.class:?]

at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:449) ~[ModelLoader$VanillaLoader.class:?]

at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:92) [ModelLoaderRegistry.class:?]

at net.minecraftforge.client.model.ModelLoader.loadAnyModel(ModelLoader.java:185) [ModelLoader.class:?]

at net.minecraftforge.client.model.ModelLoader.getModel(ModelLoader.java:168) [ModelLoader.class:?]

at net.minecraftforge.client.model.ModelLoader.loadAnyModel(ModelLoader.java:188) [ModelLoader.class:?]

at net.minecraftforge.client.model.ModelLoader.getModel(ModelLoader.java:168) [ModelLoader.class:?]

at net.minecraftforge.client.model.ModelLoader.loadItems(ModelLoader.java:156) [ModelLoader.class:?]

at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:90) [ModelLoader.class:?]

at net.minecraft.client.resources.model.ModelManager.onResourceManagerReload(ModelManager.java:29) [ModelManager.class:?]

at net.minecraft.client.resources.SimpleReloadableResourceManager.notifyReloadListeners(SimpleReloadableResourceManager.java:134) [simpleReloadableResourceManager.class:?]

at net.minecraft.client.resources.SimpleReloadableResourceManager.reloadResources(SimpleReloadableResourceManager.java:118) [simpleReloadableResourceManager.class:?]

at net.minecraft.client.Minecraft.refreshResources(Minecraft.java:767) [Minecraft.class:?]

at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:306) [FMLClientHandler.class:?]

at net.minecraft.client.Minecraft.startGame(Minecraft.java:521) [Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:356) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_51]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_51]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_51]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_51]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]

at GradleStart.main(Unknown Source) [start/:?]

Caused by: com.google.gson.stream.MalformedJsonException: Unterminated object at line 5 column 4

at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1505) ~[JsonReader.class:?]

at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:480) ~[JsonReader.class:?]

at com.google.gson.stream.JsonReader.hasNext(JsonReader.java:403) ~[JsonReader.class:?]

at com.google.gson.internal.bind.TypeAdapters$25.read(TypeAdapters.java:666) ~[TypeAdapters$25.class:?]

at com.google.gson.internal.bind.TypeAdapters$25.read(TypeAdapters.java:667) ~[TypeAdapters$25.class:?]

at com.google.gson.internal.bind.TypeAdapters$25.read(TypeAdapters.java:642) ~[TypeAdapters$25.class:?]

at com.google.gson.internal.Streams.parse(Streams.java:44) ~[streams.class:?]

... 30 more

BioWarfare Mod: http://goo.gl/BYWQty

Link to comment
Share on other sites

And your json file?

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

Blockstate:

 

{

    "variants": {

        "facing=north": { "model": "block_MicrobeExtractorIdle" },

        "facing=south": { "model": "block_MicrobeExtractorIdle", "y": 180 },

        "facing=west":  { "model": "block_MicrobeExtractorIdle", "y": 270 },

        "facing=east":  { "model": "block_MicrobeExtractorIdle", "y": 90 }

    }

}

 

Blockmodel:

 

{

    "parent":"block/orientable",

"textures": {

"top": "biowarfare:blocks/block_MicrobeExtractorTop"

"front": "biowarfare:blocks/block_MicrobeExtractorFrontOff"

"side": "biowarfare:blocks/block_MicrobeExtractorSide"

}

}

BioWarfare Mod: http://goo.gl/BYWQty

Link to comment
Share on other sites

You're missing some commas down in your "textures" section.

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

just went through the guide and i got to step 7 straight away because there is nothing in the console log and i'm pretty sure i have the block model right now. So that leaves me at step six and thats what im doing now i guess and i think its something to do with my class so if someone could see if I've made a mistake there.

 

http://pastebin.com/Za9SBWbq

 

BioWarfare Mod: http://goo.gl/BYWQty

Link to comment
Share on other sites

Hi

 

Pls post your latest versions of:

1) Screenshots (1=block placed down, 2=block held in your hand as an item)

2) Console error log

3) your blockstates.json

4) your block model file

5) your block registration code

 

-TGG

 

PS it's probably not your MicrobeExtractor class, unless you're doing something very strange

Link to comment
Share on other sites

Screenshot of item:

screenshot of block:

 

I have no errors in my console about this block

 

blockstate:

{

    "variants": {

        "facing=north": { "model": "block_MicrobeExtractorIdle" },

        "facing=south": { "model": "block_MicrobeExtractorIdle", "y": 180 },

        "facing=west":  { "model": "block_MicrobeExtractorIdle", "y": 270 },

        "facing=east":  { "model": "block_MicrobeExtractorIdle", "y": 90 }

    }

}

 

Block model:

 

{

    "parent":"block/orientable",

"textures": {

"top": "biowarfare:blocks/block_MicrobeExtractorTop",

"front": "biowarfare:blocks/block_MicrobeExtractorFrontOff",

"side": "biowarfare:blocks/block_MicrobeExtractorSide"

}

}

 

And block registration code:

http://pastebin.com/G2rRQ2LP

P.s is MicrobeExtractorIdle im doing first then the active version

BioWarfare Mod: http://goo.gl/BYWQty

Link to comment
Share on other sites

sorry dude, I don't see it.

 

I suggest you strip out all the other blocks and items, change all your unlocalised names, folders and filenames to lower case.

If that doesn't work, you could add a breakpoint to Block.getActualState(), place the block on the ground, wait for the breakpoint to trigger, and then step out into

BlockRendererDispatcher.getModelFromBlockState().

You can then step through the fetching of the block model

(eg)

        IBakedModel ibakedmodel = this.blockModelShapes.getModelForState(p_175022_1_);

which will show you whether you're getting the correct model or not.

If you are, it's probably a texturing problem.

If not, something is wrong with your model registration.  You might be able to tell what went wrong by looking in BlockModelShapes.bakedmodelstore, or alternatively in BlockStateMapper.putAllStateModelLocations.

 

Either way, you'll be digging pretty deep into the registry code so I gotta warn you, you might find it frustrating...

 

 

 

Link to comment
Share on other sites

solved it :D

 

"facing=north": { "model": "block_MicrobeExtractorIdle" },

 

forgot the modid:

 

"facing=north": { "model": "biowarfare:block_MicrobeExtractorIdle" },

Ah.  I should have noticed that.

 

It looks like you've uncovered a forge bug that has been introduced since I wrote that troubleshooting guide. 

        public IModel loadModel(ResourceLocation modelLocation)
        {
            try
            {
                return loader.new VanillaModelWrapper(modelLocation, loader.loadModel(modelLocation));
            }
            catch(IOException e)
            {
                if(loader.isLoading)
                {
                    // holding error until onPostBakeEvent
                }
                else FMLLog.log(Level.ERROR, e, "Exception loading model %s with vanilla loader, skipping", modelLocation);
                return loader.getMissingModel();
            }
        }

It ignores the error here, "holding error until onPostBakeEvent", but onPostBakeEvent doesn't rediscover the error.

 

I'll update the guide, maybe put a bug report too.

 

-TGG

 

 

 

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.



×
×
  • Create New...

Important Information

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