Skip to content

Commit

Permalink
update parameter names to match parchment
Browse files Browse the repository at this point in the history
  • Loading branch information
CursedFlames committed Jan 21, 2024
1 parent 6960725 commit c9a10d9
Show file tree
Hide file tree
Showing 21 changed files with 211 additions and 210 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@Mixin(TicketType.class)
public interface TicketTypeAccess {
@Invoker("<init>") static <T> TicketType<T> createNew(String string, Comparator<T> comparator, long l) {
@Invoker("<init>") static <T> TicketType<T> createNew(String string, Comparator<T> comparator, long timeout) {
throw new Error("Mixin did not apply");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public void cc_setCubic() {
}

@Inject(method = "resortChunkTasks", at = @At("HEAD"))
private void cc_onResortChunkTasks(int p_140522_, ChunkPos p_140523_, int p_140524_, CallbackInfo ci) {
private void cc_onResortChunkTasks(int queueLevel, ChunkPos chunkPos, int ticketLevel, CallbackInfo ci) {
assert !cc_isCubic;
}

@UsedFromASM
@TransformFrom("resortChunkTasks(ILnet/minecraft/world/level/ChunkPos;I)V")
protected abstract <T> void resortCubicTasks(int p_140522_, CloPos p_140523_, int p_140524_);
protected abstract <T> void resortCubicTasks(int queueLevel, CloPos cloPos, int ticketLevel);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ private Stream<String> cc_replaceChunkPosInDebugStatus(Stream<Long> instance, Fu
}

@Inject(method = "onLevelChange", at = @At("HEAD"))
private void cc_onChunkOnLevelChange(ChunkPos p_140616_, IntSupplier p_140617_, int p_140618_, IntConsumer p_140619_, CallbackInfo ci) {
private void cc_onChunkOnLevelChange(ChunkPos chunkPos, IntSupplier p_140617_, int p_140618_, IntConsumer p_140619_, CallbackInfo ci) {
assert !cc_isCubic;
}

@Override
@UsedFromASM
@TransformFrom("onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V")
public abstract <T> void onLevelChange(CloPos p_140616_, IntSupplier p_140617_, int p_140618_, IntConsumer p_140619_);
public abstract <T> void onLevelChange(CloPos cloPos, IntSupplier p_140617_, int p_140618_, IntConsumer p_140619_);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
@Mixin(DistanceManager.ChunkTicketTracker.class)
public abstract class MixinChunkTicketTracker extends MixinChunkTracker {
@Inject(method = "setLevel", at = @At("HEAD"))
private void cc_onSetLevel(long pos, int level, CallbackInfo ci) {
super.cc_onSetLevel(pos, level);
private void cc_onSetLevel(long sectionPos, int level, CallbackInfo ci) {
super.cc_onSetLevel(sectionPos, level);
}
// TODO if/when we replace ChunkHolder with a cubic equivalent we'll need mixins here
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ private long cc_sentinelValue() {
}

@ModifyConstant(method = "computeLevelFromNeighbor", constant = @Constant(intValue = 1))
private int cc_dontIncrementLevelOnCubeChunkEdge(int constant, @Local(ordinal = 0, argsOnly = true) long fromPos, @Local(ordinal = 1, argsOnly = true) long toPos) {
if (cc_isCubic && CloPos.isCube(fromPos) && CloPos.isChunk(toPos)) return 0;
private int cc_dontIncrementLevelOnCubeChunkEdge(int constant, @Local(ordinal = 0, argsOnly = true) long startPos, @Local(ordinal = 1, argsOnly = true) long endPos) {
if (cc_isCubic && CloPos.isCube(startPos) && CloPos.isChunk(endPos)) return 0;
return constant;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,36 +54,36 @@ private void cc_onUseChunkPos(CallbackInfo ci){
@Override
@UsedFromASM
@TransformFrom("addTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V")
public abstract <T> void addTicket(TicketType<T> p_140793_, CloPos p_140794_, int p_140795_, T p_140796_);
public abstract <T> void addTicket(TicketType<T> type, CloPos pos, int level, T value);

@Override
@UsedFromASM
@TransformFrom("removeTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V")
public abstract <T> void removeTicket(TicketType<T> p_140824_, CloPos p_140825_, int p_140826_, T p_140827_);
public abstract <T> void removeTicket(TicketType<T> type, CloPos pos, int level, T value);

@Override
@UsedFromASM
@TransformFrom("addRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V")
public abstract <T> void addRegionTicket(TicketType<T> p_140841_, CloPos p_140842_, int p_140843_, T p_140844_);
public abstract <T> void addRegionTicket(TicketType<T> type, CloPos pos, int distance, T value);

@Override
@UsedFromASM
@TransformFrom("addRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;Z)V")
public abstract <T> void addRegionTicket(TicketType<T> p_140841_, CloPos p_140842_, int p_140843_, T p_140844_, boolean forceTicks);
public abstract <T> void addRegionTicket(TicketType<T> type, CloPos pos, int distance, T value, boolean forceTicks);

@Override
@UsedFromASM
@TransformFrom("removeRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V")
public abstract <T> void removeRegionTicket(TicketType<T> p_140850_, CloPos p_140851_, int p_140852_, T p_140853_);
public abstract <T> void removeRegionTicket(TicketType<T> type, CloPos pos, int distance, T value);

@Override
@UsedFromASM
@TransformFrom("removeRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;Z)V")
public abstract <T> void removeRegionTicket(TicketType<T> p_140850_, CloPos p_140851_, int p_140852_, T p_140853_, boolean forceTicks);
public abstract <T> void removeRegionTicket(TicketType<T> type, CloPos pos, int distance, T value, boolean forceTicks);

@UsedFromASM
@TransformFrom("updateChunkForced(Lnet/minecraft/world/level/ChunkPos;Z)V")
protected abstract void updateCubeForced(CloPos p_140800_, boolean p_140801_);
protected abstract void updateCubeForced(CloPos pos, boolean add);

/**
* This function replaces a TicketType with a CubicTicketType.
Expand All @@ -100,10 +100,10 @@ private TicketType<?> cc_replaceTicketTypeOnUpdateChunkForced(Operation<TicketTy
* This requires replacing the TicketType with a CubicTicketType and the ChunkPos with a CloPos.
*/
@WrapWithCondition(method = "addPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/TickingTracker;addTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V"))
private <T> boolean cc_replaceTicketTypeOnAddPlayer(TickingTracker instance, TicketType<T> p_184155_, ChunkPos p_184156_, int p_184157_, T p_184158_, SectionPos p_140803) {
private <T> boolean cc_replaceTicketTypeOnAddPlayer(TickingTracker instance, TicketType<T> type, ChunkPos chunkPos, int ticketLevel, T key, SectionPos sectionPos) {
if(!cc_isCubic) return true;
CloPos cloPos = CloPos.section(p_140803);
((CubicTickingTracker)instance).addTicket(CubicTicketType.PLAYER, cloPos, p_184157_, cloPos);
CloPos cloPos = CloPos.section(sectionPos);
((CubicTickingTracker)instance).addTicket(CubicTicketType.PLAYER, cloPos, ticketLevel, cloPos);
return false;
}

Expand All @@ -113,29 +113,29 @@ private <T> boolean cc_replaceTicketTypeOnAddPlayer(TickingTracker instance, Tic
* This requires replacing the TicketType with a CubicTicketType and the ChunkPos with a CloPos.
*/
@WrapWithCondition(method = "removePlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/TickingTracker;removeTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V"))
private <T> boolean cc_replaceTicketTypeOnRemovePlayer(TickingTracker instance, TicketType<T> p_184169_, ChunkPos p_184170_, int p_184171_, T p_184172_, SectionPos p_140803) {
private <T> boolean cc_replaceTicketTypeOnRemovePlayer(TickingTracker instance, TicketType<T> type, ChunkPos chunkPos, int ticketLevel, T key, SectionPos sectionPos) {
if(!cc_isCubic) return true;
CloPos cloPos = CloPos.section(p_140803);
((CubicTickingTracker)instance).removeTicket(CubicTicketType.PLAYER, cloPos, p_184171_, cloPos);
CloPos cloPos = CloPos.section(sectionPos);
((CubicTickingTracker)instance).removeTicket(CubicTicketType.PLAYER, cloPos, ticketLevel, cloPos);
return false;
}

/**
* The original function expects chunkPos.toLong(), but we need to replace it with cloPos.toLong() instead.
*/
@WrapOperation(method = "addPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/ChunkPos;toLong()J"))
private long cc_replaceTicketTypeOnAddPlayer(ChunkPos chunkPos, Operation<Long> original, SectionPos p_140803) {
private long cc_replaceTicketTypeOnAddPlayer(ChunkPos chunkPos, Operation<Long> original, SectionPos sectionPos) {
if(!cc_isCubic) return original.call(chunkPos);
return CloPos.section(p_140803).toLong();
return CloPos.section(sectionPos).toLong();
}

/**
* The original function expects chunkPos.toLong(), but we need to replace it with cloPos.toLong() instead.
*/
@WrapOperation(method = "removePlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/ChunkPos;toLong()J"))
private long cc_replaceTicketTypeOnRemovePlayer(ChunkPos chunkPos, Operation<Long> original, SectionPos p_140803) {
private long cc_replaceTicketTypeOnRemovePlayer(ChunkPos chunkPos, Operation<Long> original, SectionPos sectionPos) {
if(!cc_isCubic) return original.call(chunkPos);
return CloPos.section(p_140803).toLong();
return CloPos.section(sectionPos).toLong();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
@Mixin(DistanceManager.FixedPlayerDistanceChunkTracker.class)
public abstract class MixinFixedPlayerDistanceChunkTracker extends MixinChunkTracker {
@Inject(method = "setLevel", at = @At("HEAD"))
private void cc_onSetLevel(long pos, int level, CallbackInfo ci) {
super.cc_onSetLevel(pos, level);
private void cc_onSetLevel(long sectionPos, int level, CallbackInfo ci) {
super.cc_onSetLevel(sectionPos, level);
}

// TODO do we care about dumpChunks?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ public abstract class MixinPlayerTicketTracker extends MixinFixedPlayerDistanceC
*/
@WrapOperation(method = "onLevelChange(JIZZ)V", at = @At(value = "NEW",
target = "(Lnet/minecraft/server/level/TicketType;ILjava/lang/Object;)Lnet/minecraft/server/level/Ticket;"))
private Ticket<?> cc_onTicketConstruct(TicketType<?> ttype, int a, Object pos, Operation<Ticket> original) {
private Ticket<?> cc_onTicketConstruct(TicketType<?> type, int ticketLevel, Object key, Operation<Ticket> original) {
if (!cc_isCubic)
return original.call(ttype, a, pos);
return original.call(CubicTicketType.PLAYER, a, CloPos.fromLong(((ChunkPos) pos).toLong()));
return original.call(type, ticketLevel, key);
return original.call(CubicTicketType.PLAYER, ticketLevel, CloPos.fromLong(((ChunkPos) key).toLong()));
}

/**
* This modifies the lambda inside Distance.this.ticketThrottler.onLevelChange to use a CloPos instead of a ChunkPos.
*/
@WrapWithCondition(method = "runAllUpdates", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkTaskPriorityQueueSorter;onLevelChange(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/IntSupplier;ILjava/util/function/IntConsumer;)V"))
private boolean cc_onRunAllUpdates(ChunkTaskPriorityQueueSorter instance, ChunkPos p_140616_, IntSupplier p_140617_, int p_140618_, IntConsumer p_140619_) {
private boolean cc_onRunAllUpdates(ChunkTaskPriorityQueueSorter instance, ChunkPos chunkPos, IntSupplier p_140617_, int p_140618_, IntConsumer p_140619_) {
if(!cc_isCubic) return true;
((CubicTaskPriorityQueueSorter)((DistanceManagerAccess)this$0).ticketThrottler())
.onLevelChange(CloPos.fromLong(p_140616_.toLong()), p_140617_, p_140618_, p_140619_);
.onLevelChange(CloPos.fromLong(chunkPos.toLong()), p_140617_, p_140618_, p_140619_);
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ public void cc_setCubic() {
*/
@WrapWithCondition(method = "teleportTo(Lnet/minecraft/server/level/ServerLevel;DDDLjava/util/Set;FF)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level"
+ "/ServerChunkCache;addRegionTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V"))
public <T> boolean cc_wrapAddRegionTicket(ServerChunkCache instance, TicketType<T> ticketType, ChunkPos chunkPos, int p_8390_, T p_8391_,
public <T> boolean cc_wrapAddRegionTicket(ServerChunkCache instance, TicketType<T> type, ChunkPos pos, int distance, T value,
@Local(ordinal = 0, argsOnly = true)double x,
@Local(ordinal = 1, argsOnly = true)double y,
@Local(ordinal = 2, argsOnly = true)double z) {
if (!cc_isCubic) {
return true;
}
// TODO: Add once Cubic ServerChunkCache exists
//instance.addRegionTicket(ticketType, CloPos.cube(BlockPos.containing(x, y, z)), 1, this.getId());
//instance.addRegionTicket(type, CloPos.cube(BlockPos.containing(x, y, z)), 1, this.getId());
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
@Mixin(TickingTracker.class)
public abstract class MixinTickingTracker extends MixinChunkTracker implements CubicTickingTracker {
@Inject(method = "setLevel", at = @At("HEAD"))
private void cc_onSetLevel(long pos, int level, CallbackInfo ci) {
super.cc_onSetLevel(pos, level);
private void cc_onSetLevel(long chunkPos, int level, CallbackInfo ci) {
super.cc_onSetLevel(chunkPos, level);
}

@Inject(method = "getLevel(Lnet/minecraft/world/level/ChunkPos;)I", at = @At("HEAD"))
private void cc_onChunkGetLevel(ChunkPos p_184162_, CallbackInfoReturnable<Integer> cir) {
private void cc_onChunkGetLevel(ChunkPos chunkPos, CallbackInfoReturnable<Integer> cir) {
assert !cc_isCubic;
}

Expand All @@ -50,11 +50,11 @@ private void cc_onChunkGetLevel(ChunkPos p_184162_, CallbackInfoReturnable<Integ
*/
@WrapWithCondition(method = "replacePlayerTicketsLevel", at = @At(value = "INVOKE",
target = "Lnet/minecraft/server/level/TickingTracker;addTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V"))
private <T> boolean cc_onReplacePlayerTicketsLevel(TickingTracker instance, TicketType<T> ticketType, ChunkPos pos, int a, T b) {
private <T> boolean cc_onReplacePlayerTicketsLevel(TickingTracker instance, TicketType<T> type, ChunkPos chunkPos, int ticketLevel, T key) {
if (!cc_isCubic) return true;
// if isCubic then we expect tickets to be TicketType<CloPos> not TicketType<ChunkPos>
var cloPos = CloPos.fromLong(pos.toLong());
this.addTicket((TicketType<CloPos>) ticketType, cloPos, a, cloPos);
var cloPos = CloPos.fromLong(chunkPos.toLong());
this.addTicket((TicketType<CloPos>) type, cloPos, ticketLevel, cloPos);
return false;
}

Expand All @@ -68,11 +68,11 @@ private TicketType<?> cc_replaceTicketType(Operation<TicketType<ChunkPos>> origi
}

@TransformFrom("addTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V")
public abstract <T> void addTicket(TicketType<T> p_184155_, CloPos p_184156_, int p_184157_, T p_184158_);
public abstract <T> void addTicket(TicketType<T> type, CloPos cloPos, int ticketLevel, T key);

@TransformFrom("removeTicket(Lnet/minecraft/server/level/TicketType;Lnet/minecraft/world/level/ChunkPos;ILjava/lang/Object;)V")
public abstract <T> void removeTicket(TicketType<T> p_184169_, CloPos p_184170_, int p_184171_, T p_184172_);
public abstract <T> void removeTicket(TicketType<T> type, CloPos p_184170_, int ticketLevel, T key);

@TransformFrom("getLevel(Lnet/minecraft/world/level/ChunkPos;)I")
public abstract int getLevel(CloPos p_184162_);
public abstract int getLevel(CloPos cloPos);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public abstract class MixinChunkAccess implements CloAccess {
private CloPos cc_cloPos;

@Inject(method = "<init>", at = @At("RETURN"))
private void onInit(ChunkPos chunkPos, UpgradeData p_187622_, LevelHeightAccessor p_187623_, Registry p_187624_, long p_187625_, LevelChunkSection[] p_187626_, BlendingData p_187627_,
private void onInit(ChunkPos chunkPos, UpgradeData upgradeData, LevelHeightAccessor levelHeightAccessor, Registry biomeRegistry, long inhabitedTime, LevelChunkSection[] sections,
BlendingData blendingData,
CallbackInfo ci) {
cc_cloPos = CloPos.chunk(chunkPos);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public abstract class MixinLevelCube extends MixinCubeAccess {
* Redirect to use cube section indexing instead of chunk section indexing
*/
@Dynamic @Redirect(method = "cc_dasm$getBlockState", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks/world/level/cube/LevelCube;getSectionIndex(I)I"))
private int cc_onGetBlockState_SectionIndex(LevelCube instance, int i, BlockPos pos) {
private int cc_onGetBlockState_SectionIndex(LevelCube instance, int y, BlockPos pos) {
return Coords.blockToIndex(pos);
}

Expand All @@ -24,7 +24,7 @@ private int cc_onGetBlockState_SectionIndex(LevelCube instance, int i, BlockPos
*/
@Dynamic @Redirect(method = "cc_dasm$getFluidState(III)Lnet/minecraft/world/level/material/FluidState;", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks"
+ "/world/level/cube/LevelCube;getSectionIndex(I)I"))
private int cc_onGetFluidState_SectionIndex(LevelCube instance, int i, int x, int y, int z) {
private int cc_onGetFluidState_SectionIndex(LevelCube instance, int yUnused, int x, int y, int z) {
return Coords.blockToIndex(x, y, z);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@

public interface CubicDistanceManager {
@UsedFromASM
<T> void addTicket(TicketType<T> p_140793_, CloPos p_140794_, int p_140795_, T p_140796_);
<T> void addTicket(TicketType<T> type, CloPos pos, int level, T value);

@UsedFromASM
<T> void removeTicket(TicketType<T> p_140824_, CloPos p_140825_, int p_140826_, T p_140827_);
<T> void removeTicket(TicketType<T> type, CloPos pos, int level, T value);

@UsedFromASM
<T> void addRegionTicket(TicketType<T> p_140841_, CloPos p_140842_, int p_140843_, T p_140844_);
<T> void addRegionTicket(TicketType<T> type, CloPos pos, int distance, T value);

@UsedFromASM
<T> void addRegionTicket(TicketType<T> p_140841_, CloPos p_140842_, int p_140843_, T p_140844_, boolean forceTicks);
<T> void addRegionTicket(TicketType<T> type, CloPos pos, int distance, T value, boolean forceTicks);

@UsedFromASM
<T> void removeRegionTicket(TicketType<T> p_140850_, CloPos p_140851_, int p_140852_, T p_140853_);
<T> void removeRegionTicket(TicketType<T> type, CloPos pos, int distance, T value);

@UsedFromASM
<T> void removeRegionTicket(TicketType<T> p_140850_, CloPos p_140851_, int p_140852_, T p_140853_, boolean forceTicks);
<T> void removeRegionTicket(TicketType<T> type, CloPos pos, int distance, T value, boolean forceTicks);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

public interface CubicTaskPriorityQueueSorter {
@UsedFromASM
<T> void onLevelChange(CloPos p_140616_, IntSupplier p_140617_, int p_140618_, IntConsumer p_140619_);
<T> void onLevelChange(CloPos cloPos, IntSupplier p_140617_, int p_140618_, IntConsumer p_140619_);
}
Loading

0 comments on commit c9a10d9

Please sign in to comment.