Skip to content

Commit 35fcf31

Browse files
committed
@Local fixes and other mixin fixes
1 parent 2572196 commit 35fcf31

File tree

11 files changed

+18
-18
lines changed

11 files changed

+18
-18
lines changed

common/src/main/java/com/railwayteam/railways/mixin/MixinCarriageContraptionEntity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ private void setupBufferDistanceData(CallbackInfo ci) {
208208

209209
@Inject(method = "control", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/trains/entity/Train;getCurrentStation()Lcom/simibubi/create/content/trains/station/GlobalStation;"))
210210
private void noBufferOverrun(BlockPos controlsLocalPos, Collection<Integer> heldControls, Player player,
211-
CallbackInfoReturnable<Boolean> cir, @Local(name="targetSpeed") LocalIntRef targetSpeed) {
211+
CallbackInfoReturnable<Boolean> cir, @Local(ordinal = 0) LocalIntRef targetSpeed) {
212212
if (((IBufferBlockedTrain) carriage.train).railways$isControlBlocked() && ((IBufferBlockedTrain) carriage.train).railways$getBlockedSign() == Mth.sign(targetSpeed.get())) {
213213
targetSpeed.set(0);
214214
}

common/src/main/java/com/railwayteam/railways/mixin/MixinContraption.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
@Mixin(Contraption.class)
1717
public class MixinContraption {
1818
@Inject(method = "removeBlocksFromWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;removeBlockEntity(Lnet/minecraft/core/BlockPos;)V"))
19-
private void applyPreTransformCallback(Level world, BlockPos offset, CallbackInfo ci, @Local(name="add") BlockPos add) {
19+
private void applyPreTransformCallback(Level world, BlockPos offset, CallbackInfo ci, @Local(ordinal = 1) BlockPos add) {
2020
BlockEntity be = world.getBlockEntity(add);
2121
if (be instanceof IPreAssembleCallback preTransformCallback)
2222
preTransformCallback.railways$preAssemble();

common/src/main/java/com/railwayteam/railways/mixin/MixinNavigation.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ private void storeBufferSlowdown(MutableObject<Pair<UUID, Boolean>> trackingCros
384384

385385
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/trains/entity/Train;burnFuel()V"))
386386
private void applyBufferSlowdown(Level level, CallbackInfo ci,
387-
@Local(name = "targetDistance") LocalDoubleRef targetDistance) {
387+
@Local(ordinal = 5) LocalDoubleRef targetDistance) {
388388
if (railways$bufferDistance.get() < targetDistance.get())
389389
targetDistance.set(railways$bufferDistance.get());
390390
// reset buffer distance for next time

common/src/main/java/com/railwayteam/railways/mixin/MixinScheduleRuntime.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.railwayteam.railways.mixin;
22

33
import com.llamalad7.mixinextras.sugar.Local;
4-
import com.railwayteam.railways.Railways;
54
import com.railwayteam.railways.content.schedule.WaypointDestinationInstruction;
65
import com.railwayteam.railways.mixin_interfaces.ICustomExecutableInstruction;
76
import com.simibubi.create.content.trains.entity.Train;
@@ -46,7 +45,7 @@ private void startCustomInstruction(CallbackInfoReturnable<GlobalStation> cir) {
4645

4746
@Inject(method = "tickConditions", at = @At("HEAD"), cancellable = true)
4847
private void tickWhenNoConditions(Level level, CallbackInfo ci) {
49-
if (schedule.entries.get(currentEntry).conditions.size() == 0) {
48+
if (schedule.entries.get(currentEntry).conditions.isEmpty()) {
5049
state = ScheduleRuntime.State.PRE_TRANSIT;
5150
currentEntry++;
5251
ci.cancel();
@@ -56,16 +55,15 @@ private void tickWhenNoConditions(Level level, CallbackInfo ci) {
5655
@Inject(method = "tick", at = @At(value = "FIELD", target = "Lcom/simibubi/create/content/trains/schedule/ScheduleRuntime;completed:Z", opcode = Opcodes.PUTFIELD, shift = At.Shift.AFTER))
5756
private void discardAutoSchedule(Level level, CallbackInfo ci) {
5857
if (isAutoSchedule) {
59-
Railways.LOGGER.info("[DISCARD_SCHEDULE] on train {} called in MixinScheduleRuntime#discardAutoSchedule because a non-looping auto schedule was completed", this.train.name.getString());
6058
discardSchedule();
6159
}
6260
}
6361

6462
// waypoint instructions have no conditions, and so are handled as 'invalid' by the vanilla code (https://github.com/Layers-of-Railways/Railway/issues/329)
6563
@Inject(method = "estimateStayDuration",
66-
at = @At(value = "INVOKE_ASSIGN", target = "Ljava/util/List;get(I)Ljava/lang/Object;", shift = At.Shift.BY, by=2),
64+
at = @At(value = "INVOKE_ASSIGN", target = "Ljava/util/List;get(I)Ljava/lang/Object;", shift = At.Shift.BY, by = 2),
6765
cancellable = true)
68-
private void waypointsAreValid(int index, CallbackInfoReturnable<Integer> cir, @Local(name = "scheduleEntry") ScheduleEntry scheduleEntry) {
66+
private void waypointsAreValid(int index, CallbackInfoReturnable<Integer> cir, @Local ScheduleEntry scheduleEntry) {
6967
if (scheduleEntry.instruction instanceof WaypointDestinationInstruction)
7068
cir.setReturnValue(0);
7169
}

common/src/main/java/com/railwayteam/railways/mixin/MixinStationBlockEntity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private Train returnOverridenTrain(GlobalStation instance) {
113113
}
114114

115115
@Inject(method = "assemble", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;", ordinal = 0), require = 0)
116-
private void allowAssemblingWithoutControls(UUID playerUUID, CallbackInfo ci, @Local(name="typeOfFirstBogey") AbstractBogeyBlock<?> typeOfFirstBogey, @Local(name="atLeastOneForwardControls") LocalBooleanRef atLeastOneForwardControls) {
116+
private void allowAssemblingWithoutControls(UUID playerUUID, CallbackInfo ci, @Local AbstractBogeyBlock<?> typeOfFirstBogey, @Local(ordinal = 0) LocalBooleanRef atLeastOneForwardControls) {
117117
if (typeOfFirstBogey instanceof HandcarBlock) {
118118
atLeastOneForwardControls.set(true);
119119
}

common/src/main/java/com/railwayteam/railways/mixin/MixinTrackPlacement.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ else if (TrackMaterial.fromItem(stack.getItem()).trackType == CRTrackMaterials.C
4949
private static void placeGenericCrossing0(Level level, TrackPlacement.PlacementInfo info, BlockState state1,
5050
BlockState state2, BlockPos targetPos1, BlockPos targetPos2, boolean simulate,
5151
CallbackInfoReturnable<TrackPlacement.PlacementInfo> cir,
52-
@Share("oldToPlace") LocalRef<BlockState> oldToPlace, @Local(name="toPlace") BlockState toPlace) {
52+
@Share("oldToPlace") LocalRef<BlockState> oldToPlace, @Local(ordinal = 4) BlockState toPlace) {
5353
oldToPlace.set(toPlace);
5454
}
5555

5656
@Inject(method = "placeTracks", at = @At(value = "INVOKE_ASSIGN", target = "Lcom/simibubi/create/content/trains/track/ITrackBlock;overlay(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/level/block/state/BlockState;", shift = At.Shift.AFTER))
5757
private static void placeGenericCrossing(Level level, TrackPlacement.PlacementInfo info, BlockState state1,
5858
BlockState state2, BlockPos targetPos1, BlockPos targetPos2, boolean simulate,
5959
CallbackInfoReturnable<TrackPlacement.PlacementInfo> cir,
60-
@Local(name="stateAtPos") BlockState stateAtPos,
61-
@Local(name="toPlace") LocalRef<BlockState> toPlace,
60+
@Local(ordinal = 3) BlockState stateAtPos,
61+
@Local(ordinal = 4) LocalRef<BlockState> toPlace,
6262
@Share("oldToPlace") LocalRef<BlockState> oldToPlace,
6363
@Share("crossingData") LocalRef<@Nullable GenericCrossingData> crossingData) {
6464
crossingData.set(null);
@@ -83,7 +83,7 @@ private static void placeGenericCrossing(Level level, TrackPlacement.PlacementIn
8383
private static void maybePlaceCrossing(Level level, TrackPlacement.PlacementInfo info, BlockState state1,
8484
BlockState state2, BlockPos targetPos1, BlockPos targetPos2, boolean simulate,
8585
CallbackInfoReturnable<TrackPlacement.PlacementInfo> cir,
86-
@Local(name="offsetPos") BlockPos offsetPos,
86+
@Local(ordinal = 3) BlockPos offsetPos,
8787
@Share("crossingData") LocalRef<@Nullable GenericCrossingData> crossingDataRef) {
8888
@Nullable GenericCrossingData crossingData = crossingDataRef.get();
8989
if (crossingData != null && level.getBlockEntity(offsetPos) instanceof GenericCrossingBlockEntity genericCrossingBE) {

common/src/main/java/com/railwayteam/railways/mixin/MixinTrain.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,9 @@ private static void readOccupiedCouplers(CompoundTag tag, Map<UUID, TrackGraph>
236236
}
237237

238238
@Inject(method = "collideWithOtherTrains", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/trains/entity/Train;crash()V", ordinal = 0), cancellable = true)
239-
private void railways$handcarCollision(Level level, Carriage carriage, CallbackInfo ci, @Local Train train, @Local(name = "v", ordinal = 0) Vec3 v) {
239+
private void railways$handcarCollision(Level level, Carriage carriage, CallbackInfo ci, @Local(ordinal = 1) Train train, @Local Pair<Train, Vec3> collision) {
240+
Vec3 v = collision.getSecond();
241+
240242
// Self Train / Train that collided with the other one
241243
if (((IHandcarTrain) this).railways$isHandcar()) {
242244
if (!invalid) {

common/src/main/java/com/railwayteam/railways/mixin/client/MixinStationRenderer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class MixinStationRenderer {
2323
@Inject(method = "renderSafe(Lcom/simibubi/create/content/trains/station/StationBlockEntity;FLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;II)V", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/render/CachedBufferer;partial(Lcom/jozufozu/flywheel/core/PartialModel;Lnet/minecraft/world/level/block/state/BlockState;)Lcom/simibubi/create/foundation/render/SuperByteBuffer;"))
2424
private void shiftAssemblyOverlayOnEncasedTracks(
2525
StationBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay,
26-
CallbackInfo ci, @Local(name = "currentPos") MutableBlockPos currentPos, @Local(name = "trackState") BlockState trackState) {
26+
CallbackInfo ci, @Local BlockState trackState, @Local MutableBlockPos currentPos) {
2727
ms.pushPose();
2828

2929
if (trackState.getBlock() instanceof TrackBlock trackBlock

common/src/main/java/com/railwayteam/railways/mixin/compat/sodium/MixinBlockOcclusionCache.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@Mixin(BlockOcclusionCache.class)
1919
public class MixinBlockOcclusionCache {
2020
@Inject(method = "shouldDrawSide", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;skipRendering(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/Direction;)Z"), cancellable = true)
21-
private void forceRendering(BlockState selfState, BlockGetter view, BlockPos pos, Direction facing, CallbackInfoReturnable<Boolean> cir, @Local(name = "adjState") BlockState adjState) {
21+
private void forceRendering(BlockState selfState, BlockGetter view, BlockPos pos, Direction facing, CallbackInfoReturnable<Boolean> cir, @Local(ordinal = 1) BlockState adjState) {
2222
if (selfState.getBlock() instanceof IForceRenderingSodium forceRendering) {
2323
if (forceRendering.forceRenderingSodium(selfState, adjState, facing))
2424
cir.setReturnValue(true);

fabric/src/main/java/com/railwayteam/railways/fabric/mixin/GoggleOverlayRendererMixin.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class GoggleOverlayRendererMixin {
2020
at = @At(value = "INVOKE", target = "Lcom/tterrag/registrate/util/entry/ItemEntry;asStack()Lnet/minecraft/world/item/ItemStack;")
2121
)
2222
private static ItemStack changeDisplayItem(ItemEntry<GogglesItem> instance, Operation<ItemStack> original,
23-
@Local BlockEntity be, @Local(name = "wearingGoggles") boolean wearingGoggles) {
23+
@Local BlockEntity be, @Local(ordinal = 0) boolean wearingGoggles) {
2424
if (be instanceof IHaveCustomGoggleIcon gte && wearingGoggles) {
2525
return gte.railways$setGoggleIcon(Minecraft.getInstance().player.isShiftKeyDown());
2626
}

forge/src/main/java/com/railwayteam/railways/forge/mixin/GoggleOverlayRendererMixin.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class GoggleOverlayRendererMixin {
2020
at = @At(value = "INVOKE", target = "Lcom/tterrag/registrate/util/entry/ItemEntry;asStack()Lnet/minecraft/world/item/ItemStack;")
2121
)
2222
private static ItemStack changeDisplayItem(ItemEntry<GogglesItem> instance, Operation<ItemStack> original,
23-
@Local BlockEntity be, @Local(name = "wearingGoggles") boolean wearingGoggles) {
23+
@Local BlockEntity be, @Local boolean wearingGoggles) {
2424
if (be instanceof IHaveCustomGoggleIcon gte && wearingGoggles) {
2525
return gte.railways$setGoggleIcon(Minecraft.getInstance().player.isShiftKeyDown());
2626
}

0 commit comments

Comments
 (0)