Skip to content

Commit 9b81b9b

Browse files
authored
Merge branch 'FeudalKings' into FeudalKings-EntityDeath
2 parents 83b1da4 + 62028ac commit 9b81b9b

File tree

12 files changed

+38
-48
lines changed

12 files changed

+38
-48
lines changed

arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/level/levelgen/StructurePieceBridge.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import org.bukkit.craftbukkit.v.block.CraftBlockEntityState;
99

1010
public interface StructurePieceBridge {
11-
void bridge$placeCraftBlockEntity(ServerLevelAccessor worldAccess, BlockPos position, CraftBlockEntityState<?> craftBlockEntityState, int i);
12-
void bridge$placeCraftSpawner(ServerLevelAccessor worldAccess, BlockPos position, org.bukkit.entity.EntityType entityType, int i);
11+
boolean bridge$placeCraftBlockEntity(ServerLevelAccessor worldAccess, BlockPos position, CraftBlockEntityState<?> craftBlockEntityState, int i);
12+
boolean bridge$placeCraftSpawner(ServerLevelAccessor worldAccess, BlockPos position, org.bukkit.entity.EntityType entityType, int i);
1313
void bridge$setCraftLootTable(ServerLevelAccessor worldAccess, BlockPos position, RandomSource randomSource, ResourceKey<LootTable> loottableKey);
1414
}

arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/ServerPlayerMixin.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla
162162
@Shadow public abstract void setRespawnPosition(ResourceKey<Level> arg, @org.jetbrains.annotations.Nullable BlockPos arg2, float f, boolean bl, boolean bl2);
163163
// @formatter:on
164164

165+
// FIXME: InitAuther97: Current management of TransferCookieConnection is brittle.
165166
public CraftPlayer.TransferCookieConnection transferCookieConnection;
166167
public String displayName;
167168
public Component listName;
@@ -951,6 +952,8 @@ public void reset() {
951952
@Inject(method = "restoreFrom", at = @At("HEAD"))
952953
private void arclight$forwardHandle(ServerPlayer serverPlayer, boolean bl, CallbackInfo ci) {
953954
((InternalEntityBridge) serverPlayer).internal$getBukkitEntity().setHandle((Entity) (Object) this);
955+
956+
this.transferCookieConnection = ((ServerPlayerMixin)(Object) serverPlayer).transferCookieConnection;
954957
this.bridge$setBukkitEntity(((InternalEntityBridge) serverPlayer).internal$getBukkitEntity());
955958
}
956959
}

arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/levelgen/structure/StructurePieceMixin.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,15 @@ protected void setCraftLootTable(ServerLevelAccessor worldAccess, BlockPos posit
116116
}
117117

