5
5
import com .google .gson .JsonObject ;
6
6
import net .minecraft .core .BlockPos ;
7
7
import net .minecraft .core .registries .BuiltInRegistries ;
8
+ import net .minecraft .resources .ResourceLocation ;
8
9
import net .minecraft .world .item .Item ;
9
10
import net .minecraft .world .level .EmptyBlockGetter ;
10
11
import net .minecraft .world .level .block .Block ;
@@ -62,7 +63,7 @@ public JsonObject generate() {
62
63
}
63
64
}
64
65
// Default values
65
- writeState (block , defaultBlockState , null , blockJson );
66
+ writeState (location , block , defaultBlockState , null , blockJson );
66
67
{
67
68
// List of properties
68
69
JsonObject properties = new JsonObject ();
@@ -83,7 +84,7 @@ public JsonObject generate() {
83
84
for (BlockState bs : block .getStateDefinition ().getPossibleStates ()) {
84
85
JsonObject state = new JsonObject ();
85
86
state .addProperty ("stateId" , Block .BLOCK_STATE_REGISTRY .getId (bs ));
86
- writeState (block , bs , blockJson , state );
87
+ writeState (location , block , bs , blockJson , state );
87
88
88
89
StringBuilder stateName = new StringBuilder ("[" );
89
90
for (var propertyEntry : bs .getValues ().entrySet ()) {
@@ -123,11 +124,17 @@ public JsonObject generate() {
123
124
return blocks ;
124
125
}
125
126
126
- private void writeState (Block block , BlockState blockState , JsonObject blockJson , JsonObject state ) {
127
+ private void writeState (ResourceLocation location , Block block , BlockState blockState , JsonObject blockJson , JsonObject state ) {
127
128
// Data
128
129
appendState (blockJson , state , "canRespawnIn" , block .isPossibleToRespawnInThis (blockState ), boolean .class );
129
130
appendState (blockJson , state , "hardness" , blockState .getDestroySpeed (EmptyBlockGetter .INSTANCE , BlockPos .ZERO ), float .class );
130
- appendState (blockJson , state , "lightEmission" , blockState .getLightEmission (), 0 , int .class );
131
+ if (location .toString ().equals ("minecraft:light" )) {
132
+ // This is a bad special case for light blocks. minecraft:light[level=0] has an emission value of 0, but the default
133
+ // state has an emission value of 15 meaning if this is omitted light 0 will have an emission of 15.
134
+ appendState (blockJson , state , "lightEmission" , blockState .getLightEmission (), 15 , int .class );
135
+ } else {
136
+ appendState (blockJson , state , "lightEmission" , blockState .getLightEmission (), 0 , int .class );
137
+ }
131
138
appendState (blockJson , state , "pushReaction" , blockState .getPistonPushReaction ().name (), String .class );
132
139
appendState (blockJson , state , "mapColorId" , blockState .getMapColor (EmptyBlockGetter .INSTANCE , BlockPos .ZERO ).id , int .class );
133
140
appendState (blockJson , state , "occludes" , blockState .canOcclude (), boolean .class );
0 commit comments