Jump to content

Recommended Posts

Posted

Hello,

I'm having problems creating a custom fluid block because I cannot find info on how the BlockState (the Json files) file should be setup for a fluid. I tried looking at the vanilla BlockStates and I do not see any blockstate file for water or lava.

I  was able to add a fluid block but without the proper blockstate file the game crashes when the fluid spreads because it doesn't have the different levels of the fluids defined in the blockstate file.

 

 

Does anyone have an example of how a fluid & fluid block should be done in 1.8 ?

I do not want to copy only to understand the proper way I'd be happy just to know how it was done in vanilla but i do not see blockstates for water or lava.

 

Thanks!

Tech

 

 

Posted

Hi

 

Fluids don't have blockstates.  they define a different render type

 

Each block also has a render type, specified by Block.getRenderType():

-1 = doesn’t render at all, eg BlockAir

1 = renders as a flowing liquid (animated texture) using BlockFluidRenderer.renderFluid – eg lava and water.

2 = doesn’t render anything in the block layers, but has an associated TileEntitySpecialRenderer which does draw something, eg BlockChest.

3 = renders using an IBakedModel, BlockModelRenderer.renderModel.  This is described in more detail below.

 

-TGG

Posted

OK that is very useful,

Thank you.

 

The tutorial (which was for 1.7.X ) I was using had directions to extend a forge class (BlockFluidClassic) which if I drill down far enough into its parent classes overides getRenderType () with a return value from FluidRegistry.renderIdFluid and that is set to -1.

If I override this method to return 1 then i get an error for class cast exception

My modded block which extends BlockFluidClassic cannot be cast to net.minecraft.block.BlockLiquid

which sounds correct because BlockFluidClassic  is from forge and BlockLiquid is from vanilla so the vanilla blockFluidrenderer can't be used to render mod fluids.

 

Without overriding getRenderType() the block can be placed into the world but as soon as the fluid flows out to another block it crashes with the following :

 

 

 

[10:31:57] [server thread/ERROR]: Encountered an unexpected exception

net.minecraft.util.ReportedException: Exception while ticking a block

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:769) ~[MinecraftServer.class:?]

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669) ~[MinecraftServer.class:?]

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171) ~[integratedServer.class:?]

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540) [MinecraftServer.class:?]

at java.lang.Thread.run(Unknown Source) [?:1.7.0_71]

Caused by: java.lang.IllegalArgumentException: Cannot set 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 BlockState{block=minecraft:air, properties=[]}

at net.minecraft.block.state.BlockState$StateImplementation.withProperty(BlockState.java:182) ~[blockState$StateImplementation.class:?]

at net.minecraftforge.fluids.BlockFluidClassic.flowIntoBlock(BlockFluidClassic.java:275) ~[blockFluidClassic.class:?]

at net.minecraftforge.fluids.BlockFluidClassic.updateTick(BlockFluidClassic.java:161) ~[blockFluidClassic.class:?]

at net.minecraft.world.WorldServer.tickUpdates(WorldServer.java:660) ~[WorldServer.class:?]

at net.minecraft.world.WorldServer.tick(WorldServer.java:226) ~[WorldServer.class:?]

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:763) ~[MinecraftServer.class:?]

... 4 more

[10:31:57] [server thread/ERROR]: This crash report has been saved to: D:\ALL\Code\Minecraft\TechStack-s-HeavyMachineryMod\eclipse\.\crash-reports\crash-2015-01-29_10.31.57-server.txt

[10:31:57] [server thread/INFO]: Stopping server

[10:31:57] [server thread/INFO]: Saving players

[10:31:57] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:func_179870_a:660]: ---- Minecraft Crash Report ----

// My bad.

 

Time: 1/29/15 10:31 AM

Description: Exception while ticking a block

 

java.lang.IllegalArgumentException: Cannot set 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 BlockState{block=minecraft:air, properties=[]}

at net.minecraft.block.state.BlockState$StateImplementation.withProperty(BlockState.java:182)

at net.minecraftforge.fluids.BlockFluidClassic.flowIntoBlock(BlockFluidClassic.java:275)

at net.minecraftforge.fluids.BlockFluidClassic.updateTick(BlockFluidClassic.java:161)

at net.minecraft.world.WorldServer.tickUpdates(WorldServer.java:660)

at net.minecraft.world.WorldServer.tick(WorldServer.java:226)

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:763)

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669)

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540)

at java.lang.Thread.run(Unknown Source)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at net.minecraft.block.state.BlockState$StateImplementation.withProperty(BlockState.java:182)

at net.minecraftforge.fluids.BlockFluidClassic.flowIntoBlock(BlockFluidClassic.java:275)

at net.minecraftforge.fluids.BlockFluidClassic.updateTick(BlockFluidClassic.java:161)

 

-- Block being ticked --

Details:

Block: machinemod:moonshine[level=0]

Block location: World: (103,71,204), Chunk: (at 7,4,12 in 6,12; contains blocks 96,0,192 to 111,255,207), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)

Stacktrace:

at net.minecraft.world.WorldServer.tickUpdates(WorldServer.java:660)

at net.minecraft.world.WorldServer.tick(WorldServer.java:226)

 

-- Affected level --

Details:

Level name: New World

All players: 1 total; [EntityPlayerMP['Player641'/396, l='New World', x=101.65, y=71.00, z=204.62]]

Chunk stats: ServerChunkCache: 841 Drop: 0

Level seed: -2994061550766133726

Level generator: ID 00 - default, ver 1. Features enabled: true

Level generator options:

Level spawn location: 164.00,64.00,256.00 - World: (164,64,256), Chunk: (at 4,4,0 in 10,16; contains blocks 160,0,256 to 175,255,271), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)

Level time: 191031 game time, 3060 day time

Level dimension: 0

Level storage version: 0x04ABD - Anvil

Level weather: Rain time: 1 (now: false), thunder time: 1 (now: false)

Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false

Stacktrace:

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:763)

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669)

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540)

at java.lang.Thread.run(Unknown Source)

 

-- System Details --

Details:

Minecraft Version: 1.8

Operating System: Windows 7 (amd64) version 6.1

Java Version: 1.7.0_71, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 3676607856 bytes (3506 MB) / 4132241408 bytes (3940 MB) up to 4132241408 bytes (3940 MB)

JVM Flags: 3 total; -Xincgc -Xmx4024M -Xms4024M

IntCache: cache: 1, tcache: 0, allocated: 13, tallocated: 95

FML: MCP v9.10 FML v8.0.14.1289 Minecraft Forge 11.14.0.1289 4 mods loaded, 4 mods active

mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

FML{8.0.14.1289} [Forge Mod Loader] (forgeSrc-1.8-11.14.0.1289-1.8.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Forge{11.14.0.1289} [Minecraft Forge] (forgeSrc-1.8-11.14.0.1289-1.8.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

machinemod{1.7.10-1.0-Pre-ALPHA} [MachineMod] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Profiler Position: N/A (disabled)

Player Count: 1 / 8; [EntityPlayerMP['Player641'/396, l='New World', x=101.65, y=71.00, z=204.62]]

Type: Integrated Server (map_client.txt)

Is Modded: Definitely; Client brand changed to 'fml,forge'

[10:31:57] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:func_179870_a:660]: #@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2015-01-29_10.31.57-server.txt

 

 

 

 

 

Which is why i was asking for the blockstate information because it sounds like it is trying to set the block state name = level to an integer value of 0 -15 based on the fuild's flow distance from origin (eg its height)

 

Posted

turns out its a bug in forge for 1.8  :

https://github.com/MinecraftForge/MinecraftForge/issues/1552

 

for anyone looking in the future if a PR isn't created by then.

Overriding flowIntoBlock in your class that extends BlockFluidClassic to read as follows seems to correct the issue temporarily until forge is corrected.

 

 

 

 

@Override

    protected void flowIntoBlock(World world, BlockPos pos, int meta)

    {

        if (meta < 0) return;

        if (displaceIfPossible(world, pos))

        {

        world.setBlockState(pos, this.getBlockState().getBaseState().withProperty(LEVEL, meta), 3);

       

       

 

        }

    }

 

 

 

 

Also anyone know what the guidelines are for posting PR for forge?

Any document that lays out how they should be setup ?

I assume there is some special gradel commands to run to get the forge source in a state for the PR & to create the patches etc..

 

Posted

Also anyone know what the guidelines are for posting PR for forge?

 

Go to the relevant class, click "edit."  GitHub will ask you if you want to fork the project (yes, you do).  Edit the relevant function so it does what it is supposed to.  If you need to, make sure it compiles and runs properly (do a git pull, edit and test, then git push).  Then submit a merge request.

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

I'm able to sort out how to get forge setup in my dev enviroment and make my changes &  i can test forge /fml standalone but how would i add in my mod to confirm it resolves the issue?

 

If i add it to the mods folder that forge is run from then it will crash due to the mod being built & re-obfuscated  and the forge source in the dev env is de-obfuscated.

 

Is there a way to compile/build  my mod so it is not re-obfuscated ?

 

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.