Skip to content

Commit

Permalink
feat: update membrane block model & colors
Browse files Browse the repository at this point in the history
  • Loading branch information
Elenterius committed Feb 12, 2024
1 parent 4712b27 commit c2d9174
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 197 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ private void addBlockTranslations() {
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.PRIMAL_PERMEABLE_MEMBRANE, "Primal Membrane", "Gelatinous-like membrane reinforced with elastic fibers.\n\nOnly mobs that are alive can diffuse through the membrane.");
addBlock(ModBlocks.UNDEAD_PERMEABLE_MEMBRANE, "Phantom Membrane", "Gelatinous-like membrane reinforced with elastic fibers.\n\nOnly mobs that are undead can diffuse through the membrane.");
addBlock(ModBlocks.UNDEAD_PERMEABLE_MEMBRANE, "Undead-Permeable Membrane", "Gelatinized phantom membrane reinforced with elastic fibers.\n\nOnly mobs that are undead can diffuse through the membrane.");
//addBlock(ModBlocks.NEURAL_INTERCEPTOR, "Neural Interceptor", "A psychic node that prevents natural mob spawning in a 48 block radius.");

addBlock(ModBlocks.PRIMAL_FLESH, "Primal Flesh Block", "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 @@ -12,6 +12,7 @@
import com.github.elenterius.biomancy.block.property.UserSensitivity;
import com.github.elenterius.biomancy.block.veins.FleshVeinsBlock;
import com.github.elenterius.biomancy.block.vialholder.VialHolderBlock;
import com.github.elenterius.biomancy.init.ModBlockProperties;
import com.github.elenterius.biomancy.init.ModBlocks;
import net.minecraft.core.Direction;
import net.minecraft.data.PackOutput;
Expand Down Expand Up @@ -99,10 +100,10 @@ protected void registerStatesAndModels() {
fleshDoor(ModBlocks.FLESH_DOOR);
fleshSpikes(ModBlocks.FLESH_SPIKE);
translucentBlockWithItem(ModBlocks.IMPERMEABLE_MEMBRANE);
membraneWithItem(ModBlocks.BABY_PERMEABLE_MEMBRANE);
membraneWithItem(ModBlocks.ADULT_PERMEABLE_MEMBRANE);
membraneWithItem(ModBlocks.PRIMAL_PERMEABLE_MEMBRANE);
membraneWithItem(ModBlocks.UNDEAD_PERMEABLE_MEMBRANE);
translucentBlockWithItem(ModBlocks.BABY_PERMEABLE_MEMBRANE);
translucentBlockWithItem(ModBlocks.ADULT_PERMEABLE_MEMBRANE);
translucentBlockWithItem(ModBlocks.PRIMAL_PERMEABLE_MEMBRANE);
translucentBlockWithItem(ModBlocks.UNDEAD_PERMEABLE_MEMBRANE);

//horizontalBlockWithItem(ModBlocks.NEURAL_INTERCEPTOR);

Expand Down Expand Up @@ -503,24 +504,6 @@ 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
@@ -0,0 +1,22 @@
package com.github.elenterius.biomancy.block.membrane;

import com.github.elenterius.biomancy.init.tags.ModEntityTags;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MobType;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;

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_ALIVE_MOB = (state, level, pos, entity) -> entity instanceof LivingEntity livingEntity && !entity.getType().is(ModEntityTags.FORGE_GOLEMS) && livingEntity.getMobType() != MobType.UNDEAD;
IgnoreEntityCollisionPredicate IS_UNDEAD_MOB = (state, level, pos, entity) -> entity instanceof LivingEntity livingEntity && livingEntity.getMobType() == MobType.UNDEAD;
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);
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package com.github.elenterius.biomancy.block.membrane;

import com.github.elenterius.biomancy.init.tags.ModEntityTags;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MobType;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.HalfTransparentBlock;
Expand All @@ -28,14 +24,17 @@ public MembraneBlock(BlockBehaviour.Properties properties, IgnoreEntityCollision
ignoreEntityCollisionPredicate = predicate;
}

@Override
public VoxelShape getVisualShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
return Shapes.empty();
}

@Override
public float getShadeBrightness(BlockState state, BlockGetter level, BlockPos pos) {
return 1f;
}

