-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
88 additions
and
6 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
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
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
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
19 changes: 19 additions & 0 deletions
19
src/main/java/io/github/rektroth/whiteout/mixin/world/explosion/ExplosionAccessor.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,19 @@ | ||
/* | ||
* Patch for MC-27056 | ||
* | ||
* Authored for CraftBukkit/Spigot by commandblockguy <[email protected]> on August 14, 2020. | ||
* Ported to Fabric by Rektroth <[email protected]> on April 24, 2024. | ||
*/ | ||
|
||
package io.github.rektroth.whiteout.mixin.world.explosion; | ||
|
||
import net.minecraft.world.World; | ||
import net.minecraft.world.explosion.Explosion; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin(Explosion.class) | ||
public interface ExplosionAccessor { | ||
@Accessor("world") | ||
World getWorld(); | ||
} |
62 changes: 62 additions & 0 deletions
62
src/main/java/io/github/rektroth/whiteout/mixin/world/explosion/ExplosionMixin.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,62 @@ | ||
/* | ||
* Patch for MC-27056 | ||
* | ||
* Authored for CraftBukkit/Spigot by commandblockguy <[email protected]> on August 14, 2020. | ||
* Ported to Fabric by Rektroth <[email protected]> on April 24, 2024. | ||
*/ | ||
|
||
package io.github.rektroth.whiteout.mixin.world.explosion; | ||
|
||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.Blocks; | ||
import net.minecraft.block.PistonHeadBlock; | ||
import net.minecraft.block.entity.BlockEntity; | ||
import net.minecraft.block.entity.PistonBlockEntity; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.world.explosion.Explosion; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
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.LocalCapture; | ||
|
||
import java.util.Set; | ||
|
||
@Mixin(Explosion.class) | ||
public class ExplosionMixin { | ||
@Inject( | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/world/explosion/ExplosionBehavior;canDestroyBlock(Lnet/minecraft/world/explosion/Explosion;Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;F)Z"), | ||
locals = LocalCapture.CAPTURE_FAILHARD, | ||
method = "collectBlocksAndDamageEntities()V") | ||
public void noHeadlessPiston( | ||
CallbackInfo ci, | ||
Set<BlockPos> set, | ||
int i, | ||
int j, | ||
int k, | ||
int l, | ||
double d, | ||
double e, | ||
double f, | ||
double g, | ||
float h, | ||
double m, | ||
double n, | ||
double o, | ||
float p, | ||
BlockPos blockPos, | ||
BlockState blockState | ||
) { | ||
if (blockState.getBlock() == Blocks.MOVING_PISTON) { | ||
BlockEntity extension = ((ExplosionAccessor)this).getWorld().getBlockEntity(blockPos); | ||
|
||
if (extension instanceof PistonBlockEntity blockEntity && blockEntity.isSource()) { | ||
Direction direction = blockState.get(PistonHeadBlock.FACING); | ||
set.add(blockPos.offset(direction.getOpposite())); | ||
} | ||
} | ||
} | ||
} |
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