Skip to content

Commit 5ea4473

Browse files
Merge pull request #276 from IxPrumxI/fix/worldgen-mixin
Fix worldgen mixin and refactoring other mixin names
2 parents 7c7b3c9 + 2307eab commit 5ea4473

8 files changed

+23
-49
lines changed

src/main/java/wraith/fwaystones/access/ClientPlayerEntityMixinAccess.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
public interface ClientPlayerEntityMixinAccess extends PlayerAccess {
66

7-
void requestSync();
8-
ArrayList<String> getWaystonesSorted();
7+
void fabricWaystones$requestSync();
8+
ArrayList<String> fabricWaystones$getWaystonesSorted();
99

1010
}

src/main/java/wraith/fwaystones/access/StructurePiecesListAccess.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
public interface StructurePiecesListAccess {
88

9-
void setPieces(List<StructurePiece> pieces);
9+
void fabricWaystones$setPieces(List<StructurePiece> pieces);
1010

1111
}

src/main/java/wraith/fwaystones/access/StructurePoolBasedGenerator_StructurePoolGeneratorAccess.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
public interface StructurePoolBasedGenerator_StructurePoolGeneratorAccess {
44

5-
void setMaxWaystoneCount(int maxWaystoneCount);
5+
void fabricWaystones$setMaxWaystoneCount(int maxWaystoneCount);
66

77
}

src/main/java/wraith/fwaystones/mixin/ClientPlayNetworkHandlerMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ public class ClientPlayNetworkHandlerMixin {
1616
@Inject(method = "onPlayerRespawn", at = @At("RETURN"))
1717
public void onPlayerRespawn(PlayerRespawnS2CPacket packet, CallbackInfo ci) {
1818
if (MinecraftClient.getInstance().player != null) {
19-
((ClientPlayerEntityMixinAccess) MinecraftClient.getInstance().player).requestSync();
19+
((ClientPlayerEntityMixinAccess) MinecraftClient.getInstance().player).fabricWaystones$requestSync();
2020
}
2121
}
2222

2323
@Inject(method = "onGameJoin", at = @At("RETURN"))
2424
public void onPlayerSpawn(GameJoinS2CPacket packet, CallbackInfo ci) {
2525
if (MinecraftClient.getInstance().player != null) {
26-
((ClientPlayerEntityMixinAccess) MinecraftClient.getInstance().player).requestSync();
26+
((ClientPlayerEntityMixinAccess) MinecraftClient.getInstance().player).fabricWaystones$requestSync();
2727
}
2828
}
2929

src/main/java/wraith/fwaystones/mixin/ClientPlayerEntityMixin.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
package wraith.fwaystones.mixin;
22

33
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
4-
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
54
import net.minecraft.client.network.ClientPlayerEntity;
65
import org.spongepowered.asm.mixin.Mixin;
76
import wraith.fwaystones.FabricWaystones;
87
import wraith.fwaystones.access.ClientPlayerEntityMixinAccess;
98
import wraith.fwaystones.access.PlayerEntityMixinAccess;
109
import wraith.fwaystones.packets.RequestPlayerSyncPacket;
11-
import wraith.fwaystones.packets.WaystonePacketHandler;
12-
1310
import java.util.ArrayList;
1411
import java.util.Comparator;
1512
import java.util.HashSet;
@@ -18,12 +15,12 @@
1815
public class ClientPlayerEntityMixin implements ClientPlayerEntityMixinAccess {
1916

2017
@Override
21-
public void requestSync() {
18+
public void fabricWaystones$requestSync() {
2219
ClientPlayNetworking.send(new RequestPlayerSyncPacket());
2320
}
2421

2522
@Override
26-
public ArrayList<String> getWaystonesSorted() {
23+
public ArrayList<String> fabricWaystones$getWaystonesSorted() {
2724
ArrayList<String> waystones = new ArrayList<>();
2825
HashSet<String> toRemove = new HashSet<>();
2926
var discoveredWaystones = ((PlayerEntityMixinAccess) this).fabricWaystones$getDiscoveredWaystones();

src/main/java/wraith/fwaystones/mixin/StructurePiecesListMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class StructurePiecesListMixin implements StructurePiecesListAccess {
1919
private List<StructurePiece> pieces;
2020

2121
@Override
22-
public void setPieces(List<StructurePiece> pieces) {
22+
public void fabricWaystones$setPieces(List<StructurePiece> pieces) {
2323
this.pieces = pieces;
2424
}
2525

src/main/java/wraith/fwaystones/mixin/StructurePoolBasedGeneratorMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ private static void preGenerate2(NoiseConfig noiseConfig, int maxSize, boolean m
3838
private static void onInit(StructurePoolBasedGenerator.StructurePoolGenerator structurePoolGenerator) {
3939
var config = FabricWaystones.CONFIG.worldgen;
4040
int maxWaystoneCount = Utils.getRandomIntInRange(config.min_per_village(), config.max_per_village());
41-
((StructurePoolBasedGenerator_StructurePoolGeneratorAccess) (Object) structurePoolGenerator).setMaxWaystoneCount(maxWaystoneCount);
41+
((StructurePoolBasedGenerator_StructurePoolGeneratorAccess) (Object) structurePoolGenerator).fabricWaystones$setMaxWaystoneCount(maxWaystoneCount);
4242
}
4343

4444
}

src/main/java/wraith/fwaystones/mixin/StructurePoolBasedGenerator_StructurePoolGeneratorMixin.java

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
package wraith.fwaystones.mixin;
22

3+
import com.llamalad7.mixinextras.sugar.Local;
34
import net.minecraft.registry.RegistryKey;
4-
import net.minecraft.registry.entry.RegistryEntry;
55
import net.minecraft.structure.PoolStructurePiece;
66
import net.minecraft.structure.StructureLiquidSettings;
7-
import net.minecraft.structure.StructureTemplate;
87
import net.minecraft.structure.pool.SinglePoolElement;
98
import net.minecraft.structure.pool.StructurePool;
109
import net.minecraft.structure.pool.StructurePoolBasedGenerator;
1110
import net.minecraft.structure.pool.StructurePoolElement;
1211
import net.minecraft.structure.pool.alias.StructurePoolAliasLookup;
13-
import net.minecraft.util.BlockRotation;
1412
import net.minecraft.util.Identifier;
15-
import net.minecraft.util.math.BlockBox;
16-
import net.minecraft.util.math.BlockPos;
17-
import net.minecraft.util.math.Direction;
1813
import net.minecraft.util.shape.VoxelShape;
1914
import net.minecraft.world.HeightLimitView;
2015
import net.minecraft.world.gen.noise.NoiseConfig;
@@ -26,14 +21,10 @@
2621
import org.spongepowered.asm.mixin.injection.At;
2722
import org.spongepowered.asm.mixin.injection.Inject;
2823
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
29-
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
3024
import wraith.fwaystones.FabricWaystones;
3125
import wraith.fwaystones.access.StructurePoolBasedGenerator_StructurePoolGeneratorAccess;
3226
import wraith.fwaystones.util.WaystonesWorldgen;
33-
34-
import java.util.Iterator;
3527
import java.util.List;
36-
import java.util.Optional;
3728

3829
@Mixin(StructurePoolBasedGenerator.StructurePoolGenerator.class)
3930
public class StructurePoolBasedGenerator_StructurePoolGeneratorMixin implements StructurePoolBasedGenerator_StructurePoolGeneratorAccess {
@@ -57,37 +48,23 @@ private static boolean isWaystone(StructurePoolElement element) {
5748
}
5849

5950
@Unique
60-
public void setMaxWaystoneCount(int maxWaystoneCount) {
51+
public void fabricWaystones$setMaxWaystoneCount(int maxWaystoneCount) {
6152
this.maxWaystoneCount = maxWaystoneCount;
6253
}
6354

6455
@Inject(method = "generatePiece",
65-
at = @At(value = "INVOKE", target = "Ljava/util/List;addAll(Ljava/util/Collection;)Z", ordinal = 0, shift = At.Shift.AFTER, remap = false),
66-
locals = LocalCapture.CAPTURE_FAILSOFT)
67-
private void fabricwaystones_limitWaystonePieceSpawning(PoolStructurePiece piece, MutableObject<VoxelShape> pieceShape, int minY, boolean modifyBoundingBox, HeightLimitView world, NoiseConfig noiseConfig, StructurePoolAliasLookup aliasLookup, StructureLiquidSettings liquidSettings,
56+
at = @At(value = "INVOKE", target = "Ljava/util/List;addAll(Ljava/util/Collection;)Z", ordinal = 0, shift = At.Shift.AFTER, remap = false))
57+
private void fabricwaystones_limitWaystonePieceSpawning(PoolStructurePiece piece,
58+
MutableObject<VoxelShape> pieceShape,
59+
int depth,
60+
boolean modifyBoundingBox,
61+
HeightLimitView world,
62+
NoiseConfig noiseConfig,
63+
StructurePoolAliasLookup aliasLookup,
64+
StructureLiquidSettings liquidSettings,
6865
CallbackInfo ci,
69-
StructurePoolElement structurePoolElement,
70-
BlockPos blockPos,
71-
BlockRotation blockRotation,
72-
StructurePool.Projection projection,
73-
boolean bl,
74-
MutableObject<VoxelShape> mutableObject,
75-
BlockBox blockBox,
76-
int i,
77-
Iterator var17,
78-
StructureTemplate.StructureBlockInfo structureBlockInfo,
79-
Direction direction,
80-
BlockPos blockPos2,
81-
BlockPos blockPos3,
82-
int j,
83-
int k,
84-
RegistryKey<StructurePool> registryKey,
85-
Optional optional,
86-
RegistryEntry<StructurePool> registryEntry,
87-
RegistryEntry<StructurePool> registryEntry2,
88-
MutableObject mutableObject2,
89-
boolean bl2,
90-
List<StructurePoolElement> list
66+
@Local RegistryKey<StructurePool> registryKey,
67+
@Local List<StructurePoolElement> list
9168
) {
9269
if (!FabricWaystones.CONFIG.worldgen.generate_in_villages() ||
9370
maxWaystoneCount < 0 ||

0 commit comments

Comments
 (0)