Skip to content

Commit

Permalink
Fix methods injection (#766)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakambda authored Oct 23, 2024
1 parent eeb5759 commit 1d03e98
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
@Mixin(BlockBehaviour.class)
public abstract class AbstractBlockMixin{
@Inject(method = "getDestroyProgress", at = @At(value = "TAIL"), cancellable = true)
public void calcBlockBreakingDelta(BlockState state, Player player, BlockGetter level, BlockPos pos, CallbackInfoReturnable<Float> callbackInfoReturnable){
public void calcBlockBreakingDelta(BlockState blockState, Player player, BlockGetter blockGetter, BlockPos blockPos, CallbackInfoReturnable<Float> callbackInfoReturnable){
var wrappedPlayer = new PlayerWrapper(player);
var wrappedPos = new BlockPosWrapper(pos);
var wrappedPos = new BlockPosWrapper(blockPos);

var result = FallingTree.getMod().getTreeHandler().getBreakSpeed(wrappedPlayer, wrappedPos, callbackInfoReturnable.getReturnValue());
if(result.isEmpty()){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.redstone.Orientation;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -30,16 +32,16 @@ public void updateNeighborsAlways(BlockPos pos, Block block, CallbackInfo callba
}

@Inject(method = "updateNeighborsAtExceptFromFacing", at = @At(value = "TAIL"))
public void updateNeighborsExcept(BlockPos pos, Block sourceBlock, Direction direction, CallbackInfo callbackInfo){
public void updateNeighborsExcept(BlockPos blockPos, Block block, Direction direction, @Nullable Orientation orientation, CallbackInfo callbackInfo){
//noinspection ConstantConditions
var serverLevel = (ServerLevel) (Object) this;
var directions = EnumSet.allOf(Direction.class);
directions.remove(direction);

FallingTree.getMod().getLeafBreakingHandler().onBlockUpdate(
new ServerLevelWrapper(serverLevel),
new BlockPosWrapper(pos),
new BlockStateWrapper(serverLevel.getBlockState(pos)),
new BlockPosWrapper(blockPos),
new BlockStateWrapper(serverLevel.getBlockState(blockPos)),
directions.stream().map(FallingTree.getMod()::asDirectionCompat).collect(Collectors.toSet()));
}
}

0 comments on commit 1d03e98

Please sign in to comment.