Skip to content

Commit

Permalink
Fix MC-27056
Browse files Browse the repository at this point in the history
  • Loading branch information
Rektroth committed Apr 24, 2024
1 parent 98c8b1b commit 49269f9
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Whiteout is an attempt to implement the bug fixes offered by the [Paper](https:/
| Bug | Lazy? | Name |
|-------------------------------------------------------|-------|----------------------------------------------------------------------|
| [MC-4](https://bugs.mojang.com/browse/MC-4) | Yes | Item drops sometimes appear at the wrong location |
| [MC-27056](https://bugs.mojang.com/browse/MC-27056) | Yes | You can blow the extension off a piston |
| [MC-158900](https://bugs.mojang.com/browse/MC-158900) | No | "bad packet id 26" upon connecting after tempban expire |
| [MC-257487](https://bugs.mojang.com/browse/MC-257487) | No | The ender dragon's name is not reset when it is respawned in the end |

Expand All @@ -18,7 +19,6 @@ Some of the patches are "lazy". This means that the Paper maintainers are not in
| Bug | Name |
|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [MC-11193](https://bugs.mojang.com/browse/MC-11193) | The order in which powerable blocks (e.g. redstone dust blocks) along a wire are powered or de-powered is not clearly defined and causes a non-deterministic behavior for redstone contraptions |
| [MC-27056](https://bugs.mojang.com/browse/MC-27056) | You can blow the extension off a piston |
| [MC-33041](https://bugs.mojang.com/browse/MC-33041) | Dedicated server logs "java.io.IOException: The handle is invalid" on startup |
| [MC-81098](https://bugs.mojang.com/browse/MC-81098) | Redstone dust updates cause lag |
| [MC-99075](https://bugs.mojang.com/browse/MC-99075) | Cancelled block place (spawn protection) causes inventory desync |
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_mappings=1.20.5+build.1
loader_version=0.15.10

# Mod Properties
mod_version=0.2.1
mod_version=0.3.0
maven_group=io.github.rektroth
archives_base_name=whiteout

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@Mixin(Entity.class)
public abstract class EntityMixin implements Nameable, EntityLike, CommandOutput {
// `(Entity)(Object)this` sort of "tricks" the compiler
// https://www.reddit.com/r/fabricmc/comments/nw3rs8/how_can_i_access_the_this_in_a_mixin_for_a_class/
// https://fabricmc.net/wiki/tutorial:mixin_examples#access_the_this_instance_of_the_class_your_mixin_is_targeting
// IDE will likely say the code after the check is unreachable, but it isn't

@ModifyVariable(argsOnly = true, at = @At("HEAD"), method = "setPos(DDD)V", ordinal = 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

package io.github.rektroth.whiteout.mixin.entity.boss.dragon;

import io.github.rektroth.whiteout.mixin.entity.boss.dragon.EnderDragonFightAccessor;
import net.minecraft.entity.boss.ServerBossBar;
import net.minecraft.entity.boss.dragon.EnderDragonEntity;
import net.minecraft.entity.boss.dragon.EnderDragonFight;
Expand Down
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();
}
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()));
}
}
}
}
6 changes: 4 additions & 2 deletions src/main/resources/whiteout.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
"package": "io.github.rektroth.whiteout.mixin",
"compatibilityLevel": "JAVA_21",
"mixins": [
"entity.boss.dragon.EnderDragonFightAccessor",
"entity.boss.dragon.EnderDragonFightMixin",
"entity.EntityMixin",
"server.PlayerManagerAccessor",
"server.PlayerManagerMixin",
"entity.boss.dragon.EnderDragonFightAccessor",
"entity.boss.dragon.EnderDragonFightMixin"
"world.explosion.ExplosionAccessor",
"world.explosion.ExplosionMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 49269f9

Please sign in to comment.