118118
@Override
119-
public void bridge$placeCraftBlockEntity(ServerLevelAccessor worldAccess, BlockPos position, CraftBlockEntityState<?> craftBlockEntityState, int i) {
120-
placeCraftBlockEntity(worldAccess, position, craftBlockEntityState, i);
119+
public boolean bridge$placeCraftBlockEntity(ServerLevelAccessor worldAccess, BlockPos position, CraftBlockEntityState<?> craftBlockEntityState, int i) {
120+
return placeCraftBlockEntity(worldAccess, position, craftBlockEntityState, i);
121121
}
122122

123123
@Override
124-
public void bridge$placeCraftSpawner(ServerLevelAccessor worldAccess, BlockPos position, EntityType entityType, int i) {
125-
placeCraftSpawner(worldAccess, position, entityType, i);
124+
public boolean bridge$placeCraftSpawner(ServerLevelAccessor worldAccess, BlockPos position, EntityType entityType, int i) {
125+
var spawner = (CraftCreatureSpawner) CraftBlockStates.getBlockState(worldAccess, position, Blocks.SPAWNER.defaultBlockState(), null);
126+
spawner.setSpawnedType(entityType);
127+
return placeCraftBlockEntity(worldAccess, position, spawner, i);
126128
}
127129

128130
@Override

arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/levelgen/structure/structures/IglooPiecesPieceMixin.java

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

33
import io.izzel.arclight.common.bridge.core.world.level.levelgen.StructurePieceBridge;
44
import net.minecraft.core.BlockPos;
5+
import net.minecraft.resources.ResourceKey;
56
import net.minecraft.util.RandomSource;
67
import net.minecraft.world.level.ServerLevelAccessor;
7-
import net.minecraft.world.level.levelgen.structure.BoundingBox;
8+
import net.minecraft.world.level.block.entity.ChestBlockEntity;
89
import net.minecraft.world.level.levelgen.structure.structures.IglooPieces;
9-
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
10+
import net.minecraft.world.level.storage.loot.LootTable;
1011
import org.spongepowered.asm.mixin.Mixin;
1112
import org.spongepowered.asm.mixin.injection.At;
12-
import org.spongepowered.asm.mixin.injection.Inject;
13-
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
13+
import org.spongepowered.asm.mixin.injection.Redirect;
1414

1515
@Mixin(IglooPieces.IglooPiece.class)
1616
public class IglooPiecesPieceMixin {
17-
@Inject(method = "handleDataMarker", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/ServerLevelAccessor;getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;"))
18-
private void arclight$customSetLootTable(String string, BlockPos pos, ServerLevelAccessor level, RandomSource random, BoundingBox aabb, CallbackInfo ci) {
19-
((StructurePieceBridge) this).bridge$setCraftLootTable(level, pos.below(), random, BuiltInLootTables.IGLOO_CHEST);
17+
@Redirect(method = "handleDataMarker", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/entity/ChestBlockEntity;setLootTable(Lnet/minecraft/resources/ResourceKey;J)V"))
18+
private void arclight$customSetLootTable(ChestBlockEntity instance, ResourceKey<LootTable> resourceKey, long l, String string, BlockPos pos, ServerLevelAccessor level, RandomSource random) {
19+
((StructurePieceBridge) this).bridge$setCraftLootTable(level, pos.below(), random, resourceKey);
2020
}
2121
}

arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/levelgen/structure/structures/MineshaftPiecesPieceMixin.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,21 @@
22

33
import io.izzel.arclight.common.bridge.core.world.level.levelgen.StructurePieceBridge;
44
import net.minecraft.core.BlockPos;
5-
import net.minecraft.util.RandomSource;
6-
import net.minecraft.world.level.ChunkPos;
7-
import net.minecraft.world.level.StructureManager;
85
import net.minecraft.world.level.WorldGenLevel;
96
import net.minecraft.world.level.block.entity.BlockEntity;
107
import net.minecraft.world.level.block.state.BlockState;
11-
import net.minecraft.world.level.chunk.ChunkGenerator;
12-
import net.minecraft.world.level.levelgen.structure.BoundingBox;
138
import net.minecraft.world.level.levelgen.structure.structures.MineshaftPieces;
149
import org.bukkit.entity.EntityType;
15-
import org.objectweb.asm.Opcodes;
1610
import org.spongepowered.asm.mixin.Mixin;
1711
import org.spongepowered.asm.mixin.injection.At;
18-
import org.spongepowered.asm.mixin.injection.Inject;
1912
import org.spongepowered.asm.mixin.injection.Redirect;
20-
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
2113

2214
@Mixin(MineshaftPieces.MineShaftCorridor.class)
2315
public class MineshaftPiecesPieceMixin {
2416

25-
@Inject(method = "postProcess", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraft/world/level/levelgen/structure/structures/MineshaftPieces$MineShaftCorridor;hasPlacedSpider:Z"))
26-
private void arclight$customPlaceSpawner(WorldGenLevel level, StructureManager manager, ChunkGenerator generator, RandomSource random, BoundingBox aabb, ChunkPos chunkIn, BlockPos blockIn, CallbackInfo ci) {
27-
((StructurePieceBridge) this).bridge$placeCraftSpawner(level, blockIn, EntityType.CAVE_SPIDER, 2);
28-
}
29-
3017
@Redirect(method = "postProcess", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/level/WorldGenLevel;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z"))
3118
private boolean arclight$skipSetBlock(WorldGenLevel instance, BlockPos blockPos, BlockState blockState, int i) {
32-
return false;
19+
return ((StructurePieceBridge) this).bridge$placeCraftSpawner(instance, blockPos, EntityType.CAVE_SPIDER, 2);
3320
}
3421

3522
@Redirect(method = "postProcess", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/level/WorldGenLevel;getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;"))

arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/levelgen/structure/structures/NetherFortressPiecesPieceMixin.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,10 @@
2121

2222
@Mixin(NetherFortressPieces.MonsterThrone.class)
2323
public class NetherFortressPiecesPieceMixin {
24-
@Inject(method = "postProcess", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces$MonsterThrone;hasPlacedSpawner:Z"))
25-
private void arclight$customPlaceSpawner(WorldGenLevel level, StructureManager manager, ChunkGenerator generator, RandomSource random, BoundingBox aabb, ChunkPos chunkIn, BlockPos blockIn, CallbackInfo ci) {
26-
((StructurePieceBridge) this).bridge$placeCraftSpawner(level, blockIn, EntityType.CAVE_SPIDER, 2);
27-
}
2824

2925
@Redirect(method = "postProcess", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/level/WorldGenLevel;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z"))
3026
private boolean arclight$skipSetBlock(WorldGenLevel instance, BlockPos blockPos, BlockState blockState, int i) {
31-
return false;
27+
return ((StructurePieceBridge) this).bridge$placeCraftSpawner(instance, blockPos, EntityType.BLAZE, 2);
3228
}
3329

3430
@Redirect(method = "postProcess", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/level/WorldGenLevel;getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;"))

arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/levelgen/structure/structures/StrongholdPiecesPortalRoomMixin.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,9 @@
2222
@Mixin(StrongholdPieces.PortalRoom.class)
2323
public class StrongholdPiecesPortalRoomMixin {
2424

25-
@Inject(method = "postProcess", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraft/world/level/levelgen/structure/structures/StrongholdPieces$PortalRoom;hasPlacedSpawner:Z"))
26-
private void arclight$customPlaceSpawner(WorldGenLevel level, StructureManager manager, ChunkGenerator generator, RandomSource random, BoundingBox aabb, ChunkPos chunkIn, BlockPos blockIn, CallbackInfo ci) {
27-
((StructurePieceBridge) this).bridge$placeCraftSpawner(level, blockIn, EntityType.SILVERFISH, 2);
28-
}
29-
3025
@Redirect(method = "postProcess", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/level/WorldGenLevel;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z"))
3126
private boolean arclight$skipSetBlock(WorldGenLevel instance, BlockPos blockPos, BlockState blockState, int i) {
32-
return false;
27+
return ((StructurePieceBridge) this).bridge$placeCraftSpawner(instance, blockPos, EntityType.SILVERFISH, 2);
3328
}
3429

3530
@Redirect(method = "postProcess", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/WorldGenLevel;getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;"))
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
package io.izzel.arclight.common.mixin.core.world.level.levelgen.structure.structures;
22

33
import io.izzel.arclight.common.bridge.core.world.server.ServerWorldBridge;
4-
import net.minecraft.world.entity.Entity;
4+
import net.minecraft.core.BlockPos;
5+
import net.minecraft.util.RandomSource;
6+
import net.minecraft.world.level.ChunkPos;
57
import net.minecraft.world.level.ServerLevelAccessor;
8+
import net.minecraft.world.level.StructureManager;
69
import net.minecraft.world.level.WorldGenLevel;
10+
import net.minecraft.world.level.chunk.ChunkGenerator;
11+
import net.minecraft.world.level.levelgen.structure.BoundingBox;
712
import net.minecraft.world.level.levelgen.structure.structures.SwampHutPiece;
813
import org.bukkit.event.entity.CreatureSpawnEvent;
914
import org.spongepowered.asm.mixin.Mixin;
1015
import org.spongepowered.asm.mixin.injection.At;
11-
import org.spongepowered.asm.mixin.injection.Redirect;
16+
import org.spongepowered.asm.mixin.injection.Inject;
17+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1218

1319
@Mixin(SwampHutPiece.class)
1420
public class SwampHutPieceMixin {
1521

16-
@Redirect(method = "postProcess", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/WorldGenLevel;addFreshEntityWithPassengers(Lnet/minecraft/world/entity/Entity;)V"))
17-
private void arclight$addSpawnReasonForWitch(WorldGenLevel instance, Entity entity) {
18-
((ServerWorldBridge) instance).bridge$addAllEntities(entity, CreatureSpawnEvent.SpawnReason.CHUNK_GEN);
22+
@Inject(method = "postProcess", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/WorldGenLevel;addFreshEntityWithPassengers(Lnet/minecraft/world/entity/Entity;)V"))
23+
private void arclight$addSpawnReasonForWitch(WorldGenLevel worldGenLevel, StructureManager structureManager, ChunkGenerator chunkGenerator, RandomSource randomSource, BoundingBox boundingBox, ChunkPos chunkPos, BlockPos blockPos, CallbackInfo ci) {
24+
((ServerWorldBridge) worldGenLevel).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.CHUNK_GEN);
1925
}
2026

21-
@Redirect(method = "spawnCat", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/ServerLevelAccessor;addFreshEntityWithPassengers(Lnet/minecraft/world/entity/Entity;)V"))
22-
private void arclight$addSpawnReasonForCat(ServerLevelAccessor instance, Entity entity) {
23-
((ServerWorldBridge) instance).bridge$addAllEntities(entity, CreatureSpawnEvent.SpawnReason.CHUNK_GEN);
27+
@Inject(method = "spawnCat", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/ServerLevelAccessor;addFreshEntityWithPassengers(Lnet/minecraft/world/entity/Entity;)V"))
28+
private void arclight$addSpawnReasonForCat(ServerLevelAccessor serverLevelAccessor, BoundingBox boundingBox, CallbackInfo ci) {
29+
((ServerWorldBridge) serverLevelAccessor).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.CHUNK_GEN);
2430
}
2531
}

arclight-common/src/main/resources/mixins.arclight.core.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@
549549
"world.level.levelgen.structure.structures.DesertPyramidStructureMixin",
550550
"world.level.levelgen.structure.structures.EndCityPiecesPieceMixin",
551551
"world.level.levelgen.structure.structures.IglooPiecesPieceMixin",
552+
"world.level.levelgen.structure.structures.MineshaftPiecesPieceMixin",
552553
"world.level.levelgen.structure.structures.NetherFortressPiecesPieceMixin",
553554
"world.level.levelgen.structure.structures.OceanRuinPiecesPieceMixin",
554555
"world.level.levelgen.structure.structures.ShipwreckPiecesPieceMixin",

arclight-fabric/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ dependencies {
3232
implementation 'net.md-5:bungeecord-chat:1.20-R0.2'
3333

3434
implementation("io.izzel.arclight:mixin-tools:$mixinToolsVersion") { transitive = false }
35+
annotationProcessor("io.izzel.arclight:mixin-tools:$mixinToolsVersion") { transitive = false }
3536

3637
shadowCommon("org.spigotmc:spigot-api:$minecraftVersion-R0.1-SNAPSHOT") { transitive = false }
3738
shadowCommon "io.izzel.arclight.generated:spigot:$minecraftVersion:deobf"

0 commit comments

Comments
 (0)