Jump to content

Recommended Posts

Posted

I've maded a plant that looks like chorus plant but grows underwater. But, due to it's model, there is a graphical glitch bot underwater or when it grows outside of the water. In this image you can see what i mean.

4lIpHcg.png

So my question is: is there a way to remove this glitch? Maybe a custom model or something? I've seen some mods that has underwater plants and they don't have this glitch, but they don't have an open source code, so how can i do that? :)

If this needs this are the classes for the plant

BlockBlueCoral (the chorus fruit-like block) [url]http://pastebin.com/ZZFvJuMR[/url]
BlockBlueCoralPlant (the chorus plant-like block) [url]http://pastebin.com/vqyuqfbk[/url]
The json files for models are the same as the chorus plant/flower

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted

Changing to that material gives me this error when i place the block

java.lang.IllegalArgumentException: Cannot get property PropertyInteger{name=level, clazz=class java.lang.Integer, values=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]} as it does not exist in BlockStateContainer{block=mw:blue_coral, properties=[age]}
at net.minecraft.block.state.BlockStateContainer$StateImplementation.getValue(BlockStateContainer.java:192)
at net.minecraft.block.BlockDynamicLiquid.getPossibleFlowDirections(BlockDynamicLiquid.java:226)
at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:137)
at net.minecraft.block.Block.randomTick(Block.java:552)
at net.minecraft.world.WorldServer.updateBlocks(WorldServer.java:480)
at net.minecraft.world.WorldServer.tick(WorldServer.java:224)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:768)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:683)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:155)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:532)
at java.lang.Thread.run(Unknown Source)

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted

You also need to include the

BlockLiquid.LEVEL

property in your

BlockStateContainer

and register an

IStateMapper

to ignore that property in your blockstates file (if you don't want its value to affect the model).

 

You can see my implementation of a basic water plant here, with the

IStateMapper

registration here (called in preInit from the client proxy).

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

Thanks a lot :D By doing that the plant is rendered good underwater. But when this grows outside it still have this glitch :(

R4yH8IV.jpg

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted

You'll probably need to override

Block#getMaterial(IBlockState)

to return a different

Material

when the block isn't submerged in water.

 

You don't have access to the world or position in this method, so you'll need to create an

IProperty

for this (probably a

PropertyBool

called

IN_WATER

) and store it in the metadata.

 

When the block is placed and when a neighbouring block changes, set the value of this property based on the surrounding blocks. I'm not sure exactly how to determine what qualifies as submerged and what doesn't, but start by checking if any of the horizontally adjacent blocks are something other than water or your plant.

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

Due to the model i think the glitch will still be there even with different material. By now i've solved doing a check in the update tick function, so if the plant is trying to grow up but it's near the surface of water then it stops growing :) Thanks anyway for the help :)

Don't blame me if i always ask for your help. I just want to learn to be better :)

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.