22
22
import net .minecraft .world .item .ItemDisplayContext ;
23
23
import net .minecraft .world .level .block .*;
24
24
import net .minecraft .world .level .block .state .BlockState ;
25
- import net .minecraft .world .level .block .state .properties .BlockStateProperties ;
26
- import net .minecraft .world .level .block .state .properties .BooleanProperty ;
27
- import net .minecraft .world .level .block .state .properties .DirectionProperty ;
28
- import net .minecraft .world .level .block .state .properties .Property ;
25
+ import net .minecraft .world .level .block .state .properties .*;
29
26
import net .minecraftforge .client .model .generators .*;
30
27
import net .minecraftforge .common .data .ExistingFileHelper ;
31
28
import net .minecraftforge .registries .ForgeRegistries ;
32
29
import net .minecraftforge .registries .RegistryObject ;
33
30
import org .jetbrains .annotations .Nullable ;
34
31
import org .joml .Vector3f ;
35
32
36
- import java .util .Collection ;
37
33
import java .util .Objects ;
38
34
import java .util .function .Function ;
39
35
@@ -63,6 +59,11 @@ protected ResourceLocation blockAsset(Block block) {
63
59
return new ResourceLocation (registryKey .getNamespace (), ModelProvider .BLOCK_FOLDER + "/" + registryKey .getPath ());
64
60
}
65
61
62
+ protected ResourceLocation blockAsset (Block block , String suffix ) {
63
+ ResourceLocation registryKey = registryKey (block );
64
+ return new ResourceLocation (registryKey .getNamespace (), ModelProvider .BLOCK_FOLDER + "/" + registryKey .getPath () + suffix );
65
+ }
66
+
66
67
protected ResourceLocation extend (ResourceLocation resourceLocation , String suffix ) {
67
68
return new ResourceLocation (resourceLocation .getNamespace (), resourceLocation .getPath () + suffix );
68
69
}
@@ -157,6 +158,8 @@ protected void registerStatesAndModels() {
157
158
158
159
particleOnly (ModBlocks .ACID_FLUID_BLOCK , new ResourceLocation ("biomancy:block/acid_flat" ));
159
160
layeredCauldron (ModBlocks .ACID_CAULDRON );
161
+ multifaceBlockWithPropertyVariants (ModBlocks .ACID_SPLATTER .get (), AcidSplatterBlock .AGE .get ());
162
+
160
163
existingBlockWithItem (ModBlocks .WATER_GEL_BLOCK );
161
164
}
162
165
@@ -649,13 +652,11 @@ public <T extends FleshVeinsBlock> void veinsBlock(RegistryObject<T> block) {
649
652
650
653
public void veinsBlock (MultifaceBlock block ) {
651
654
String name = path (block );
652
- ModelFile model = models ()
653
- .singleTexture (name , BiomancyMod .createRL ("block/template_veins" ), blockAsset (block ))
654
- .renderType ("cutout" );
655
+ ResourceLocation parentModel = BiomancyMod .createRL ("block/template_veins" );
655
656
656
- MultiPartBlockStateBuilder builder = getMultipartBuilder ( block );
657
+ ModelFile model = models (). singleTexture ( name , parentModel , blockAsset ( block )). renderType ( "cutout" );
657
658
658
- Collection < BooleanProperty > properties = PipeBlock . PROPERTY_BY_DIRECTION . values ( );
659
+ MultiPartBlockStateBuilder builder = getMultipartBuilder ( block );
659
660
660
661
PipeBlock .PROPERTY_BY_DIRECTION .forEach ((direction , property ) -> {
661
662
if (direction .getAxis ().isHorizontal ()) {
@@ -665,11 +666,6 @@ public void veinsBlock(MultifaceBlock block) {
665
666
.rotationY (rotY ).uvLock (true ).addModel ()
666
667
.condition (property , true )
667
668
.end ();
668
-
669
- MultiPartBlockStateBuilder .PartBuilder partBuilder = builder .part ().modelFile (model )
670
- .rotationY (rotY ).uvLock (true ).addModel ();
671
- properties .forEach (p -> partBuilder .condition (p , false ));
672
- partBuilder .end ();
673
669
}
674
670
else if (direction .getAxis ().isVertical ()) {
675
671
int rotX = direction == Direction .UP ? 270 : 90 ;
@@ -678,11 +674,41 @@ else if (direction.getAxis().isVertical()) {
678
674
.rotationX (rotX ).uvLock (true ).addModel ()
679
675
.condition (property , true )
680
676
.end ();
677
+ }
678
+ });
679
+ }
681
680
682
- MultiPartBlockStateBuilder .PartBuilder partBuilder = builder .part ().modelFile (model )
683
- .rotationX (rotX ).uvLock (true ).addModel ();
684
- properties .forEach (p -> partBuilder .condition (p , false ));
685
- partBuilder .end ();
681
+ public void multifaceBlockWithPropertyVariants (MultifaceBlock block , IntegerProperty integerProperty ) {
682
+ String modelName = path (block );
683
+ ResourceLocation parentModel = BiomancyMod .createRL ("block/template_veins" );
684
+
685
+ MultiPartBlockStateBuilder builder = getMultipartBuilder (block );
686
+
687
+ PipeBlock .PROPERTY_BY_DIRECTION .forEach ((direction , directionProperty ) -> {
688
+ if (direction .getAxis ().isHorizontal ()) {
689
+ int rotY = (((int ) direction .toYRot ()) + 180 ) % 360 ;
690
+
691
+ for (Integer value : integerProperty .getPossibleValues ()) {
692
+ String suffix = "_" + value ;
693
+ ModelFile model = models ().singleTexture (modelName + suffix , parentModel , blockAsset (block , suffix )).renderType ("cutout" );
694
+ builder .part ().modelFile (model )
695
+ .rotationY (rotY ).uvLock (true ).addModel ()
696
+ .condition (directionProperty , true )
697
+ .condition (integerProperty , value )
698
+ .end ();
699
+ }
700
+ }
701
+ else if (direction .getAxis ().isVertical ()) {
702
+ int rotX = direction == Direction .UP ? 270 : 90 ;
703
+ for (Integer value : integerProperty .getPossibleValues ()) {
704
+ String suffix = "_" + value ;
705
+ ModelFile model = models ().singleTexture (modelName + suffix , parentModel , blockAsset (block , suffix )).renderType ("cutout" );
706
+ builder .part ().modelFile (model )
707
+ .rotationX (rotX ).uvLock (true ).addModel ()
708
+ .condition (directionProperty , true )
709
+ .condition (integerProperty , value )
710
+ .end ();
711
+ }
686
712
}
687
713
});
688
714
}
0 commit comments