Skip to content

Commit

Permalink
feat: add specialised membrane variants for items, babies and adult mobs
Browse files Browse the repository at this point in the history
  • Loading branch information
Elenterius committed Aug 15, 2023
1 parent 7af7853 commit 0da0681
Show file tree
Hide file tree
Showing 14 changed files with 240 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,10 @@ private void addBlockTranslations() {
addBlock(ModBlocks.BLUE_BIO_LANTERN, "Blue Bio-Lantern", "A bioluminescent light source. This one is blue!");
addBlock(ModBlocks.TENDON_CHAIN, "Tendon Chain", "A chain made of tendons.");
addBlock(ModBlocks.VIAL_HOLDER, "Vial Holder", "Display and organize your serums.");
addBlock(ModBlocks.FLESH_MEMBRANE, "Fleshy Membrane", "Window made of gelatinous-like membrane reinforced with elastic fibers.\n\nBaby mobs diffuse through the membrane.");
addBlock(ModBlocks.IMPERMEABLE_MEMBRANE, "Impermeable Membrane", "Gelatinous-like membrane reinforced with elastic fibers.");
addBlock(ModBlocks.BABY_PERMEABLE_MEMBRANE, "Baby-Permeable Membrane", "Gelatinous-like membrane reinforced with elastic fibers.\n\nBaby mobs can diffuse through the membrane.");
addBlock(ModBlocks.ADULT_PERMEABLE_MEMBRANE, "Adult-Permeable Membrane", "Gelatinous-like membrane reinforced with elastic fibers.\n\nAdult mobs can diffuse through the membrane.");
addBlock(ModBlocks.ITEM_PERMEABLE_MEMBRANE, "Item-Permeable Membrane", "Gelatinous-like membrane reinforced with elastic fibers.\n\nItems can diffuse through the membrane.");

addBlock(ModBlocks.PRIMAL_FLESH, "Primal Flesh Block", "Primitive and pure, you better not touch this with your dirty mitts.");
addBlock(ModBlocks.PRIMAL_FLESH_SLAB, "Primal Flesh Slab", "Primitive and pure, you better not touch this with your dirty mitts.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ protected void addTables() {
add(ModBlocks.MALIGNANT_FLESH_VEINS.get(), block -> createMultifaceBlockDrops(block, HAS_SHEARS_OR_SILK_TOUCH));

dropSelf(ModBlocks.VOICE_BOX.get());
dropSelf(ModBlocks.FLESH_MEMBRANE.get());
dropSelf(ModBlocks.IMPERMEABLE_MEMBRANE.get());
dropSelf(ModBlocks.BABY_PERMEABLE_MEMBRANE.get());
dropSelf(ModBlocks.ADULT_PERMEABLE_MEMBRANE.get());
dropSelf(ModBlocks.ITEM_PERMEABLE_MEMBRANE.get());
dropSelf(ModBlocks.FLESH_IRIS_DOOR.get());
dropSelf(ModBlocks.FLESH_FENCE.get());
dropSelf(ModBlocks.FLESH_FENCE_GATE.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ protected void registerStatesAndModels() {
irisDoor(ModBlocks.FLESH_IRIS_DOOR, true);
fleshDoor(ModBlocks.FLESH_DOOR);
fleshSpikes(ModBlocks.FLESH_SPIKE);
translucentBlockWithItem(ModBlocks.FLESH_MEMBRANE);
translucentBlockWithItem(ModBlocks.IMPERMEABLE_MEMBRANE);
membraneWithItem(ModBlocks.BABY_PERMEABLE_MEMBRANE);
membraneWithItem(ModBlocks.ADULT_PERMEABLE_MEMBRANE);
membraneWithItem(ModBlocks.ITEM_PERMEABLE_MEMBRANE);
bioLantern(ModBlocks.YELLOW_BIO_LANTERN);
bioLantern(ModBlocks.BLUE_BIO_LANTERN);
tendonChain(ModBlocks.TENDON_CHAIN);
Expand Down Expand Up @@ -430,6 +433,24 @@ public void tendonChain(FleshChainBlock block) {
itemModels().basicItem(block.asItem());
}

public void membraneWithItem(RegistryObject<MembraneBlock> registryObject) {
membraneWithItem(registryObject.get());
}

public void membraneWithItem(MembraneBlock block) {
String path = path(block);
// ResourceLocation texture = blockAsset(block);
ResourceLocation template = BiomancyMod.createRL("block/template_membrane");

ModelFile model = models()
.withExistingParent(path, template)
.texture("base", BiomancyMod.createRL("block/membrane_base"))
.texture("overlay", BiomancyMod.createRL("block/membrane_overlay"));

simpleBlock(block, model);
simpleBlockItem(block, model);
}

public void bioLantern(FleshLanternBlock block) {
String path = path(block);
ResourceLocation texture = blockAsset(block);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -895,10 +895,31 @@ private void registerBioForgeRecipes(Consumer<FinishedRecipe> consumer) {
.setCategory(ModBioForgeTabs.BLOCKS)
.unlockedBy(ModItems.BONE_FRAGMENTS.get()).save(consumer);

BioForgeRecipeBuilder.create(ModItems.FLESH_MEMBRANE.get())
BioForgeRecipeBuilder.create(ModItems.IMPERMEABLE_MEMBRANE.get())
.addIngredient(ModItems.ELASTIC_FIBERS.get(), 2)
.addIngredient(ModItems.BILE.get(), 4)
.addIngredient(ModItems.GEM_FRAGMENTS.get(), 1)
.addIngredient(ModItems.GEM_FRAGMENTS.get(), 2)
.setCategory(ModBioForgeTabs.MISC)
.unlockedBy(ModItems.ELASTIC_FIBERS.get()).save(consumer);

BioForgeRecipeBuilder.create(ModItems.ITEM_PERMEABLE_MEMBRANE.get())
.addIngredient(ModItems.ELASTIC_FIBERS.get(), 4)
.addIngredient(ModItems.BILE.get(), 4)
.addIngredient(Items.QUARTZ, 1)
.setCategory(ModBioForgeTabs.MISC)
.unlockedBy(ModItems.ELASTIC_FIBERS.get()).save(consumer);

BioForgeRecipeBuilder.create(ModItems.BABY_PERMEABLE_MEMBRANE.get())
.addIngredient(ModItems.ELASTIC_FIBERS.get(), 4)
.addIngredient(ModItems.REGENERATIVE_FLUID.get(), 4)
.addIngredient(ModItems.GEM_FRAGMENTS.get(), 2)
.setCategory(ModBioForgeTabs.MISC)
.unlockedBy(ModItems.ELASTIC_FIBERS.get()).save(consumer);

BioForgeRecipeBuilder.create(ModItems.ADULT_PERMEABLE_MEMBRANE.get())
.addIngredient(ModItems.ELASTIC_FIBERS.get(), 4)
.addIngredient(ModItems.HORMONE_SECRETION.get(), 4)
.addIngredient(ModItems.GEM_FRAGMENTS.get(), 2)
.setCategory(ModBioForgeTabs.MISC)
.unlockedBy(ModItems.ELASTIC_FIBERS.get()).save(consumer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ protected void addTags() {
ModBlocks.MALIGNANT_FLESH_SLAB.get()
);

tag(BlockTags.IMPERMEABLE).add(ModBlocks.FLESH_MEMBRANE.get());
tag(BlockTags.IMPERMEABLE).add(
ModBlocks.IMPERMEABLE_MEMBRANE.get(),
ModBlocks.BABY_PERMEABLE_MEMBRANE.get(),
ModBlocks.ADULT_PERMEABLE_MEMBRANE.get(),
ModBlocks.ITEM_PERMEABLE_MEMBRANE.get()
);
}

private void addFleshyBlocksToHoeTag() {
Expand Down
10 changes: 8 additions & 2 deletions src/generated/resources/assets/biomancy/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,14 @@
"block.biomancy.tendon_chain.tooltip": "A chain made of tendons.",
"block.biomancy.vial_holder": "Vial Holder",
"block.biomancy.vial_holder.tooltip": "Display and organize your serums.",
"block.biomancy.flesh_membrane": "Fleshy Membrane",
"block.biomancy.flesh_membrane.tooltip": "Window made of gelatinous-like membrane reinforced with elastic fibers.\n\nBaby mobs diffuse through the membrane.",
"block.biomancy.impermeable_membrane": "Impermeable Membrane",
"block.biomancy.impermeable_membrane.tooltip": "Gelatinous-like membrane reinforced with elastic fibers.",
"block.biomancy.baby_permeable_membrane": "Baby-Permeable Membrane",
"block.biomancy.baby_permeable_membrane.tooltip": "Gelatinous-like membrane reinforced with elastic fibers.\n\nBaby mobs can diffuse through the membrane.",
"block.biomancy.adult_permeable_membrane": "Adult-Permeable Membrane",
"block.biomancy.adult_permeable_membrane.tooltip": "Gelatinous-like membrane reinforced with elastic fibers.\n\nAdult mobs can diffuse through the membrane.",
"block.biomancy.item_permeable_membrane": "Item-Permeable Membrane",
"block.biomancy.item_permeable_membrane.tooltip": "Gelatinous-like membrane reinforced with elastic fibers.\n\nItems can diffuse through the membrane.",
"block.biomancy.primal_flesh": "Primal Flesh Block",
"block.biomancy.primal_flesh.tooltip": "Primitive and pure, you better not touch this with your dirty mitts.",
"block.biomancy.primal_flesh_slab": "Primal Flesh Slab",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ public void fallOn(Level level, BlockState state, BlockPos pos, Entity entity, f

@Override
public VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
if (context instanceof EntityCollisionContext entityContext && ignoreEntityCollisionPredicate.test(state, level, pos, entityContext.getEntity())) {
return Shapes.empty();
if (context instanceof EntityCollisionContext entityContext) {
Entity entity = entityContext.getEntity();
if (ignoreEntityCollisionPredicate.test(state, level, pos, entity)) {
return Shapes.empty();
}
}
return state.getShape(level, pos);
}
Expand All @@ -71,6 +74,7 @@ public interface IgnoreEntityCollisionPredicate {
IgnoreEntityCollisionPredicate IS_BABY_MOB = (state, level, pos, entity) -> entity instanceof LivingEntity livingEntity && livingEntity.isBaby();
IgnoreEntityCollisionPredicate IS_ADULT_MOB = (state, level, pos, entity) -> entity instanceof LivingEntity livingEntity && !livingEntity.isBaby();
IgnoreEntityCollisionPredicate IS_ITEM = (state, level, pos, entity) -> entity instanceof ItemEntity;
IgnoreEntityCollisionPredicate NEVER = (state, level, pos, entity) -> false;

boolean test(BlockState state, BlockGetter level, BlockPos pos, @Nullable Entity entity);
}
Expand Down
16 changes: 12 additions & 4 deletions src/main/java/com/github/elenterius/biomancy/init/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ public final class ModBlocks {

//## Misc
public static final RegistryObject<VoiceBoxBlock> VOICE_BOX = register("voice_box", VoiceBoxBlock::new);
public static final RegistryObject<MembraneBlock> FLESH_MEMBRANE = register("flesh_membrane", props -> {
props = props.noOcclusion().isRedstoneConductor(ModBlocks::neverValid).isSuffocating(ModBlocks::neverValid).isViewBlocking(ModBlocks::neverValid);
return new MembraneBlock(props, MembraneBlock.IgnoreEntityCollisionPredicate.IS_BABY_MOB);
});
public static final RegistryObject<MembraneBlock> IMPERMEABLE_MEMBRANE = registerMembrane("impermeable_membrane", MembraneBlock.IgnoreEntityCollisionPredicate.NEVER);
public static final RegistryObject<MembraneBlock> BABY_PERMEABLE_MEMBRANE = registerMembrane("baby_permeable_membrane", MembraneBlock.IgnoreEntityCollisionPredicate.IS_BABY_MOB);
public static final RegistryObject<MembraneBlock> ADULT_PERMEABLE_MEMBRANE = registerMembrane("adult_permeable_membrane", MembraneBlock.IgnoreEntityCollisionPredicate.IS_ADULT_MOB);
public static final RegistryObject<MembraneBlock> ITEM_PERMEABLE_MEMBRANE = registerMembrane("item_permeable_membrane", MembraneBlock.IgnoreEntityCollisionPredicate.IS_ITEM);

public static final RegistryObject<LadderBlock> FLESH_LADDER = register("flesh_ladder", () -> new LadderBlock(createFleshyBoneProperties().noOcclusion()));
public static final RegistryObject<FleshFenceBlock> FLESH_FENCE = register("flesh_fence", FleshFenceBlock::new);
public static final RegistryObject<FleshFenceGateBlock> FLESH_FENCE_GATE = register("flesh_fence_gate", () -> new FleshFenceGateBlock(createFleshyBoneProperties().noOcclusion()));
Expand Down Expand Up @@ -155,6 +156,13 @@ private static <T extends DirectionalSlabBlock> RegistryObject<T> registerSlab(S
return BLOCKS.register(name, () -> factory.apply(copyProperties(parent.get())));
}

private static RegistryObject<MembraneBlock> registerMembrane(String name, MembraneBlock.IgnoreEntityCollisionPredicate predicate) {
return register(name, props -> {
props = props.noOcclusion().isRedstoneConductor(ModBlocks::neverValid).isSuffocating(ModBlocks::neverValid).isViewBlocking(ModBlocks::neverValid);
return new MembraneBlock(props, predicate);
});
}

public static BlockBehaviour.Properties copyProperties(BlockBehaviour behaviour) {
return BlockBehaviour.Properties.copy(behaviour);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ public final class ModItems {

//## Misc
public static final RegistryObject<SimpleBlockItem> VOICE_BOX = registerSimpleBlockItem(ModBlocks.VOICE_BOX, () -> createProperties().tab(null));
public static final RegistryObject<SimpleBlockItem> FLESH_MEMBRANE = registerSimpleBlockItem(ModBlocks.FLESH_MEMBRANE);
public static final RegistryObject<SimpleBlockItem> IMPERMEABLE_MEMBRANE = registerSimpleBlockItem(ModBlocks.IMPERMEABLE_MEMBRANE);
public static final RegistryObject<SimpleBlockItem> BABY_PERMEABLE_MEMBRANE = registerSimpleBlockItem(ModBlocks.BABY_PERMEABLE_MEMBRANE);
public static final RegistryObject<SimpleBlockItem> ADULT_PERMEABLE_MEMBRANE = registerSimpleBlockItem(ModBlocks.ADULT_PERMEABLE_MEMBRANE);
public static final RegistryObject<SimpleBlockItem> ITEM_PERMEABLE_MEMBRANE = registerSimpleBlockItem(ModBlocks.ITEM_PERMEABLE_MEMBRANE);
public static final RegistryObject<SimpleBlockItem> FLESH_LADDER = registerSimpleBlockItem(ModBlocks.FLESH_LADDER);
public static final RegistryObject<SimpleBlockItem> FLESH_FENCE = registerSimpleBlockItem(ModBlocks.FLESH_FENCE);
public static final RegistryObject<SimpleBlockItem> FLESH_FENCE_GATE = registerSimpleBlockItem(ModBlocks.FLESH_FENCE_GATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,16 @@ public static void onBlockModelRegistry(final ModelEvent.RegisterAdditional even

@SubscribeEvent
public static void onItemColorRegistry(final RegisterColorHandlersEvent.Item event) {
event.register((stack, index) -> ModItems.ESSENCE.get().getColor(stack, index), ModItems.ESSENCE.get());
event.register((stack, tintIndex) -> ModItems.ESSENCE.get().getColor(stack, tintIndex), ModItems.ESSENCE.get());
event.register((stack, tintIndex) -> tintIndex == 1 ? 0xFF_09DF5B : 0xFF_FFFFFF, ModBlocks.BABY_PERMEABLE_MEMBRANE.get());
event.register((stack, tintIndex) -> tintIndex == 1 ? 0xFF_69CB49 : 0xFF_FFFFFF, ModBlocks.ADULT_PERMEABLE_MEMBRANE.get());
}

@SubscribeEvent
public static void onBlockColorRegistry(final RegisterColorHandlersEvent.Block event) {
event.register(VialHolderBlock::getTintColor, ModBlocks.VIAL_HOLDER.get());
event.register((state, level, pos, tintIndex) -> tintIndex == 1 ? 0xFF_09DF5B : 0xFF_FFFFFF, ModBlocks.BABY_PERMEABLE_MEMBRANE.get());
event.register((state, level, pos, tintIndex) -> tintIndex == 1 ? 0xFF_69CB49 : 0xFF_FFFFFF, ModBlocks.ADULT_PERMEABLE_MEMBRANE.get());
}

@SubscribeEvent
Expand Down
146 changes: 146 additions & 0 deletions src/main/resources/assets/biomancy/models/block/template_membrane.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
{
"parent": "block/block",
"render_type": "minecraft:translucent",
"textures": {
"particle": "#base",
"base": "#base",
"inner": "#base",
"overlay": "#overlay"
},
"groups": [
{
"name": "base",
"origin": [ 0, 0, 0 ],
"color": 0,
"children": [ 0, 2 ]
},
{
"name": "overlay",
"origin": [ 0, 0, 0 ],
"color": 0,
"children": [ 1 ]
}
],
"elements": [
{
"from": [ 0, 0, 0 ],
"to": [ 16, 16, 16 ],
"faces": {
"north": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#base",
"cullface": "north",
"tintindex": 1
},
"east": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#base",
"cullface": "east",
"tintindex": 1
},
"south": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#base",
"cullface": "south",
"tintindex": 1
},
"west": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#base",
"cullface": "west",
"tintindex": 1
},
"up": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#base",
"cullface": "up",
"tintindex": 1
},
"down": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#base",
"cullface": "down",
"tintindex": 1
}
}
},
{
"from": [ 0, 0, 0 ],
"to": [ 16, 16, 16 ],
"faces": {
"north": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#overlay",
"cullface": "north",
"tintindex": 0
},
"east": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#overlay",
"cullface": "east",
"tintindex": 0
},
"south": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#overlay",
"cullface": "south",
"tintindex": 0
},
"west": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#overlay",
"cullface": "west",
"tintindex": 0
},
"up": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#overlay",
"cullface": "up",
"tintindex": 0
},
"down": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#overlay",
"cullface": "down",
"tintindex": 0
}
}
},
{
"from": [ 2, 2, 2 ],
"to": [ 14, 14, 14 ],
"faces": {
"north": {
"uv": [ 2, 2, 14, 14 ],
"texture": "#inner",
"tintindex": 0
},
"east": {
"uv": [ 2, 2, 14, 14 ],
"texture": "#inner",
"tintindex": 0
},
"south": {
"uv": [ 2, 2, 14, 14 ],
"texture": "#inner",
"tintindex": 0
},
"west": {
"uv": [ 2, 2, 14, 14 ],
"texture": "#inner",
"tintindex": 0
},
"up": {
"uv": [ 2, 2, 14, 14 ],
"texture": "#inner",
"tintindex": 0
},
"down": {
"uv": [ 2, 2, 14, 14 ],
"texture": "#inner",
"tintindex": 0
}
}
}
]
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0da0681

Please sign in to comment.