-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make lava fluid destroy certain malignant flesh blocks
- Loading branch information
1 parent
24e8e54
commit 543d55f
Showing
5 changed files
with
78 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/generated/resources/data/biomancy/tags/blocks/lava_destructible.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/java/com/github/elenterius/biomancy/mixin/FlowingFluidMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Boolean> 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<Boolean> 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(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters