Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit c2a5e23

Browse files
committed
Use an accessor mixin instead of a seperate interface.
1 parent 75a8195 commit c2a5e23

3 files changed

Lines changed: 6 additions & 39 deletions

File tree

patchwork-events-world/src/main/java/com/patchworkmc/impl/event/world/IGetWorldFromChunkGenerator.java

Lines changed: 0 additions & 26 deletions
This file was deleted.

patchwork-events-world/src/main/java/com/patchworkmc/mixin/event/world/MixinChunkGenerator.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,13 @@
2020
package com.patchworkmc.mixin.event.world;
2121

2222
import org.spongepowered.asm.mixin.Mixin;
23-
import org.spongepowered.asm.mixin.Shadow;
23+
import org.spongepowered.asm.mixin.gen.Accessor;
2424

2525
import net.minecraft.world.IWorld;
2626
import net.minecraft.world.gen.chunk.ChunkGenerator;
2727

28-
import com.patchworkmc.impl.event.world.IGetWorldFromChunkGenerator;
29-
3028
@Mixin(ChunkGenerator.class)
31-
public class MixinChunkGenerator implements IGetWorldFromChunkGenerator {
32-
@Shadow
33-
protected IWorld world;
34-
35-
public IWorld getWorld() {
36-
return world;
37-
}
29+
public interface MixinChunkGenerator {
30+
@Accessor
31+
IWorld getWorld();
3832
}

patchwork-events-world/src/main/java/com/patchworkmc/mixin/event/world/MixinSpawnHelper.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import net.minecraft.world.biome.Biome;
3434
import net.minecraft.world.gen.chunk.ChunkGenerator;
3535

36-
import com.patchworkmc.impl.event.world.IGetWorldFromChunkGenerator;
3736
import com.patchworkmc.impl.event.world.WorldEvents;
3837

3938
@Mixin(SpawnHelper.class)
@@ -44,14 +43,14 @@ public class MixinSpawnHelper {
4443

4544
@ModifyVariable(method = "method_8664", at = @At(value = "INVOKE", target = "java/util/List.isEmpty ()Z", shift = At.Shift.BEFORE))
4645
private static List<Biome.SpawnEntry> hookRandomSpawn(List<Biome.SpawnEntry> oldSpawns, ChunkGenerator<?> chunkGenerator, EntityCategory entityCategory, Random random, BlockPos blockPos) {
47-
IWorld world = ((IGetWorldFromChunkGenerator) chunkGenerator).getWorld();
46+
IWorld world = ((MixinChunkGenerator) chunkGenerator).getWorld();
4847

4948
return WorldEvents.getPotentialSpawns(world, entityCategory, blockPos, oldSpawns);
5049
}
5150

5251
@ModifyVariable(method = "method_8659", at = @At(value = "INVOKE", target = "java/util/List.isEmpty ()Z", shift = At.Shift.BEFORE))
5352
private static List<Biome.SpawnEntry> hookCanSpawn(List<Biome.SpawnEntry> oldSpawns, ChunkGenerator<?> chunkGenerator, EntityCategory entityCategory, Biome.SpawnEntry spawnEntry, BlockPos blockPos) {
54-
IWorld world = ((IGetWorldFromChunkGenerator) chunkGenerator).getWorld();
53+
IWorld world = ((MixinChunkGenerator) chunkGenerator).getWorld();
5554

5655
return WorldEvents.getPotentialSpawns(world, entityCategory, blockPos, oldSpawns);
5756
}

0 commit comments

Comments
 (0)