Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
zml2008 committed Dec 5, 2021
1 parent b20f26e commit e95ee60
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T> ScheduledTick<T> 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 <T> ScheduledTick<T> 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 <T> ScheduledTick<T> tracker$createTick(BlockPos pos, T type, int triggerTick) {
return new ScheduledTick<>(type, pos, this.shadow$getLevelData().getGameTime() + (long)triggerTick, this.shadow$nextSubTickCount());
private <T> ScheduledTick<T> 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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -52,35 +43,37 @@
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;
@Shadow @Final protected WritableLevelData levelData;

@Shadow public abstract LevelChunk shadow$getChunkAt(BlockPos pos);
@Shadow public abstract void shadow$guardEntityTick(Consumer<Entity> 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);
@Shadow public void shadow$setBlockEntity(final BlockEntity tileEntity) { } // Shadowed
@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
Expand Down

0 comments on commit e95ee60

Please sign in to comment.