TrialSpawner compile fixes

This commit is contained in:
Bjarne Koll
2025-06-01 14:39:40 +02:00
parent df96454561
commit 5933bd5bf3
5 changed files with 94 additions and 55 deletions

View File

@@ -140,12 +140,10 @@ public net.minecraft.world.effect.MobEffect attributeModifiers
public net.minecraft.world.effect.MobEffect$AttributeTemplate
public net.minecraft.world.effect.MobEffectInstance hiddenEffect
public net.minecraft.world.entity.AreaEffectCloud durationOnUse
public net.minecraft.world.entity.AreaEffectCloud ownerUUID
public net.minecraft.world.entity.AreaEffectCloud potionContents
public net.minecraft.world.entity.AreaEffectCloud radiusOnUse
public net.minecraft.world.entity.AreaEffectCloud radiusPerTick
public net.minecraft.world.entity.AreaEffectCloud reapplicationDelay
public net.minecraft.world.entity.AreaEffectCloud updateColor()V
public net.minecraft.world.entity.AreaEffectCloud waitTime
public net.minecraft.world.entity.Display DATA_POS_ROT_INTERPOLATION_DURATION_ID
public net.minecraft.world.entity.Display createTransformation(Lnet/minecraft/network/syncher/SynchedEntityData;)Lcom/mojang/math/Transformation;
@@ -330,14 +328,8 @@ public net.minecraft.world.entity.animal.wolf.Wolf setSoundVariant(Lnet/minecraf
public net.minecraft.world.entity.animal.wolf.Wolf setVariant(Lnet/minecraft/core/Holder;)V
public net.minecraft.world.entity.boss.enderdragon.EnderDragon subEntities
public net.minecraft.world.entity.boss.wither.WitherBoss bossEvent
public net.minecraft.world.entity.decoration.ArmorStand bodyPose
public net.minecraft.world.entity.decoration.ArmorStand disabledSlots
public net.minecraft.world.entity.decoration.ArmorStand headPose
public net.minecraft.world.entity.decoration.ArmorStand isDisabled(Lnet/minecraft/world/entity/EquipmentSlot;)Z
public net.minecraft.world.entity.decoration.ArmorStand leftArmPose
public net.minecraft.world.entity.decoration.ArmorStand leftLegPose
public net.minecraft.world.entity.decoration.ArmorStand rightArmPose
public net.minecraft.world.entity.decoration.ArmorStand rightLegPose
public net.minecraft.world.entity.decoration.ArmorStand setMarker(Z)V
public net.minecraft.world.entity.decoration.ArmorStand setSmall(Z)V
public net.minecraft.world.entity.decoration.HangingEntity setDirection(Lnet/minecraft/core/Direction;)V
@@ -364,8 +356,6 @@ public net.minecraft.world.entity.monster.Creeper explodeCreeper()V
public net.minecraft.world.entity.monster.Creeper explosionRadius
public net.minecraft.world.entity.monster.Creeper maxSwell
public net.minecraft.world.entity.monster.Creeper swell
public net.minecraft.world.entity.monster.Drowned groundNavigation
public net.minecraft.world.entity.monster.Drowned waterNavigation
public net.minecraft.world.entity.monster.EnderMan teleport()Z
public net.minecraft.world.entity.monster.EnderMan teleportTowards(Lnet/minecraft/world/entity/Entity;)Z
public net.minecraft.world.entity.monster.Endermite life
@@ -449,9 +439,6 @@ public net.minecraft.world.entity.projectile.Arrow updateColor()V
public net.minecraft.world.entity.projectile.EvokerFangs warmupDelayTicks
public net.minecraft.world.entity.projectile.EyeOfEnder life
public net.minecraft.world.entity.projectile.EyeOfEnder surviveAfterDeath
public net.minecraft.world.entity.projectile.EyeOfEnder tx
public net.minecraft.world.entity.projectile.EyeOfEnder ty
public net.minecraft.world.entity.projectile.EyeOfEnder tz
public net.minecraft.world.entity.projectile.FireworkRocketEntity DATA_ATTACHED_TO_TARGET
public net.minecraft.world.entity.projectile.FireworkRocketEntity DATA_ID_FIREWORKS_ITEM
public net.minecraft.world.entity.projectile.FireworkRocketEntity DATA_SHOT_AT_ANGLE
@@ -471,11 +458,9 @@ public net.minecraft.world.entity.projectile.FishingHook timeUntilHooked
public net.minecraft.world.entity.projectile.FishingHook timeUntilLured
public net.minecraft.world.entity.projectile.FishingHook$FishHookState
public net.minecraft.world.entity.projectile.LargeFireball explosionPower
public net.minecraft.world.entity.projectile.Projectile cachedOwner
public net.minecraft.world.entity.projectile.Projectile hasBeenShot
public net.minecraft.world.entity.projectile.Projectile leftOwner
public net.minecraft.world.entity.projectile.Projectile owner
public net.minecraft.world.entity.projectile.Projectile ownerUUID
public net.minecraft.world.entity.projectile.ShulkerBullet currentMoveDirection
public net.minecraft.world.entity.projectile.ShulkerBullet flightSteps
public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaX
@@ -616,7 +601,6 @@ public net.minecraft.world.level.block.entity.BedBlockEntity color
public net.minecraft.world.level.block.entity.BeehiveBlockEntity savedFlowerPos
public net.minecraft.world.level.block.entity.BellBlockEntity resonating
public net.minecraft.world.level.block.entity.BellBlockEntity resonationTicks
public net.minecraft.world.level.block.entity.BlockEntity saveId(Lnet/minecraft/nbt/CompoundTag;)V
public net.minecraft.world.level.block.entity.BlockEntityType validBlocks
public net.minecraft.world.level.block.entity.BrewingStandBlockEntity brewTime
public net.minecraft.world.level.block.entity.BrewingStandBlockEntity fuel
@@ -629,7 +613,6 @@ public net.minecraft.world.level.block.entity.ChestBlockEntity openersCounter
public net.minecraft.world.level.block.entity.ChestBlockEntity playSound(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/sounds/SoundEvent;)V
public net.minecraft.world.level.block.entity.ChiseledBookShelfBlockEntity lastInteractedSlot
public net.minecraft.world.level.block.entity.ConduitBlockEntity destroyTarget
public net.minecraft.world.level.block.entity.ConduitBlockEntity destroyTargetUUID
public net.minecraft.world.level.block.entity.ConduitBlockEntity effectBlocks
public net.minecraft.world.level.block.entity.ConduitBlockEntity getDestroyRangeAABB(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/phys/AABB;
public net.minecraft.world.level.block.entity.CrafterBlockEntity craftingTicksRemaining
@@ -665,13 +648,14 @@ public net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity age
public net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity exactTeleport
public net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity exitPortal
public net.minecraft.world.level.block.entity.TrialSpawnerBlockEntity trialSpawner
public net.minecraft.world.level.block.entity.trialspawner.TrialSpawner config
public net.minecraft.world.level.block.entity.trialspawner.TrialSpawner isOminous
public net.minecraft.world.level.block.entity.trialspawner.TrialSpawner stateAccessor
public net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerData cooldownEndsAt
public net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerData currentMobs
public net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerData detectedPlayers
public net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerData nextMobSpawnsAt
public net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerData nextSpawnData
public net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerStateData cooldownEndsAt
public net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerStateData currentMobs
public net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerStateData detectedPlayers
public net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerStateData nextMobSpawnsAt
public net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerStateData nextSpawnData
public net.minecraft.world.level.block.entity.vault.VaultBlockEntity serverData
public net.minecraft.world.level.block.entity.vault.VaultServerData getRewardedPlayers()Ljava/util/Set;
public net.minecraft.world.level.block.entity.vault.VaultServerData pauseStateUpdatingUntil(J)V
@@ -690,7 +674,6 @@ public net.minecraft.world.level.chunk.LevelChunk level
public net.minecraft.world.level.chunk.LevelChunk loaded
public net.minecraft.world.level.chunk.LevelChunkSection states
public net.minecraft.world.level.chunk.PalettedContainer registry
public net.minecraft.world.level.chunk.status.ChunkStatusTasks postLoadProtoChunk(Lnet/minecraft/server/level/ServerLevel;Ljava/util/List;)V
public net.minecraft.world.level.chunk.storage.EntityStorage entityDeserializerQueue
public net.minecraft.world.level.chunk.storage.EntityStorage level
public net.minecraft.world.level.chunk.storage.RegionFileStorage regionCache
@@ -777,10 +760,6 @@ public-f net.minecraft.world.level.LevelSettings hardcore
public-f net.minecraft.world.level.LevelSettings levelName
public-f net.minecraft.world.level.block.ChestBlock MENU_PROVIDER_COMBINER
public-f net.minecraft.world.level.block.entity.BannerBlockEntity baseColor
public-f net.minecraft.world.level.block.entity.trialspawner.TrialSpawner normalConfig
public-f net.minecraft.world.level.block.entity.trialspawner.TrialSpawner ominousConfig
public-f net.minecraft.world.level.block.entity.trialspawner.TrialSpawner requiredPlayerRange
public-f net.minecraft.world.level.block.entity.trialspawner.TrialSpawner targetCooldownLength
public-f net.minecraft.world.level.saveddata.maps.MapItemSavedData centerX
public-f net.minecraft.world.level.saveddata.maps.MapItemSavedData centerZ
public-f net.minecraft.world.level.saveddata.maps.MapItemSavedData dimension

View File

@@ -36,3 +36,39 @@
for (ItemStack itemStack : randomItems) {
DefaultDispenseItemBehavior.spawnItem(level, itemStack, 2, Direction.UP, Vec3.atBottomCenterOf(pos).relative(Direction.UP, 1.2));
}
@@ -402,6 +_,35 @@
this.requiredPlayerRange
);
}
+
+ // Paper start - trial spawner API - withers
+ public TrialSpawner.FullConfig overrideTargetCooldownLength(final int targetCooldownLength) {
+ return new TrialSpawner.FullConfig(
+ this.normal,
+ this.ominous,
+ targetCooldownLength,
+ this.requiredPlayerRange
+ );
+ }
+
+ public TrialSpawner.FullConfig overrideRequiredPlayerRange(final int requiredPlayerRange) {
+ return new TrialSpawner.FullConfig(
+ this.normal,
+ this.ominous,
+ this.targetCooldownLength,
+ requiredPlayerRange
+ );
+ }
+
+ public TrialSpawner.FullConfig overrideConfigs(final Holder<TrialSpawnerConfig> normal, final Holder<TrialSpawnerConfig> ominous) {
+ return new TrialSpawner.FullConfig(
+ normal,
+ ominous,
+ this.targetCooldownLength,
+ this.requiredPlayerRange
+ );
+ }
+ // Paper end - trial spawner API - withers
}
public interface StateAccessor {

View File

@@ -0,0 +1,19 @@
--- a/net/minecraft/world/level/storage/TagValueInput.java
+++ b/net/minecraft/world/level/storage/TagValueInput.java
@@ -37,6 +_,16 @@
this.input = input;
}
+ // Paper start - utility methods
+ public static ValueInput createGlobalDiscarding(final CompoundTag compoundTag) {
+ return create(ProblemReporter.DISCARDING, net.minecraft.server.MinecraftServer.getServer().registryAccess(), compoundTag);
+ }
+
+ public static ValueInput createDiscarding(final HolderLookup.Provider provider, final CompoundTag compoundTag) {
+ return create(ProblemReporter.DISCARDING, provider, compoundTag);
+ }
+ // Paper end - utility methods
+
public static ValueInput create(ProblemReporter problemReporter, HolderLookup.Provider lookup, CompoundTag input) {
return new TagValueInput(problemReporter, new ValueInputContextHelper(lookup, NbtOps.INSTANCE), input);
}

