diff --git a/src/datagen/java/com/github/elenterius/biomancy/datagen/tags/ModBlockTagsProvider.java b/src/datagen/java/com/github/elenterius/biomancy/datagen/tags/ModBlockTagsProvider.java index 0d4c7eaf7..a0d56bc63 100644 --- a/src/datagen/java/com/github/elenterius/biomancy/datagen/tags/ModBlockTagsProvider.java +++ b/src/datagen/java/com/github/elenterius/biomancy/datagen/tags/ModBlockTagsProvider.java @@ -68,6 +68,16 @@ protected void addTags(HolderLookup.Provider provider) { .add(Blocks.MOSS_BLOCK, Blocks.VINE) .addTag(BlockTags.FLOWERS); + tag(ModBlockTags.LAVA_DESTRUCTIBLE).add( + ModBlocks.MALIGNANT_FLESH_VEINS.get(), + ModBlocks.MALIGNANT_FLESH_SLAB.get(), + ModBlocks.MALIGNANT_FLESH_STAIRS.get(), + ModBlocks.MALIGNANT_FLESH_WALL.get(), + ModBlocks.PRIMAL_BLOOM.get(), + ModBlocks.PRIMAL_PERMEABLE_MEMBRANE.get(), + ModBlocks.PRIMAL_PERMEABLE_MEMBRANE_PANE.get() + ); + tag(BlockTags.DOORS).add(ModBlocks.FLESH_DOOR.get()).add(ModBlocks.FULL_FLESH_DOOR.get()); tag(BlockTags.TRAPDOORS).add(ModBlocks.FLESH_IRIS_DOOR.get()); diff --git a/src/generated/resources/data/biomancy/tags/blocks/lava_destructible.json b/src/generated/resources/data/biomancy/tags/blocks/lava_destructible.json new file mode 100644 index 000000000..06f98d42f --- /dev/null +++ b/src/generated/resources/data/biomancy/tags/blocks/lava_destructible.json @@ -0,0 +1,11 @@ +{ + "values": [ + "biomancy:malignant_flesh_veins", + "biomancy:malignant_flesh_slab", + "biomancy:malignant_flesh_stairs", + "biomancy:malignant_flesh_wall", + "biomancy:primal_bloom", + "biomancy:primal_permeable_membrane", + "biomancy:primal_permeable_membrane_pane" + ] +} \ No newline at end of file diff --git a/src/main/java/com/github/elenterius/biomancy/init/tags/ModBlockTags.java b/src/main/java/com/github/elenterius/biomancy/init/tags/ModBlockTags.java index 61f493945..6561bd53b 100644 --- a/src/main/java/com/github/elenterius/biomancy/init/tags/ModBlockTags.java +++ b/src/main/java/com/github/elenterius/biomancy/init/tags/ModBlockTags.java @@ -12,6 +12,7 @@ public final class ModBlockTags { public static final TagKey ALLOW_VEINS_TO_ATTACH = tag("allow_veins_to_attach"); public static final TagKey DISALLOW_VEINS_TO_ATTACH = tag("disallow_veins_to_attach"); public static final TagKey ACID_DESTRUCTIBLE = tag("acid_destructible"); + public static final TagKey LAVA_DESTRUCTIBLE = tag("lava_destructible"); private ModBlockTags() {} diff --git a/src/main/java/com/github/elenterius/biomancy/mixin/FlowingFluidMixin.java b/src/main/java/com/github/elenterius/biomancy/mixin/FlowingFluidMixin.java new file mode 100644 index 000000000..258e8c7a4 --- /dev/null +++ b/src/main/java/com/github/elenterius/biomancy/mixin/FlowingFluidMixin.java @@ -0,0 +1,52 @@ +package com.github.elenterius.biomancy.mixin; + +import com.github.elenterius.biomancy.init.tags.ModBlockTags; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.FlowingFluid; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.LavaFluid; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(FlowingFluid.class) +public abstract class FlowingFluidMixin extends Fluid { + + @Unique + private boolean biomancy$isLavaFluid() { + FlowingFluid fluid = (FlowingFluid) (Object) this; + return fluid instanceof LavaFluid; + } + + @Inject(method = "canPassThrough", at = @At(value = "HEAD"), cancellable = true) + private void onCanPassThrough(BlockGetter level, Fluid fluid, BlockPos fromPos, BlockState fromBlockState, Direction direction, BlockPos toPos, BlockState toBlockState, FluidState toFluidState, CallbackInfoReturnable cir) { + if (biomancy$isLavaFluid() && toBlockState.is(ModBlockTags.LAVA_DESTRUCTIBLE)) { + cir.setReturnValue(true); + } + } + + @Inject(method = "canSpreadTo", at = @At(value = "HEAD"), cancellable = true) + private void onCanSpreadTo(BlockGetter level, BlockPos fromPos, BlockState fromBlockState, Direction direction, BlockPos toPos, BlockState toBlockState, FluidState toFluidState, Fluid fluid, CallbackInfoReturnable cir) { + if (biomancy$isLavaFluid() && toBlockState.is(ModBlockTags.LAVA_DESTRUCTIBLE)) { + cir.setReturnValue(true); + } + } + + @Inject(method = "spreadTo", at = @At(value = "HEAD"), cancellable = true) + private void onSpreadTo(LevelAccessor level, BlockPos pos, BlockState state, Direction direction, FluidState fluidState, CallbackInfo ci) { + if (biomancy$isLavaFluid() && state.is(ModBlockTags.LAVA_DESTRUCTIBLE)) { + level.setBlock(pos, fluidState.createLegacyBlock(), Block.UPDATE_ALL); + ci.cancel(); + } + } + +} diff --git a/src/main/resources/mixins.biomancy.json b/src/main/resources/mixins.biomancy.json index ff1f5ffb2..f85ad0f28 100644 --- a/src/main/resources/mixins.biomancy.json +++ b/src/main/resources/mixins.biomancy.json @@ -9,10 +9,10 @@ }, "mixins": [ "AgeableMobAccessor", "AnimalMixin", "AreaEffectCloudMixin", "ArmorStandAccessor", "ArrowMixin", "BiomeAccessor", "ChickenMixin", "CowMixin", - "DamageSourceAccessor", "EntityAccessor", "IntegerPropertyAccessor", "LivingEntityAccessor", "LivingEntityMixin", "MobEffectInstanceAccessor", - "MobEffectInstanceMixin", "MobEntityAccessor", "PhantomMixin", "PigMixin", "PlayerMixin", "ServerLevelAccessor", "ServerLevelMixin", "SheepAccessor", - "SheepMixin", "SlimeAccessor", "SuspiciousStewItemAccessor", "SwordItemMixinAccessor", "TadpoleAccessor", "TextureSlotAccessor", "ThrownPotionMixin", - "UnbreakingEnchantmentMixin", "WallBlockMixin", "ZombieVillagerMixinAccessor" + "DamageSourceAccessor", "EntityAccessor", "FlowingFluidMixin", "IntegerPropertyAccessor", "LivingEntityAccessor", "LivingEntityMixin", + "MobEffectInstanceAccessor", "MobEffectInstanceMixin", "MobEntityAccessor", "PhantomMixin", "PigMixin", "PlayerMixin", "ServerLevelAccessor", + "ServerLevelMixin", "SheepAccessor", "SheepMixin", "SlimeAccessor", "SuspiciousStewItemAccessor", "SwordItemMixinAccessor", "TadpoleAccessor", + "TextureSlotAccessor", "ThrownPotionMixin", "UnbreakingEnchantmentMixin", "WallBlockMixin", "ZombieVillagerMixinAccessor" ], "client": [ "client.ClientPackListenerMixin", "client.ClientRecipeBookMixin", "client.GuiGraphicsMixin", "client.PlayerRendererMixin", "client.RecipeCollectionAccessor"