From 614121743dc7e330c22035878ccd5e992ce9371f Mon Sep 17 00:00:00 2001 From: Patbox <39821509+Patbox@users.noreply.github.com> Date: Sun, 8 Dec 2024 12:27:22 +0100 Subject: [PATCH] Update to 1.21.4 (without the book) --- build.gradle | 6 +- gradle.properties | 12 +-- gradle/wrapper/gradle-wrapper.properties | 2 +- .../creeperfall/Creeperfall.java | 4 +- .../entity/CreeperfallCreeperEntity.java | 7 +- .../entity/CreeperfallGuardianEntity.java | 2 +- .../entity/CreeperfallOcelotEntity.java | 5 +- .../entity/CreeperfallSkeletonEntity.java | 4 +- .../ai/goal/CreeperfallFollowTargetGoal.java | 5 +- .../entity/ai/goal/LookUpAtEntityGoal.java | 5 +- .../creeperfall/game/CreeperfallActive.java | 98 ++++++++++--------- .../game/CreeperfallStageManager.java | 4 +- .../creeperfall/game/CreeperfallTimerBar.java | 4 +- .../creeperfall/game/CreeperfallWaiting.java | 32 +++--- .../game/config/CreeperfallConfig.java | 11 ++- .../creeperfall/game/map/CreeperfallMap.java | 2 +- .../game/participant/ArmorUpgrade.java | 18 ++-- .../participant/CreeperfallParticipant.java | 21 ++-- .../game/shop/CreeperfallShop.java | 11 ++- .../CreeperfallCreeperSpawnLogic.java | 2 +- .../spawning/CreeperfallPlayerSpawnLogic.java | 17 ++-- .../{games => plasmid/game}/standard.json | 0 src/main/resources/fabric.mod.json | 4 +- 23 files changed, 149 insertions(+), 127 deletions(-) rename src/main/resources/data/creeperfall/{games => plasmid/game}/standard.json (100%) diff --git a/build.gradle b/build.gradle index 53c17f8..abcbe6c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,10 @@ plugins { - id 'fabric-loom' version '1.5.+' + id 'fabric-loom' version '1.8.+' id 'maven-publish' } -sourceCompatibility = JavaVersion.VERSION_17 -targetCompatibility = JavaVersion.VERSION_17 +sourceCompatibility = JavaVersion.VERSION_21 +targetCompatibility = JavaVersion.VERSION_21 archivesBaseName = project.archives_base_name version = project.mod_version diff --git a/gradle.properties b/gradle.properties index db20ba8..7b38965 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,20 +3,20 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://modmuss50.me/fabric.html -minecraft_version=1.20.4 -yarn_mappings=1.20.4+build.1 -loader_version=0.15.6 +minecraft_version=1.21.4 +yarn_mappings=1.21.4+build.1 +loader_version=0.16.9 # Mod Properties -mod_version=1.3.10 +mod_version=1.3.11 maven_group=io.github.redstoneparadox archives_base_name=creeperfall # Dependencies # check this on https://modmuss50.me/fabric.html -fabric_version=0.91.1+1.20.4 +fabric_version=0.110.2+1.21.4 # check this on https://nucleoid.xyz/use/ -plasmid_version=0.5.102-SNAPSHOT+1.20.4 +plasmid_version=0.6.2+1.21.4 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e411586..e1adfb4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/io/github/redstoneparadox/creeperfall/Creeperfall.java b/src/main/java/io/github/redstoneparadox/creeperfall/Creeperfall.java index 45ea128..bcaca50 100644 --- a/src/main/java/io/github/redstoneparadox/creeperfall/Creeperfall.java +++ b/src/main/java/io/github/redstoneparadox/creeperfall/Creeperfall.java @@ -7,7 +7,7 @@ import net.minecraft.util.Identifier; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import xyz.nucleoid.plasmid.game.GameType; +import xyz.nucleoid.plasmid.api.game.GameType; public class Creeperfall implements ModInitializer { @@ -15,7 +15,7 @@ public class Creeperfall implements ModInitializer { public static final Logger LOGGER = LogManager.getLogger(ID); public static final GameType TYPE = GameType.register( - new Identifier(ID, "creeperfall"), + Identifier.of(ID, "creeperfall"), CreeperfallConfig.CODEC, CreeperfallWaiting::open ); diff --git a/src/main/java/io/github/redstoneparadox/creeperfall/entity/CreeperfallCreeperEntity.java b/src/main/java/io/github/redstoneparadox/creeperfall/entity/CreeperfallCreeperEntity.java index 31c3565..b11821e 100644 --- a/src/main/java/io/github/redstoneparadox/creeperfall/entity/CreeperfallCreeperEntity.java +++ b/src/main/java/io/github/redstoneparadox/creeperfall/entity/CreeperfallCreeperEntity.java @@ -12,6 +12,7 @@ import net.minecraft.entity.passive.CatEntity; import net.minecraft.entity.passive.OcelotEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; @@ -44,7 +45,7 @@ protected void initGoals() { 1, true, true, - livingEntity -> true + (livingEntity, world) -> true ) ); this.targetSelector.add(2, new CreeperfallFollowTargetGoal<>( @@ -53,7 +54,7 @@ protected void initGoals() { 1, true, true, - livingEntity -> true + (livingEntity, world) -> true ) ); } @@ -93,7 +94,7 @@ public void tick() { } if (getY() <= 0) { - kill(); + kill((ServerWorld) this.getWorld()); } super.tick(); } diff --git a/src/main/java/io/github/redstoneparadox/creeperfall/entity/CreeperfallGuardianEntity.java b/src/main/java/io/github/redstoneparadox/creeperfall/entity/CreeperfallGuardianEntity.java index 9e61389..3bd0366 100644 --- a/src/main/java/io/github/redstoneparadox/creeperfall/entity/CreeperfallGuardianEntity.java +++ b/src/main/java/io/github/redstoneparadox/creeperfall/entity/CreeperfallGuardianEntity.java @@ -42,7 +42,7 @@ protected void initGoals() { 10, true, false, - livingEntity -> livingEntity instanceof CreeperEntity + (livingEntity, world) -> livingEntity instanceof CreeperEntity ) ); } diff --git a/src/main/java/io/github/redstoneparadox/creeperfall/entity/CreeperfallOcelotEntity.java b/src/main/java/io/github/redstoneparadox/creeperfall/entity/CreeperfallOcelotEntity.java index c5abd42..775d6a5 100644 --- a/src/main/java/io/github/redstoneparadox/creeperfall/entity/CreeperfallOcelotEntity.java +++ b/src/main/java/io/github/redstoneparadox/creeperfall/entity/CreeperfallOcelotEntity.java @@ -7,6 +7,7 @@ import net.minecraft.entity.ai.goal.LookAtEntityGoal; import net.minecraft.entity.mob.CreeperEntity; import net.minecraft.entity.passive.OcelotEntity; +import net.minecraft.server.world.ServerWorld; import net.minecraft.world.World; import java.util.Set; @@ -28,7 +29,7 @@ public CreeperfallOcelotEntity(EntityTracker tracker, World world) { @Override protected void initGoals() { super.initGoals(); - this.targetSelector.add(1, new CreeperfallFollowTargetGoal<>(this, CreeperEntity.class, 10, false, false, Entity::isOnGround, false)); + this.targetSelector.add(1, new CreeperfallFollowTargetGoal<>(this, CreeperEntity.class, 10, false, false, (livingEntity, world) -> livingEntity.isOnGround(), false)); this.goalSelector.add(1, new LookAtEntityGoal(this, CreeperEntity.class, 128.0F)); } @@ -43,7 +44,7 @@ public void tick() { for (CreeperEntity creeper: creepers) { if (getPos().distanceTo(creeper.getPos()) <= 4 && creeper.isOnGround()) { - creeper.kill(); + creeper.kill((ServerWorld) this.getWorld()); } } diff --git a/src/main/java/io/github/redstoneparadox/creeperfall/entity/CreeperfallSkeletonEntity.java b/src/main/java/io/github/redstoneparadox/creeperfall/entity/CreeperfallSkeletonEntity.java index 239c92d..0f7517c 100644 --- a/src/main/java/io/github/redstoneparadox/creeperfall/entity/CreeperfallSkeletonEntity.java +++ b/src/main/java/io/github/redstoneparadox/creeperfall/entity/CreeperfallSkeletonEntity.java @@ -43,13 +43,13 @@ protected void initGoals() { 10, true, false, - livingEntity -> livingEntity instanceof CreeperEntity && !livingEntity.isOnGround() + (livingEntity, world) -> livingEntity instanceof CreeperEntity && !livingEntity.isOnGround() ) ); } @Override - public void setOnFireFor(int seconds) { + public void setOnFireForTicks(int ticks) { } diff --git a/src/main/java/io/github/redstoneparadox/creeperfall/entity/ai/goal/CreeperfallFollowTargetGoal.java b/src/main/java/io/github/redstoneparadox/creeperfall/entity/ai/goal/CreeperfallFollowTargetGoal.java index 050e0b1..75748e4 100644 --- a/src/main/java/io/github/redstoneparadox/creeperfall/entity/ai/goal/CreeperfallFollowTargetGoal.java +++ b/src/main/java/io/github/redstoneparadox/creeperfall/entity/ai/goal/CreeperfallFollowTargetGoal.java @@ -1,6 +1,7 @@ package io.github.redstoneparadox.creeperfall.entity.ai.goal; import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.ai.TargetPredicate; import net.minecraft.entity.ai.goal.ActiveTargetGoal; import net.minecraft.entity.mob.MobEntity; import net.minecraft.util.math.Box; @@ -11,12 +12,12 @@ public class CreeperfallFollowTargetGoal extends ActiveTargetGoal { private final boolean airborneTargetsOnly; - public CreeperfallFollowTargetGoal(MobEntity mob, Class targetClass, int reciprocalChance, boolean checkVisibility, boolean checkCanNavigate, @Nullable Predicate targetPredicate) { + public CreeperfallFollowTargetGoal(MobEntity mob, Class targetClass, int reciprocalChance, boolean checkVisibility, boolean checkCanNavigate, @Nullable TargetPredicate.EntityPredicate targetPredicate) { super(mob, targetClass, reciprocalChance, checkVisibility, checkCanNavigate, targetPredicate); this.airborneTargetsOnly = true; } - public CreeperfallFollowTargetGoal(MobEntity mob, Class targetClass, int reciprocalChance, boolean checkVisibility, boolean checkCanNavigate, @Nullable Predicate targetPredicate, boolean airborneTargetsOnly) { + public CreeperfallFollowTargetGoal(MobEntity mob, Class targetClass, int reciprocalChance, boolean checkVisibility, boolean checkCanNavigate, @Nullable TargetPredicate.EntityPredicate targetPredicate, boolean airborneTargetsOnly) { super(mob, targetClass, reciprocalChance, checkVisibility, checkCanNavigate, targetPredicate); this.airborneTargetsOnly = airborneTargetsOnly; } diff --git a/src/main/java/io/github/redstoneparadox/creeperfall/entity/ai/goal/LookUpAtEntityGoal.java b/src/main/java/io/github/redstoneparadox/creeperfall/entity/ai/goal/LookUpAtEntityGoal.java index 888a4e1..da4c3fe 100644 --- a/src/main/java/io/github/redstoneparadox/creeperfall/entity/ai/goal/LookUpAtEntityGoal.java +++ b/src/main/java/io/github/redstoneparadox/creeperfall/entity/ai/goal/LookUpAtEntityGoal.java @@ -4,6 +4,7 @@ import net.minecraft.entity.ai.goal.LookAtEntityGoal; import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.world.ServerWorld; public class LookUpAtEntityGoal extends LookAtEntityGoal { public LookUpAtEntityGoal(MobEntity mob, Class targetType, float range) { @@ -19,9 +20,9 @@ public boolean canStart() { } if (this.targetType == PlayerEntity.class) { - this.target = mob.getWorld().getClosestPlayer(targetPredicate, mob, mob.getX(), mob.getEyeY(), mob.getZ()); + this.target = ((ServerWorld) mob.getWorld()).getClosestPlayer(targetPredicate, mob, mob.getX(), mob.getEyeY(), mob.getZ()); } else { - this.target = mob.getWorld().getClosestEntity(targetType, targetPredicate, mob, mob.getX(), mob.getEyeY(), mob.getZ(), mob.getBoundingBox().expand(range, range, range)); + this.target = ((ServerWorld) mob.getWorld()).getClosestEntity(targetType, targetPredicate, mob, mob.getX(), mob.getEyeY(), mob.getZ(), mob.getBoundingBox().expand(range, range, range)); } return this.target != null; diff --git a/src/main/java/io/github/redstoneparadox/creeperfall/game/CreeperfallActive.java b/src/main/java/io/github/redstoneparadox/creeperfall/game/CreeperfallActive.java index d26a450..5e4c0f3 100644 --- a/src/main/java/io/github/redstoneparadox/creeperfall/game/CreeperfallActive.java +++ b/src/main/java/io/github/redstoneparadox/creeperfall/game/CreeperfallActive.java @@ -35,7 +35,6 @@ import net.minecraft.util.ActionResult; import net.minecraft.util.Formatting; import net.minecraft.util.Hand; -import net.minecraft.util.TypedActionResult; import net.minecraft.util.hit.EntityHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -43,14 +42,17 @@ import net.minecraft.world.GameMode; import net.minecraft.world.explosion.Explosion; import org.jetbrains.annotations.Nullable; -import xyz.nucleoid.plasmid.game.GameCloseReason; -import xyz.nucleoid.plasmid.game.GameSpace; -import xyz.nucleoid.plasmid.game.common.GlobalWidgets; -import xyz.nucleoid.plasmid.game.event.GameActivityEvents; -import xyz.nucleoid.plasmid.game.event.GamePlayerEvents; -import xyz.nucleoid.plasmid.game.player.PlayerSet; -import xyz.nucleoid.plasmid.game.rule.GameRuleType; -import xyz.nucleoid.plasmid.util.PlayerRef; +import xyz.nucleoid.plasmid.api.game.GameCloseReason; +import xyz.nucleoid.plasmid.api.game.GameSpace; +import xyz.nucleoid.plasmid.api.game.common.GlobalWidgets; +import xyz.nucleoid.plasmid.api.game.event.GameActivityEvents; +import xyz.nucleoid.plasmid.api.game.event.GamePlayerEvents; +import xyz.nucleoid.plasmid.api.game.player.JoinOffer; +import xyz.nucleoid.plasmid.api.game.player.PlayerSet; +import xyz.nucleoid.plasmid.api.game.rule.GameRuleType; +import xyz.nucleoid.plasmid.api.util.PlayerRef; +import xyz.nucleoid.stimuli.event.DroppedItemsResult; +import xyz.nucleoid.stimuli.event.EventResult; import xyz.nucleoid.stimuli.event.entity.EntityDeathEvent; import xyz.nucleoid.stimuli.event.entity.EntityDropItemsEvent; import xyz.nucleoid.stimuli.event.item.ItemUseEvent; @@ -106,26 +108,28 @@ private CreeperfallActive(GameSpace gameSpace, ServerWorld world, CreeperfallMap public static void open(GameSpace gameSpace, ServerWorld world, CreeperfallMap map, CreeperfallConfig config) { gameSpace.setActivity(game -> { - Set participants = gameSpace.getPlayers().stream() + Set participants = gameSpace.getPlayers().participants().stream() .map(PlayerRef::of) .collect(Collectors.toSet()); GlobalWidgets widgets = GlobalWidgets.addTo(game); CreeperfallActive active = new CreeperfallActive(gameSpace, world, map, widgets, config, participants); - game.setRule(GameRuleType.CRAFTING, ActionResult.FAIL); - game.setRule(GameRuleType.PORTALS, ActionResult.FAIL); - game.setRule(GameRuleType.PVP, ActionResult.FAIL); - game.setRule(GameRuleType.HUNGER, ActionResult.FAIL); - game.setRule(GameRuleType.FALL_DAMAGE, ActionResult.FAIL); - game.setRule(GameRuleType.BLOCK_DROPS, ActionResult.FAIL); - game.setRule(GameRuleType.THROW_ITEMS, ActionResult.FAIL); - game.setRule(GameRuleType.UNSTABLE_TNT, ActionResult.FAIL); - game.setRule(GameRuleType.BREAK_BLOCKS, ActionResult.FAIL); + game.setRule(GameRuleType.CRAFTING, EventResult.DENY); + game.setRule(GameRuleType.PORTALS, EventResult.DENY); + game.setRule(GameRuleType.PVP, EventResult.DENY); + game.setRule(GameRuleType.HUNGER, EventResult.DENY); + game.setRule(GameRuleType.FALL_DAMAGE, EventResult.DENY); + game.setRule(GameRuleType.BLOCK_DROPS, EventResult.DENY); + game.setRule(GameRuleType.THROW_ITEMS, EventResult.DENY); + game.setRule(GameRuleType.UNSTABLE_TNT, EventResult.DENY); + game.setRule(GameRuleType.BREAK_BLOCKS, EventResult.DENY); game.listen(GameActivityEvents.ENABLE, active::onOpen); game.listen(GameActivityEvents.DISABLE, active::onClose); + game.listen(GameActivityEvents.STATE_UPDATE, state -> state.canPlay(false)); - game.listen(GamePlayerEvents.OFFER, offer -> offer.accept(world, Vec3d.ZERO)); + game.listen(GamePlayerEvents.OFFER, JoinOffer::acceptSpectators); + game.listen(GamePlayerEvents.ACCEPT, offer -> offer.teleport(world, Vec3d.ZERO)); game.listen(GamePlayerEvents.ADD, active::addPlayer); game.listen(GamePlayerEvents.REMOVE, active::removePlayer); @@ -151,20 +155,20 @@ public void spawnGuardian() { CreeperfallGuardianEntity entity = new CreeperfallGuardianEntity(this.world); entity.setInvulnerable(true); - spawnEntity(entity, 0.5, 68, 0.5, SpawnReason.SPAWN_EGG); + spawnEntity(entity, 0.5, 68, 0.5, SpawnReason.SPAWN_ITEM_USE); } public void spawnOcelot() { CreeperfallOcelotEntity entity = new CreeperfallOcelotEntity(tracker, this.world); entity.setInvulnerable(true); - spawnEntity(entity, 0.5, 65, 0.5, SpawnReason.SPAWN_EGG); + spawnEntity(entity, 0.5, 65, 0.5, SpawnReason.SPAWN_ITEM_USE); } public void spawnSkeleton() { CreeperfallSkeletonEntity entity = new CreeperfallSkeletonEntity(this.world); - spawnEntity(entity, 0.5, 65, 0.5, SpawnReason.SPAWN_EGG); + spawnEntity(entity, 0.5, 65, 0.5, SpawnReason.SPAWN_ITEM_USE); } public void spawnEntity(Entity entity, double x, double y, double z, SpawnReason spawnReason) { @@ -183,7 +187,7 @@ public void spawnEntity(Entity entity, double x, double y, double z, SpawnReason entity.prevZ = z; if (entity instanceof MobEntity) { - ((MobEntity) entity).initialize(world, world.getLocalDifficulty(new BlockPos(0, 0, 0)), spawnReason, null, null); + ((MobEntity) entity).initialize(world, world.getLocalDifficulty(new BlockPos(0, 0, 0)), spawnReason, null); } world.spawnEntity(entity); @@ -217,23 +221,23 @@ private void removePlayer(ServerPlayerEntity player) { this.participants.remove(PlayerRef.of(player)); } - private ActionResult onPlayerDamage(ServerPlayerEntity player, DamageSource source, float amount) { + private EventResult onPlayerDamage(ServerPlayerEntity player, DamageSource source, float amount) { Entity sourceEntity = source.getSource(); if (sourceEntity instanceof ArrowEntity) { Entity owner = ((ArrowEntity) sourceEntity).getOwner(); if (owner instanceof SkeletonEntity) { - return ActionResult.FAIL; + return EventResult.DENY; } } // TODO handle damage //this.spawnParticipant(player); - return ActionResult.PASS; + return EventResult.PASS; } - private ActionResult onPlayerDeath(ServerPlayerEntity player, DamageSource source) { + private EventResult onPlayerDeath(ServerPlayerEntity player, DamageSource source) { this.removePlayer(player); this.spawnSpectator(player); @@ -242,17 +246,17 @@ private ActionResult onPlayerDeath(ServerPlayerEntity player, DamageSource sourc players.sendMessage(source.getDeathMessage(player)); - return ActionResult.FAIL; + return EventResult.DENY; } - private ActionResult onAttackEntity(ServerPlayerEntity attacker, Hand hand, Entity attacked, EntityHitResult hitResult) { - if (!(attacked instanceof CreeperEntity)) return ActionResult.FAIL; - return ActionResult.PASS; + private EventResult onAttackEntity(ServerPlayerEntity attacker, Hand hand, Entity attacked, EntityHitResult hitResult) { + if (!(attacked instanceof CreeperEntity)) return EventResult.DENY; + return EventResult.PASS; } - private ActionResult onEntityHit(ProjectileEntity entity, EntityHitResult hitResult) { - if (!(hitResult.getEntity() instanceof CreeperEntity)) return ActionResult.FAIL; - return ActionResult.PASS; + private EventResult onEntityHit(ProjectileEntity entity, EntityHitResult hitResult) { + if (!(hitResult.getEntity() instanceof CreeperEntity)) return EventResult.DENY; + return EventResult.PASS; } private void spawnParticipant(ServerPlayerEntity player) { @@ -307,11 +311,15 @@ private void tick() { } } - private void onExplosion(Explosion explosion, boolean bool) { - explosion.clearAffectedBlocks(); + + + private EventResult onExplosion(Explosion explosion, List blockPos) { + blockPos.clear(); + + return EventResult.PASS; } - private ActionResult onEntityDeath(LivingEntity entity, DamageSource source) { + private EventResult onEntityDeath(LivingEntity entity, DamageSource source) { if (entity instanceof CreeperEntity) { @Nullable Entity sourceEntity = source.getSource(); @Nullable ServerPlayerEntity player = null; @@ -332,27 +340,27 @@ else if (sourceEntity instanceof ArrowEntity) { int minEmeralds = config.emeraldRewardCount.min().orElse(0); int emeralds = (random.nextInt(maxEmeralds - minEmeralds) + 1) + minEmeralds; player.giveItemStack(new ItemStack(Items.EMERALD, emeralds)); - player.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.MASTER, 1.0f, 1.0f); + player.playSoundToPlayer(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.MASTER, 1.0f, 1.0f); } } - return ActionResult.PASS; + return EventResult.PASS; } - private TypedActionResult> onDropLoot(LivingEntity dropper, List loot) { + private DroppedItemsResult onDropLoot(LivingEntity dropper, List loot) { loot.clear(); - return TypedActionResult.consume(loot); + return DroppedItemsResult.pass(loot); } - private TypedActionResult onUseItem(ServerPlayerEntity player, Hand hand) { + private ActionResult onUseItem(ServerPlayerEntity player, Hand hand) { ItemStack stack = player.getStackInHand(hand); if (stack.getItem() == Items.COMPASS) { CreeperfallShop.create(participants.get(PlayerRef.of(player)), this, config.shopConfig); - return TypedActionResult.success(stack); + return ActionResult.SUCCESS_SERVER; } - return TypedActionResult.pass(stack); + return ActionResult.PASS; } private void broadcastResult() { diff --git a/src/main/java/io/github/redstoneparadox/creeperfall/game/CreeperfallStageManager.java b/src/main/java/io/github/redstoneparadox/creeperfall/game/CreeperfallStageManager.java index 3844095..fbee7e8 100644 --- a/src/main/java/io/github/redstoneparadox/creeperfall/game/CreeperfallStageManager.java +++ b/src/main/java/io/github/redstoneparadox/creeperfall/game/CreeperfallStageManager.java @@ -10,8 +10,8 @@ import net.minecraft.util.Formatting; import net.minecraft.util.math.Vec3d; import net.minecraft.world.GameMode; -import xyz.nucleoid.plasmid.game.GameSpace; -import xyz.nucleoid.plasmid.game.player.PlayerSet; +import xyz.nucleoid.plasmid.api.game.GameSpace; +import xyz.nucleoid.plasmid.api.game.player.PlayerSet; import java.util.Set; diff --git a/src/main/java/io/github/redstoneparadox/creeperfall/game/CreeperfallTimerBar.java b/src/main/java/io/github/redstoneparadox/creeperfall/game/CreeperfallTimerBar.java index b8308b2..2dba6b2 100644 --- a/src/main/java/io/github/redstoneparadox/creeperfall/game/CreeperfallTimerBar.java +++ b/src/main/java/io/github/redstoneparadox/creeperfall/game/CreeperfallTimerBar.java @@ -2,8 +2,8 @@ import net.minecraft.entity.boss.BossBar; import net.minecraft.text.Text; -import xyz.nucleoid.plasmid.game.common.GlobalWidgets; -import xyz.nucleoid.plasmid.game.common.widget.BossBarWidget; +import xyz.nucleoid.plasmid.api.game.common.GlobalWidgets; +import xyz.nucleoid.plasmid.api.game.common.widget.BossBarWidget; public final class CreeperfallTimerBar { private final BossBarWidget widget; diff --git a/src/main/java/io/github/redstoneparadox/creeperfall/game/CreeperfallWaiting.java b/src/main/java/io/github/redstoneparadox/creeperfall/game/CreeperfallWaiting.java index 16e0723..b7ff904 100644 --- a/src/main/java/io/github/redstoneparadox/creeperfall/game/CreeperfallWaiting.java +++ b/src/main/java/io/github/redstoneparadox/creeperfall/game/CreeperfallWaiting.java @@ -5,7 +5,6 @@ import io.github.redstoneparadox.creeperfall.game.map.CreeperfallMapGenerator; import io.github.redstoneparadox.creeperfall.game.spawning.CreeperfallPlayerSpawnLogic; import net.minecraft.entity.damage.DamageSource; -import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.item.WrittenBookItem; import net.minecraft.network.packet.s2c.play.OpenWrittenBookS2CPacket; @@ -13,19 +12,19 @@ import net.minecraft.server.world.ServerWorld; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; -import net.minecraft.util.TypedActionResult; import net.minecraft.util.math.Vec3d; import net.minecraft.world.GameMode; import net.minecraft.world.GameRules; import xyz.nucleoid.fantasy.RuntimeWorldConfig; -import xyz.nucleoid.plasmid.event.GameEvents; -import xyz.nucleoid.plasmid.game.GameOpenContext; -import xyz.nucleoid.plasmid.game.GameOpenProcedure; -import xyz.nucleoid.plasmid.game.GameResult; -import xyz.nucleoid.plasmid.game.GameSpace; -import xyz.nucleoid.plasmid.game.common.GameWaitingLobby; -import xyz.nucleoid.plasmid.game.event.GameActivityEvents; -import xyz.nucleoid.plasmid.game.event.GamePlayerEvents; +import xyz.nucleoid.plasmid.api.game.GameOpenContext; +import xyz.nucleoid.plasmid.api.game.GameOpenProcedure; +import xyz.nucleoid.plasmid.api.game.GameResult; +import xyz.nucleoid.plasmid.api.game.GameSpace; +import xyz.nucleoid.plasmid.api.game.common.GameWaitingLobby; +import xyz.nucleoid.plasmid.api.game.event.GameActivityEvents; +import xyz.nucleoid.plasmid.api.game.event.GamePlayerEvents; +import xyz.nucleoid.plasmid.api.game.player.JoinOffer; +import xyz.nucleoid.stimuli.event.EventResult; import xyz.nucleoid.stimuli.event.item.ItemUseEvent; import xyz.nucleoid.stimuli.event.player.PlayerDeathEvent; @@ -57,7 +56,8 @@ public static GameOpenProcedure open(GameOpenContext context) CreeperfallWaiting waiting = new CreeperfallWaiting(game.getGameSpace(), world, map, context.config()); GameWaitingLobby.addTo(game, config.playerConfig); - game.listen(GamePlayerEvents.OFFER, offer -> offer.accept(world, Vec3d.ZERO)); + game.listen(GamePlayerEvents.OFFER, JoinOffer::accept); + game.listen(GamePlayerEvents.ACCEPT, offer -> offer.teleport(world, Vec3d.ZERO)); game.listen(GameActivityEvents.REQUEST_START, waiting::requestStart); game.listen(GamePlayerEvents.ADD, waiting::addPlayer); game.listen(PlayerDeathEvent.EVENT, waiting::onPlayerDeath); @@ -74,18 +74,18 @@ private void addPlayer(ServerPlayerEntity player) { this.spawnPlayer(player); } - private ActionResult onPlayerDeath(ServerPlayerEntity player, DamageSource source) { + private EventResult onPlayerDeath(ServerPlayerEntity player, DamageSource source) { player.setHealth(20.0f); this.spawnPlayer(player); - return ActionResult.FAIL; + return EventResult.DENY; } private void spawnPlayer(ServerPlayerEntity player) { - this.spawnLogic.resetPlayer(player, GameMode.ADVENTURE, true); + this.spawnLogic.resetPlayer(player, this.gameSpace.getPlayers().participants().contains(player) ? GameMode.ADVENTURE : GameMode.SPECTATOR, true); this.spawnLogic.spawnPlayer(player); } - private TypedActionResult onItemUse(ServerPlayerEntity player, Hand hand) { + private ActionResult onItemUse(ServerPlayerEntity player, Hand hand) { var stack = player.getStackInHand(hand); if (stack.isOf(Items.WRITTEN_BOOK)) { if (WrittenBookItem.resolve(stack, player.getCommandSource(), player)) { @@ -95,6 +95,6 @@ private TypedActionResult onItemUse(ServerPlayerEntity player, Hand h player.networkHandler.sendPacket(new OpenWrittenBookS2CPacket(hand)); } - return TypedActionResult.success(stack, true); + return ActionResult.SUCCESS_SERVER; } } diff --git a/src/main/java/io/github/redstoneparadox/creeperfall/game/config/CreeperfallConfig.java b/src/main/java/io/github/redstoneparadox/creeperfall/game/config/CreeperfallConfig.java index 46b8056..12534d6 100644 --- a/src/main/java/io/github/redstoneparadox/creeperfall/game/config/CreeperfallConfig.java +++ b/src/main/java/io/github/redstoneparadox/creeperfall/game/config/CreeperfallConfig.java @@ -1,16 +1,17 @@ package io.github.redstoneparadox.creeperfall.game.config; import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import io.github.redstoneparadox.creeperfall.game.util.Codecs; import net.minecraft.predicate.NumberRange; -import xyz.nucleoid.plasmid.game.common.config.PlayerConfig; +import xyz.nucleoid.plasmid.api.game.common.config.WaitingLobbyConfig; import java.util.List; public class CreeperfallConfig { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - PlayerConfig.CODEC.fieldOf("players").forGetter(config -> config.playerConfig), + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( + WaitingLobbyConfig.CODEC.fieldOf("players").forGetter(config -> config.playerConfig), CreeperfallMapConfig.CODEC.fieldOf("map").forGetter(config -> config.mapConfig), CreeperfallShopConfig.CODEC.fieldOf("shop").forGetter(config -> config.shopConfig), CreeperfallCreeperConfig.CODEC.fieldOf("creepers").forGetter(config -> config.creeperConfig), @@ -20,7 +21,7 @@ public class CreeperfallConfig { Codecs.INT_RANGE.fieldOf("emerald_reward_count").forGetter(config -> config.emeraldRewardCount) ).apply(instance, CreeperfallConfig::new)); - public final PlayerConfig playerConfig; + public final WaitingLobbyConfig playerConfig; public final CreeperfallMapConfig mapConfig; public final CreeperfallShopConfig shopConfig; public final CreeperfallCreeperConfig creeperConfig; @@ -30,7 +31,7 @@ public class CreeperfallConfig { public final NumberRange.IntRange emeraldRewardCount; public CreeperfallConfig( - PlayerConfig playerConfig, + WaitingLobbyConfig playerConfig, CreeperfallMapConfig mapConfig, CreeperfallShopConfig shopConfig, CreeperfallCreeperConfig creeperConfig, diff --git a/src/main/java/io/github/redstoneparadox/creeperfall/game/map/CreeperfallMap.java b/src/main/java/io/github/redstoneparadox/creeperfall/game/map/CreeperfallMap.java index 7c722e7..4545c58 100644 --- a/src/main/java/io/github/redstoneparadox/creeperfall/game/map/CreeperfallMap.java +++ b/src/main/java/io/github/redstoneparadox/creeperfall/game/map/CreeperfallMap.java @@ -5,7 +5,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.gen.chunk.ChunkGenerator; import xyz.nucleoid.map_templates.MapTemplate; -import xyz.nucleoid.plasmid.game.world.generator.TemplateChunkGenerator; +import xyz.nucleoid.plasmid.api.game.world.generator.TemplateChunkGenerator; public class CreeperfallMap { private final MapTemplate template; diff --git a/src/main/java/io/github/redstoneparadox/creeperfall/game/participant/ArmorUpgrade.java b/src/main/java/io/github/redstoneparadox/creeperfall/game/participant/ArmorUpgrade.java index 1b898e1..5eb31fa 100644 --- a/src/main/java/io/github/redstoneparadox/creeperfall/game/participant/ArmorUpgrade.java +++ b/src/main/java/io/github/redstoneparadox/creeperfall/game/participant/ArmorUpgrade.java @@ -7,6 +7,9 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.RegistryWrapper; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.Pair; @@ -138,27 +141,26 @@ public boolean isNone() { public static class Builder { private final List>>> tiers = new ArrayList<>(); + private final RegistryWrapper.Impl enchantment; + + public Builder(RegistryWrapper.WrapperLookup lookup) { + this.enchantment = lookup.getOrThrow(RegistryKeys.ENCHANTMENT); + } public Builder tier(ArmorType type) { tiers.add(new Pair<>(type, itemStacks -> {})); return this; } - public Builder tier(ArmorType type, Enchantment enchantment, int level) { + public Builder tier(ArmorType type, RegistryKey enchantment, int level) { tiers.add(new Pair<>(type, itemStacks -> { for (ItemStack stack : itemStacks) { - EnchantmentHelper.set(map(enchantment, level), stack); + stack.addEnchantment(this.enchantment.getOrThrow(enchantment), level); } })); return this; } - private Map map(K k, V v) { - Map map = new HashMap<>(); - map.put(k, v); - return map; - } - public ArmorUpgrade build() { return new ArmorUpgrade(tiers); } diff --git a/src/main/java/io/github/redstoneparadox/creeperfall/game/participant/CreeperfallParticipant.java b/src/main/java/io/github/redstoneparadox/creeperfall/game/participant/CreeperfallParticipant.java index 6a86832..117eda7 100644 --- a/src/main/java/io/github/redstoneparadox/creeperfall/game/participant/CreeperfallParticipant.java +++ b/src/main/java/io/github/redstoneparadox/creeperfall/game/participant/CreeperfallParticipant.java @@ -7,12 +7,14 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.Hand; import org.jetbrains.annotations.Nullable; -import xyz.nucleoid.plasmid.game.GameSpace; -import xyz.nucleoid.plasmid.util.PlayerRef; +import xyz.nucleoid.plasmid.api.game.GameSpace; +import xyz.nucleoid.plasmid.api.util.PlayerRef; import java.util.Objects; @@ -22,16 +24,17 @@ public class CreeperfallParticipant { private boolean gameStarted = false; private boolean fireworks = false; - public final ArmorUpgrade armorUpgrade = new ArmorUpgrade.Builder() - .tier(ArmorUpgrade.ArmorType.NONE) - .tier(ArmorUpgrade.ArmorType.CHAIN, Enchantments.BLAST_PROTECTION, 1) - .tier(ArmorUpgrade.ArmorType.CHAIN, Enchantments.BLAST_PROTECTION, 2) - .tier(ArmorUpgrade.ArmorType.CHAIN, Enchantments.BLAST_PROTECTION, 3) - .build(); + public final ArmorUpgrade armorUpgrade; public final StatUpgrade maxArrowsUpgrade; public CreeperfallParticipant(PlayerRef player, ServerWorld world, CreeperfallConfig config) { + this.armorUpgrade = new ArmorUpgrade.Builder(world.getRegistryManager()) + .tier(ArmorUpgrade.ArmorType.NONE) + .tier(ArmorUpgrade.ArmorType.CHAIN, Enchantments.BLAST_PROTECTION, 1) + .tier(ArmorUpgrade.ArmorType.CHAIN, Enchantments.BLAST_PROTECTION, 2) + .tier(ArmorUpgrade.ArmorType.CHAIN, Enchantments.BLAST_PROTECTION, 3) + .build(); this.player = player; this.world = world; armorUpgrade.upgrade(this); @@ -110,7 +113,7 @@ public void enableCrossbowAndFireworks() { } ItemStack crossbowStack = new ItemStack(Items.CROSSBOW); - crossbowStack.addEnchantment(Enchantments.QUICK_CHARGE, 3); + crossbowStack.addEnchantment(this.world.getRegistryManager().getOrThrow(RegistryKeys.ENCHANTMENT).getOrThrow(Enchantments.QUICK_CHARGE), 3); player.giveItemStack(crossbowStack); replenishArrows(); diff --git a/src/main/java/io/github/redstoneparadox/creeperfall/game/shop/CreeperfallShop.java b/src/main/java/io/github/redstoneparadox/creeperfall/game/shop/CreeperfallShop.java index fd8671d..356ff2e 100644 --- a/src/main/java/io/github/redstoneparadox/creeperfall/game/shop/CreeperfallShop.java +++ b/src/main/java/io/github/redstoneparadox/creeperfall/game/shop/CreeperfallShop.java @@ -7,15 +7,16 @@ import io.github.redstoneparadox.creeperfall.game.participant.CreeperfallParticipant; import io.github.redstoneparadox.creeperfall.game.participant.StatUpgrade; import io.github.redstoneparadox.creeperfall.game.participant.Upgrade; +import net.minecraft.component.DataComponentTypes; import net.minecraft.item.Item; import net.minecraft.item.Items; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Style; import net.minecraft.text.Text; import net.minecraft.util.Formatting; -import xyz.nucleoid.plasmid.shop.Cost; -import xyz.nucleoid.plasmid.shop.ShopEntry; -import xyz.nucleoid.plasmid.util.Guis; +import xyz.nucleoid.plasmid.api.shop.Cost; +import xyz.nucleoid.plasmid.api.shop.ShopEntry; +import xyz.nucleoid.plasmid.api.util.Guis; import java.util.ArrayList; import java.util.List; @@ -54,7 +55,7 @@ public static SimpleGui create(CreeperfallParticipant participant, CreeperfallAc */ - var gui = Guis.createSelectorGui(participant.getPlayerEntity(), Text.translatable(TRANSLATION_ROOT + "title"), shop); + var gui = Guis.createSelectorGui(participant.getPlayerEntity(), Text.translatable(TRANSLATION_ROOT + "title"), false, shop); gui.open(); return gui; @@ -112,7 +113,7 @@ private static ShopEntry upgrade(CreeperfallParticipant participant, List upgrade.canUpgrade() ? Cost.ofEmeralds(prices.get(upgrade.getTier())) : Cost.no()) diff --git a/src/main/java/io/github/redstoneparadox/creeperfall/game/spawning/CreeperfallCreeperSpawnLogic.java b/src/main/java/io/github/redstoneparadox/creeperfall/game/spawning/CreeperfallCreeperSpawnLogic.java index 7658c17..5a33ce7 100644 --- a/src/main/java/io/github/redstoneparadox/creeperfall/game/spawning/CreeperfallCreeperSpawnLogic.java +++ b/src/main/java/io/github/redstoneparadox/creeperfall/game/spawning/CreeperfallCreeperSpawnLogic.java @@ -12,7 +12,7 @@ import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.random.Random; -import xyz.nucleoid.plasmid.game.GameSpace; +import xyz.nucleoid.plasmid.api.game.GameSpace; public class CreeperfallCreeperSpawnLogic { private final GameSpace gameSpace; diff --git a/src/main/java/io/github/redstoneparadox/creeperfall/game/spawning/CreeperfallPlayerSpawnLogic.java b/src/main/java/io/github/redstoneparadox/creeperfall/game/spawning/CreeperfallPlayerSpawnLogic.java index 85b1335..f9b1ac5 100644 --- a/src/main/java/io/github/redstoneparadox/creeperfall/game/spawning/CreeperfallPlayerSpawnLogic.java +++ b/src/main/java/io/github/redstoneparadox/creeperfall/game/spawning/CreeperfallPlayerSpawnLogic.java @@ -2,6 +2,8 @@ import io.github.redstoneparadox.creeperfall.Creeperfall; import io.github.redstoneparadox.creeperfall.game.map.CreeperfallMap; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.component.type.UnbreakableComponent; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffects; import net.minecraft.item.ItemStack; @@ -13,11 +15,14 @@ import net.minecraft.server.world.ServerWorld; import net.minecraft.text.Text; import net.minecraft.util.Formatting; +import net.minecraft.util.Unit; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.GameMode; +import java.util.Set; + public class CreeperfallPlayerSpawnLogic { private final CreeperfallMap map; private final ServerWorld world; @@ -45,19 +50,17 @@ public void resetPlayer(ServerPlayerEntity player, GameMode gameMode, boolean lo if (gameMode != GameMode.SPECTATOR && !lobby) { ItemStack compassStack = new ItemStack(Items.COMPASS); - compassStack.setCustomName(Text.translatable("shop.creeperfall.title").formatted(Formatting.AQUA, Formatting.ITALIC)); + compassStack.set(DataComponentTypes.ITEM_NAME, Text.translatable("shop.creeperfall.title").formatted(Formatting.AQUA, Formatting.ITALIC)); player.giveItemStack(compassStack); ItemStack bowStack = new ItemStack(Items.BOW); - NbtCompound nbt = bowStack.getOrCreateNbt(); - - nbt.putBoolean("Unbreakable", true); + bowStack.set(DataComponentTypes.UNBREAKABLE, new UnbreakableComponent(true)); player.giveItemStack(bowStack); //player.giveItemStack(new ItemStack(Items.ARROW, config.maxArrows.get(0))); } if (lobby) { - ItemStack bookStack = new ItemStack(Items.WRITTEN_BOOK); + /*ItemStack bookStack = new ItemStack(Items.WRITTEN_BOOK); NbtCompound nbt = bookStack.getOrCreateNbt(); NbtList pages = new NbtList(); NbtCompound display = new NbtCompound(); @@ -80,7 +83,7 @@ public void resetPlayer(ServerPlayerEntity player, GameMode gameMode, boolean lo nbt.putString("title", "How to Play"); nbt.putString("author", "RedstoneParadox"); - player.giveItemStack(bookStack); + player.giveItemStack(bookStack);*/ } if (gameMode == GameMode.SPECTATOR) { @@ -99,6 +102,6 @@ public void spawnPlayer(ServerPlayerEntity player) { float x = pos.getX() + MathHelper.nextFloat(player.getRandom(), -radius, radius); float z = pos.getZ() + MathHelper.nextFloat(player.getRandom(), -radius, radius); - player.teleport(this.world, x, pos.getY() + 0.5, z, 0.0F, 0.0F); + player.teleport(this.world, x, pos.getY() + 0.5, z, Set.of(), 0.0F, 0.0F, false); } } diff --git a/src/main/resources/data/creeperfall/games/standard.json b/src/main/resources/data/creeperfall/plasmid/game/standard.json similarity index 100% rename from src/main/resources/data/creeperfall/games/standard.json rename to src/main/resources/data/creeperfall/plasmid/game/standard.json diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 7065cd0..5305be5 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -20,7 +20,7 @@ "depends": { "fabricloader": ">=0.9.1", "fabric": "*", - "minecraft": ">=1.17.1", - "plasmid": "0.5.x" + "minecraft": ">=1.21.4", + "plasmid": "0.6.x" } }