From e95ee602e755e06215797b2877c9899b3ba2cf55 Mon Sep 17 00:00:00 2001 From: zml Date: Sun, 5 Dec 2021 11:43:32 -0800 Subject: [PATCH] Work around SpongePowered/Mixin#541 --- .../level/ServerLevelMixin_Tracker.java | 30 +++++++++---------- .../world/level/LevelMixin_Tracker.java | 23 +++++--------- 2 files changed, 23 insertions(+), 30 deletions(-) diff --git a/src/mixins/java/org/spongepowered/common/mixin/tracker/server/level/ServerLevelMixin_Tracker.java b/src/mixins/java/org/spongepowered/common/mixin/tracker/server/level/ServerLevelMixin_Tracker.java index ffaa3115af2..f2ac6648c3d 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/tracker/server/level/ServerLevelMixin_Tracker.java +++ b/src/mixins/java/org/spongepowered/common/mixin/tracker/server/level/ServerLevelMixin_Tracker.java @@ -171,53 +171,53 @@ public abstract class ServerLevelMixin_Tracker extends LevelMixin_Tracker implem @Redirect(method = "tickBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/Block;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;tick(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;Ljava/util/Random;)V")) - private void tracker$wrapBlockTick(BlockState blockState, ServerLevel worldIn, BlockPos posIn, Random randomIn) { + private void tracker$wrapBlockTick(final BlockState blockState, final ServerLevel worldIn, final BlockPos posIn, final Random randomIn) { TrackingUtil.updateTickBlock(this, blockState, posIn, randomIn); } @Redirect(method = "tickFluid(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/material/Fluid;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/material/FluidState;tick(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)V")) - private void tracker$wrapFluidTick(FluidState fluidState, net.minecraft.world.level.Level level, BlockPos pos) { + private void tracker$wrapFluidTick(final FluidState fluidState, final net.minecraft.world.level.Level level, final BlockPos pos) { TrackingUtil.updateTickFluid(this, fluidState, pos); } - private ScheduledTick tracker$createTick(BlockPos pos, T type, int triggerTick, TickPriority priority) { - return new ScheduledTick<>(type, pos, this.shadow$getLevelData().getGameTime() + (long)triggerTick, priority, this.shadow$nextSubTickCount()); + private ScheduledTick tracker$createTick(final BlockPos pos, final T type, final int triggerTick, final TickPriority priority) { + return new ScheduledTick<>(type, pos, this.getLevelData().getGameTime() + (long)triggerTick, priority, this.nextSubTickCount()); } - private ScheduledTick tracker$createTick(BlockPos pos, T type, int triggerTick) { - return new ScheduledTick<>(type, pos, this.shadow$getLevelData().getGameTime() + (long)triggerTick, this.shadow$nextSubTickCount()); + private ScheduledTick tracker$createTick(final BlockPos pos, final T type, final int triggerTick) { + return new ScheduledTick<>(type, pos, this.getLevelData().getGameTime() + (long)triggerTick, this.nextSubTickCount()); } @Override - public void shadow$scheduleTick(BlockPos pos, Block block, int triggerTick, TickPriority priority) { + public void scheduleTick(final BlockPos pos, final Block block, final int triggerTick, final TickPriority priority) { final var scheduledTick = this.tracker$createTick(pos, block, triggerTick, priority); PhaseTracker.getInstance().getPhaseContext().associateScheduledTickUpdate((ServerLevel) (Object) this, scheduledTick); - this.shadow$getBlockTicks().schedule(scheduledTick); + this.getBlockTicks().schedule(scheduledTick); } @Override - public void shadow$scheduleTick(BlockPos pos, Block block, int triggerTick) { + public void scheduleTick(final BlockPos pos, final Block block, final int triggerTick) { final var scheduledTick = this.tracker$createTick(pos, block, triggerTick); PhaseTracker.getInstance().getPhaseContext().associateScheduledTickUpdate((ServerLevel) (Object) this, scheduledTick); - this.shadow$getBlockTicks().schedule(scheduledTick); + this.getBlockTicks().schedule(scheduledTick); } @Override - public void shadow$scheduleTick( - BlockPos pos, Fluid fluid, int triggerTick, TickPriority priority + public void scheduleTick( + final BlockPos pos, final Fluid fluid, final int triggerTick, final TickPriority priority ) { final var scheduledTick = this.tracker$createTick(pos, fluid, triggerTick, priority); PhaseTracker.getInstance().getPhaseContext().associateScheduledTickUpdate((ServerLevel) (Object) this, scheduledTick); - this.shadow$getFluidTicks().schedule(scheduledTick); + this.getFluidTicks().schedule(scheduledTick); } @Override - public void shadow$scheduleTick(BlockPos pos, Fluid fluid, int triggerTick) { + public void scheduleTick(final BlockPos pos, final Fluid fluid, final int triggerTick) { final var scheduledTick = this.tracker$createTick(pos, fluid, triggerTick); PhaseTracker.getInstance().getPhaseContext().associateScheduledTickUpdate((ServerLevel) (Object) this, scheduledTick); - this.shadow$getFluidTicks().schedule(scheduledTick); + this.getFluidTicks().schedule(scheduledTick); } /** diff --git a/src/mixins/java/org/spongepowered/common/mixin/tracker/world/level/LevelMixin_Tracker.java b/src/mixins/java/org/spongepowered/common/mixin/tracker/world/level/LevelMixin_Tracker.java index b0d244d97a0..20c5d05ed89 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/tracker/world/level/LevelMixin_Tracker.java +++ b/src/mixins/java/org/spongepowered/common/mixin/tracker/world/level/LevelMixin_Tracker.java @@ -24,22 +24,13 @@ */ package org.spongepowered.common.mixin.tracker.world.level; -import net.minecraft.world.level.block.entity.TickingBlockEntity; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.Slice; -import org.spongepowered.common.bridge.TrackableBridge; -import org.spongepowered.common.bridge.world.level.LevelBridge; - -import javax.annotation.Nullable; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.TickingBlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.material.FluidState; @@ -52,21 +43,21 @@ import org.spongepowered.asm.mixin.injection.Coerce; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.common.bridge.world.level.LevelBridge; import org.spongepowered.common.event.ShouldFire; import org.spongepowered.common.event.SpongeCommonEventFactory; import org.spongepowered.common.event.tracking.PhaseTracker; -import javax.annotation.Nullable; - import java.util.List; import java.util.Random; import java.util.function.Consumer; import java.util.function.Predicate; +import javax.annotation.Nullable; + @Mixin(Level.class) -public abstract class LevelMixin_Tracker implements LevelBridge, LevelAccessorMixin_Tracker { +public abstract class LevelMixin_Tracker implements LevelBridge, LevelAccessor { // @formatter:off @Shadow @Final public Random random; @@ -74,6 +65,7 @@ public abstract class LevelMixin_Tracker implements LevelBridge, LevelAccessorMi @Shadow public abstract LevelChunk shadow$getChunkAt(BlockPos pos); @Shadow public abstract void shadow$guardEntityTick(Consumer p_217390_1_, Entity p_217390_2_); + @Override @Shadow public boolean setBlock(final BlockPos pos, final BlockState state, final int flags, final int limit) { throw new IllegalStateException("Untransformed shadow!"); } @Shadow public void shadow$removeBlockEntity(final BlockPos pos) { } // shadowed @Shadow @Nullable public abstract BlockEntity shadow$getBlockEntity(BlockPos pos); @@ -81,6 +73,7 @@ public abstract class LevelMixin_Tracker implements LevelBridge, LevelAccessorMi @Shadow public void shadow$neighborChanged(final BlockPos pos, final Block blockIn, final BlockPos fromPos) { } // Shadowed @Shadow public abstract BlockState shadow$getBlockState(BlockPos pos); @Shadow public abstract boolean shadow$isDebug(); + @Override @Shadow public boolean destroyBlock(final BlockPos p_241212_1_, final boolean p_241212_2_, @Nullable final Entity p_241212_3_, final int p_241212_4_) { throw new IllegalStateException("Untransformed shadow!"); } @Shadow public abstract FluidState shadow$getFluidState(BlockPos p_204610_1_); // @formatter:on