Skip to content

Commit 368aa6d

Browse files
committed
feat: add acid splatter block
1 parent 6d5b791 commit 368aa6d

File tree

21 files changed

+481
-109
lines changed

21 files changed

+481
-109
lines changed

src/datagen/java/com/github/elenterius/biomancy/datagen/lang/EnglishLangProvider.java

+1
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,7 @@ private void addBlockTranslations() {
689689
addBlock(ModBlocks.PRIMAL_ORIFICE, "Primal Orifice", "A grotesque, flesh mass riddled with holes, oozing gastric juices. These orifices appear to grow inside flesh mound chambers and can be harvested using buckets or bottles, yielding a highly acidic fluid.");
690690
addBlock(ModBlocks.ACID_FLUID_BLOCK, "Gastric Acid");
691691
addBlock(ModBlocks.ACID_CAULDRON,"Gastric Acid Cauldron");
692+
addBlock(ModBlocks.ACID_SPLATTER, "Gastric Acid Splatter");
692693
addBlock(ModBlocks.WATER_GEL_BLOCK, "Water Gel", "A hydrating water gel that supplies moisture to mobs and farmland without spilling liquids everywhere.");
693694
}
694695

src/datagen/java/com/github/elenterius/biomancy/datagen/loot/ModBlockLoot.java

+1
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ protected void generate() {
251251

252252
add(ModBlocks.ACID_FLUID_BLOCK.get(), noDrop());
253253
add(ModBlocks.ACID_CAULDRON.get(), drop(Items.CAULDRON));
254+
add(ModBlocks.ACID_SPLATTER.get(), noDrop());
254255
dropSelf(ModBlocks.WATER_GEL_BLOCK.get());
255256
}
256257

src/datagen/java/com/github/elenterius/biomancy/datagen/models/ModBlockStateProvider.java

+45-19
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,14 @@
2222
import net.minecraft.world.item.ItemDisplayContext;
2323
import net.minecraft.world.level.block.*;
2424
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.*;
2926
import net.minecraftforge.client.model.generators.*;
3027
import net.minecraftforge.common.data.ExistingFileHelper;
3128
import net.minecraftforge.registries.ForgeRegistries;
3229
import net.minecraftforge.registries.RegistryObject;
3330
import org.jetbrains.annotations.Nullable;
3431
import org.joml.Vector3f;
3532

36-
import java.util.Collection;
3733
import java.util.Objects;
3834
import java.util.function.Function;
3935

@@ -63,6 +59,11 @@ protected ResourceLocation blockAsset(Block block) {
6359
return new ResourceLocation(registryKey.getNamespace(), ModelProvider.BLOCK_FOLDER + "/" + registryKey.getPath());
6460
}
6561

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+
6667
protected ResourceLocation extend(ResourceLocation resourceLocation, String suffix) {
6768
return new ResourceLocation(resourceLocation.getNamespace(), resourceLocation.getPath() + suffix);
6869
}
@@ -157,6 +158,8 @@ protected void registerStatesAndModels() {
157158

158159
particleOnly(ModBlocks.ACID_FLUID_BLOCK, new ResourceLocation("biomancy:block/acid_flat"));
159160
layeredCauldron(ModBlocks.ACID_CAULDRON);
161+
multifaceBlockWithPropertyVariants(ModBlocks.ACID_SPLATTER.get(), AcidSplatterBlock.AGE.get());
162+
160163
existingBlockWithItem(ModBlocks.WATER_GEL_BLOCK);
161164
}
162165

@@ -649,13 +652,11 @@ public <T extends FleshVeinsBlock> void veinsBlock(RegistryObject<T> block) {
649652

650653
public void veinsBlock(MultifaceBlock block) {
651654
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");
655656

656-
MultiPartBlockStateBuilder builder = getMultipartBuilder(block);
657+
ModelFile model = models().singleTexture(name, parentModel, blockAsset(block)).renderType("cutout");
657658

658-
Collection<BooleanProperty> properties = PipeBlock.PROPERTY_BY_DIRECTION.values();
659+
MultiPartBlockStateBuilder builder = getMultipartBuilder(block);
659660

660661
PipeBlock.PROPERTY_BY_DIRECTION.forEach((direction, property) -> {
661662
if (direction.getAxis().isHorizontal()) {
@@ -665,11 +666,6 @@ public void veinsBlock(MultifaceBlock block) {
665666
.rotationY(rotY).uvLock(true).addModel()
666667
.condition(property, true)
667668
.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();
673669
}
674670
else if (direction.getAxis().isVertical()) {
675671
int rotX = direction == Direction.UP ? 270 : 90;
@@ -678,11 +674,41 @@ else if (direction.getAxis().isVertical()) {
678674
.rotationX(rotX).uvLock(true).addModel()
679675
.condition(property, true)
680676
.end();
677+
}
678+
});
679+
}
681680

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+
}
686712
}
687713
});
688714
}

src/datagen/java/com/github/elenterius/biomancy/datagen/models/ModItemModelProvider.java

+16
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ protected void registerModels() {
111111
flatBlockItem(ModItems.MALIGNANT_FLESH_VEINS);
112112

113113
dynamicBucket(ModItems.ACID_BUCKET.get());
114+
flatBlockItem(ModItems.ACID_SPLATTER, "_0");
115+
114116
basicItem(ModItems.GELLING_AGENT);
115117
weaponItem(ModItems.GRENADE);
116118

@@ -260,6 +262,20 @@ public ItemModelBuilder flatBlockItem(ResourceLocation registryKey) {
260262
.texture(LAYER_0_TEXTURE, new ResourceLocation(registryKey.getNamespace(), BLOCK_FOLDER + "/" + registryKey.getPath()));
261263
}
262264

265+
public <T extends BlockItem> ItemModelBuilder flatBlockItem(RegistryObject<T> registryObject, String suffix) {
266+
return flatBlockItem(registryObject.getId(), suffix);
267+
}
268+
269+
public ItemModelBuilder flatBlockItem(BlockItem blockItem, String suffix) {
270+
return flatBlockItem(registryKey(blockItem), suffix);
271+
}
272+
273+
public ItemModelBuilder flatBlockItem(ResourceLocation registryKey, String suffix) {
274+
return getBuilder(registryKey.toString())
275+
.parent(new ModelFile.UncheckedModelFile("item/generated"))
276+
.texture(LAYER_0_TEXTURE, new ResourceLocation(registryKey.getNamespace(), BLOCK_FOLDER + "/" + registryKey.getPath() + suffix));
277+
}
278+
263279
public <T extends BlockItem> ItemModelBuilder wallBlockItem(RegistryObject<T> registryObject) {
264280
return wallBlockItem(registryObject.getId());
265281
}

src/datagen/java/com/github/elenterius/biomancy/datagen/tags/ModBlockTagsProvider.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private void addMineableWithToolTags() {
145145
IntrinsicTagAppender<Block> hoeTag = tag(BlockTags.MINEABLE_WITH_HOE);
146146

147147
Set<Block> notMineableWithHoe = Set.of(
148-
ModBlocks.ACID_CAULDRON.get(), ModBlocks.ACID_FLUID_BLOCK.get(),
148+
ModBlocks.ACID_CAULDRON.get(), ModBlocks.ACID_FLUID_BLOCK.get(), ModBlocks.ACID_SPLATTER.get(),
149149
ModBlocks.WATER_GEL_BLOCK.get()
150150
);
151151

0 commit comments

Comments
 (0)