@Override
public boolean propagatesSkylightDown(BlockState state, BlockGetter level, BlockPos pos) {
return true;
}
Expand Down Expand Up @@ -71,14 +70,4 @@ public VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPo
return BlockPathTypes.STICKY_HONEY;
}

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_ALIVE_MOB = (state, level, pos, entity) -> entity instanceof LivingEntity livingEntity && !entity.getType().is(ModEntityTags.FORGE_GOLEMS) && livingEntity.getMobType() != MobType.UNDEAD;
IgnoreEntityCollisionPredicate IS_UNDEAD_MOB = (state, level, pos, entity) -> entity instanceof LivingEntity livingEntity && livingEntity.getMobType() == MobType.UNDEAD;
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);
}
}
17 changes: 9 additions & 8 deletions src/main/java/com/github/elenterius/biomancy/init/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.github.elenterius.biomancy.block.fleshkinchest.FleshkinChestBlock;
import com.github.elenterius.biomancy.block.fleshspike.FleshSpikeBlock;
import com.github.elenterius.biomancy.block.mawhopper.MawHopperBlock;
import com.github.elenterius.biomancy.block.membrane.IgnoreEntityCollisionPredicate;
import com.github.elenterius.biomancy.block.membrane.MembraneBlock;
import com.github.elenterius.biomancy.block.membrane.SpreadingMembraneBlock;
import com.github.elenterius.biomancy.block.orifice.OrificeBlock;
Expand Down Expand Up @@ -94,11 +95,11 @@ public final class ModBlocks {
//public static final RegistryObject<NeuralInterceptorBlock> NEURAL_INTERCEPTOR = register("neural_interceptor", NeuralInterceptorBlock::new);

//## Membranes
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> PRIMAL_PERMEABLE_MEMBRANE = registerMembrane("primal_permeable_membrane", MembraneBlock.IgnoreEntityCollisionPredicate.IS_ALIVE_MOB, SpreadingMembraneBlock::new);
public static final RegistryObject<MembraneBlock> UNDEAD_PERMEABLE_MEMBRANE = registerMembrane("undead_permeable_membrane", MembraneBlock.IgnoreEntityCollisionPredicate.IS_UNDEAD_MOB);
public static final RegistryObject<MembraneBlock> IMPERMEABLE_MEMBRANE = registerMembrane("impermeable_membrane", IgnoreEntityCollisionPredicate.NEVER);
public static final RegistryObject<MembraneBlock> BABY_PERMEABLE_MEMBRANE = registerMembrane("baby_permeable_membrane", IgnoreEntityCollisionPredicate.IS_BABY_MOB);
public static final RegistryObject<MembraneBlock> ADULT_PERMEABLE_MEMBRANE = registerMembrane("adult_permeable_membrane", IgnoreEntityCollisionPredicate.IS_ADULT_MOB);
public static final RegistryObject<MembraneBlock> PRIMAL_PERMEABLE_MEMBRANE = registerMembrane("primal_permeable_membrane", IgnoreEntityCollisionPredicate.IS_ALIVE_MOB, SpreadingMembraneBlock::new);
public static final RegistryObject<MembraneBlock> UNDEAD_PERMEABLE_MEMBRANE = registerMembrane("undead_permeable_membrane", IgnoreEntityCollisionPredicate.IS_UNDEAD_MOB);

//## Light Sources
public static final RegistryObject<FleshLanternBlock> PRIMORDIAL_BIO_LANTERN = register("primordial_bio_lantern", properties -> new FleshLanternBlock(properties.sound(SoundType.SHROOMLIGHT).lightLevel(x -> 15).noOcclusion()));
Expand Down Expand Up @@ -151,11 +152,11 @@ 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) {
private static RegistryObject<MembraneBlock> registerMembrane(String name, IgnoreEntityCollisionPredicate predicate) {
return registerMembrane(name, predicate, MembraneBlock::new);
}

private static <T extends MembraneBlock> RegistryObject<T> registerMembrane(String name, MembraneBlock.IgnoreEntityCollisionPredicate predicate, MembraneBlockFactory<T> factory) {
private static <T extends MembraneBlock> RegistryObject<T> registerMembrane(String name, IgnoreEntityCollisionPredicate predicate, MembraneBlockFactory<T> factory) {
return register(name, props -> {
props = props.noOcclusion().isRedstoneConductor(ModBlocks::neverValid).isSuffocating(ModBlocks::neverValid).isViewBlocking(ModBlocks::neverValid);
return factory.create(props, predicate);
Expand Down Expand Up @@ -206,6 +207,6 @@ interface StairBlockFactory<T extends StairBlock> {
}

interface MembraneBlockFactory<T extends MembraneBlock> {
T create(BlockBehaviour.Properties properties, MembraneBlock.IgnoreEntityCollisionPredicate predicate);
T create(BlockBehaviour.Properties properties, IgnoreEntityCollisionPredicate predicate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,12 @@ public static void onBlockModelRegistry(final ModelEvent.RegisterAdditional even
@SubscribeEvent
public static void onItemColorRegistry(final RegisterColorHandlersEvent.Item event) {
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_ACBF60 : 0xFF_FFFFFF, ModBlocks.ADULT_PERMEABLE_MEMBRANE.get());
event.register((stack, tintIndex) -> tintIndex == 1 ? 0xFF_F740FD : 0xFF_FFFFFF, ModBlocks.PRIMAL_PERMEABLE_MEMBRANE.get());
event.register((stack, index) -> index == 1 ? IClientFluidTypeExtensions.of(((BucketItem) stack.getItem()).getFluid()).getTintColor() : 0xFF_FFFFFF, ModItems.ACID_BUCKET.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_ACBF60 : 0xFF_FFFFFF, ModBlocks.ADULT_PERMEABLE_MEMBRANE.get());
event.register((state, level, pos, tintIndex) -> tintIndex == 1 ? 0xFF_F740FD : 0xFF_FFFFFF, ModBlocks.PRIMAL_PERMEABLE_MEMBRANE.get());
}

@SubscribeEvent
Expand Down
146 changes: 0 additions & 146 deletions src/main/resources/assets/biomancy/models/block/template_membrane.json

This file was deleted.

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.
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.
Binary file not shown.
Binary file not shown.
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.
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 c2d9174

Please sign in to comment.