View File

@@ -7,7 +7,7 @@ import java.util.UUID;
import net.minecraft.core.Holder;
import net.minecraft.world.level.block.TrialSpawnerBlock;
import net.minecraft.world.level.block.entity.TrialSpawnerBlockEntity;
import net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerData;
import net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerStateData;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
@@ -23,8 +23,8 @@ public class CraftTrialSpawner extends CraftBlockEntityState<TrialSpawnerBlockEn
public CraftTrialSpawner(World world, TrialSpawnerBlockEntity blockEntity) {
super(world, blockEntity);
this.normalConfig = new CraftTrialSpawnerConfiguration(blockEntity.getTrialSpawner().getNormalConfig(), this.getSnapshot());
this.ominousConfig = new CraftTrialSpawnerConfiguration(blockEntity.getTrialSpawner().getOminousConfig(), this.getSnapshot());
this.normalConfig = new CraftTrialSpawnerConfiguration(blockEntity.getTrialSpawner().normalConfig(), this.getSnapshot());
this.ominousConfig = new CraftTrialSpawnerConfiguration(blockEntity.getTrialSpawner().ominousConfig(), this.getSnapshot());
}
protected CraftTrialSpawner(CraftTrialSpawner state, Location location) {
@@ -35,22 +35,22 @@ public class CraftTrialSpawner extends CraftBlockEntityState<TrialSpawnerBlockEn
@Override
public long getCooldownEnd() {
return this.getSnapshot().trialSpawner.getData().cooldownEndsAt;
return this.getSnapshot().trialSpawner.getStateData().cooldownEndsAt;
}
@Override
public void setCooldownEnd(long ticks) {
this.getSnapshot().trialSpawner.getData().cooldownEndsAt = ticks;
this.getSnapshot().trialSpawner.getStateData().cooldownEndsAt = ticks;
}
@Override
public long getNextSpawnAttempt() {
return this.getSnapshot().trialSpawner.getData().nextMobSpawnsAt;
return this.getSnapshot().trialSpawner.getStateData().nextMobSpawnsAt;
}
@Override
public void setNextSpawnAttempt(long ticks) {
this.getSnapshot().trialSpawner.getData().nextMobSpawnsAt = ticks;
this.getSnapshot().trialSpawner.getStateData().nextMobSpawnsAt = ticks;
}
@Override
@@ -60,17 +60,17 @@ public class CraftTrialSpawner extends CraftBlockEntityState<TrialSpawnerBlockEn
@Override
public void setCooldownLength(int ticks) {
this.getSnapshot().trialSpawner.targetCooldownLength = ticks;
this.getSnapshot().trialSpawner.config = this.getSnapshot().trialSpawner.config.overrideTargetCooldownLength(ticks);
}
@Override
public int getRequiredPlayerRange() {
return this.getSnapshot().trialSpawner.getRequiredPlayerRange();
return this.getSnapshot().trialSpawner.getRequiredPlayerRange();
}
@Override
public void setRequiredPlayerRange(int requiredPlayerRange) {
this.getSnapshot().trialSpawner.requiredPlayerRange = requiredPlayerRange;
this.getSnapshot().trialSpawner.config = this.getSnapshot().trialSpawner.config.overrideRequiredPlayerRange(requiredPlayerRange);
}
@Override
@@ -160,24 +160,26 @@ public class CraftTrialSpawner extends CraftBlockEntityState<TrialSpawnerBlockEn
@Override
public TrialSpawnerConfiguration getNormalConfiguration() {
return this.normalConfig;
return this.normalConfig;
}
@Override
public TrialSpawnerConfiguration getOminousConfiguration() {
return this.ominousConfig;
return this.ominousConfig;
}
@Override
protected void applyTo(TrialSpawnerBlockEntity blockEntity) {
super.applyTo(blockEntity);
blockEntity.trialSpawner.normalConfig = Holder.direct(this.normalConfig.toMinecraft());
blockEntity.trialSpawner.ominousConfig = Holder.direct(this.ominousConfig.toMinecraft());
blockEntity.trialSpawner.config = blockEntity.trialSpawner.config.overrideConfigs(
Holder.direct(this.normalConfig.toMinecraft()),
Holder.direct(this.ominousConfig.toMinecraft())
);
}
private TrialSpawnerData getTrialData() {
return this.getSnapshot().getTrialSpawner().getData();
private TrialSpawnerStateData getTrialData() {
return this.getSnapshot().getTrialSpawner().getStateData();
}
@Override

View File

@@ -16,7 +16,8 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.SpawnData;
import net.minecraft.world.level.block.entity.TrialSpawnerBlockEntity;
import net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerConfig;
import net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerData;
import net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerStateData;
import net.minecraft.world.level.storage.TagValueInput;
import org.bukkit.block.spawner.SpawnRule;
import org.bukkit.block.spawner.SpawnerEntry;
import org.bukkit.craftbukkit.CraftLootTable;
@@ -56,12 +57,14 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
@Override
public EntityType getSpawnedType() {
if (this.spawnPotentialsDefinition.isEmpty()) {
return null;
}
if (this.spawnPotentialsDefinition.isEmpty()) {
return null;
}
Optional<net.minecraft.world.entity.EntityType<?>> type = net.minecraft.world.entity.EntityType.by(this.spawnPotentialsDefinition.unwrap().get(0).value().getEntityToSpawn());
return type.map(CraftEntityType::minecraftToBukkit).orElse(null);
Optional<net.minecraft.world.entity.EntityType<?>> type = net.minecraft.world.entity.EntityType.by(TagValueInput.createGlobalDiscarding(
this.spawnPotentialsDefinition.unwrap().getFirst().value().getEntityToSpawn()
));
return type.map(CraftEntityType::minecraftToBukkit).orElse(null);
}
@Override
@@ -74,7 +77,7 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
Preconditions.checkArgument(entityType != EntityType.UNKNOWN, "Can't spawn EntityType %s from mob spawners!", entityType);
SpawnData data = new SpawnData();
data.getEntityToSpawn().putString(Entity.ID_TAG, BuiltInRegistries.ENTITY_TYPE.getKey(CraftEntityType.bukkitToMinecraft(entityType)).toString());
data.getEntityToSpawn().putString(Entity.TAG_ID, BuiltInRegistries.ENTITY_TYPE.getKey(CraftEntityType.bukkitToMinecraft(entityType)).toString());
this.getTrialData().nextSpawnData = Optional.of(data);
this.spawnPotentialsDefinition = WeightedList.of(data);
}
@@ -121,7 +124,7 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
@Override
public int getDelay() {
return this.ticksBetweenSpawn;
return this.ticksBetweenSpawn;
}
@Override
@@ -287,16 +290,16 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
@Override
public int getRequiredPlayerRange() {
return this.snapshot.trialSpawner.getRequiredPlayerRange();
return this.snapshot.trialSpawner.getRequiredPlayerRange();
}
@Override
public void setRequiredPlayerRange(int requiredPlayerRange) {
this.snapshot.trialSpawner.requiredPlayerRange = requiredPlayerRange;
this.snapshot.trialSpawner.config = this.snapshot.trialSpawner.config.overrideRequiredPlayerRange(requiredPlayerRange);
}
private TrialSpawnerData getTrialData() {
return this.snapshot.getTrialSpawner().getData();
private TrialSpawnerStateData getTrialData() {
return this.snapshot.getTrialSpawner().getStateData();
}
protected TrialSpawnerConfig toMinecraft() {