From 395b5dbd75059603b69a5a077eaec3283724d90e Mon Sep 17 00:00:00 2001 From: XiaoHuNao Date: Sun, 21 Jan 2024 03:08:35 +0800 Subject: [PATCH] update --- .../surviving_the_aftermath/api/Constant.java | 5 --- .../api/SpawnPosHandler.java | 9 ---- .../api/base/BaseAftermath.java | 10 ++--- .../common/event/PlayerEvent.java | 42 ------------------- .../event/subscriber/ClientForgeEvent.java | 3 +- .../event/subscriber/RaidEventSubscriber.java | 6 --- .../condition/StructureConditionModule.java | 2 +- .../module/entity_info/EntityInfoModule.java | 4 +- .../EntityInfoWithPredicateModule.java | 7 ---- .../module/predicate/EquipmentPredicate.java | 2 - .../weighted/AttributeWeightedModule.java | 2 +- .../module/weighted/EffectWeightedModule.java | 3 +- .../weighted/EntityTypeWeightedModule.java | 6 +-- .../module/weighted/ItemWeightedModule.java | 5 +-- .../common/raid/BaseRaid.java | 23 +++++----- .../common/raid/NetherRaid.java | 37 +++++++++++++++- .../{ => common}/util/AftermathEventUtil.java | 2 +- .../{ => common}/util/CodecUtils.java | 2 +- .../{ => common}/util/RandomUtils.java | 2 +- .../{ => common}/util/RegistryUtil.java | 2 +- .../{ => common}/util/StructureUtils.java | 2 +- .../compat/kubejs/ModKubeJSPlugin.java | 2 +- 22 files changed, 66 insertions(+), 112 deletions(-) delete mode 100644 src/main/java/com/pancake/surviving_the_aftermath/api/Constant.java delete mode 100644 src/main/java/com/pancake/surviving_the_aftermath/api/SpawnPosHandler.java rename src/main/java/com/pancake/surviving_the_aftermath/{ => common}/util/AftermathEventUtil.java (98%) rename src/main/java/com/pancake/surviving_the_aftermath/{ => common}/util/CodecUtils.java (97%) rename src/main/java/com/pancake/surviving_the_aftermath/{ => common}/util/RandomUtils.java (94%) rename src/main/java/com/pancake/surviving_the_aftermath/{ => common}/util/RegistryUtil.java (97%) rename src/main/java/com/pancake/surviving_the_aftermath/{ => common}/util/StructureUtils.java (98%) diff --git a/src/main/java/com/pancake/surviving_the_aftermath/api/Constant.java b/src/main/java/com/pancake/surviving_the_aftermath/api/Constant.java deleted file mode 100644 index 62a5c48..0000000 --- a/src/main/java/com/pancake/surviving_the_aftermath/api/Constant.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.pancake.surviving_the_aftermath.api; - -public class Constant { - public static final String IDENTIFIER = "identifier"; -} diff --git a/src/main/java/com/pancake/surviving_the_aftermath/api/SpawnPosHandler.java b/src/main/java/com/pancake/surviving_the_aftermath/api/SpawnPosHandler.java deleted file mode 100644 index b8cfa45..0000000 --- a/src/main/java/com/pancake/surviving_the_aftermath/api/SpawnPosHandler.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.pancake.surviving_the_aftermath.api; - -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.Level; - -@FunctionalInterface -public interface SpawnPosHandler { - void handleSpawnPos(Level level, BlockPos pos); -} \ No newline at end of file diff --git a/src/main/java/com/pancake/surviving_the_aftermath/api/base/BaseAftermath.java b/src/main/java/com/pancake/surviving_the_aftermath/api/base/BaseAftermath.java index ce3ddbe..656c4c6 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/api/base/BaseAftermath.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/api/base/BaseAftermath.java @@ -6,8 +6,7 @@ import com.pancake.surviving_the_aftermath.api.module.IAftermathModule; import com.pancake.surviving_the_aftermath.common.data.pack.AftermathModuleLoader; import com.pancake.surviving_the_aftermath.common.raid.module.BaseRaidModule; -import com.pancake.surviving_the_aftermath.compat.kubejs.util.AftermathEventJsUtil; -import com.pancake.surviving_the_aftermath.util.AftermathEventUtil; +import com.pancake.surviving_the_aftermath.common.util.AftermathEventUtil; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerBossEvent; @@ -28,8 +27,8 @@ public abstract class BaseAftermath implements IAftermath { protected Set players = Sets.newHashSet(); - protected final ServerBossEvent progress = new ServerBossEvent(Component.empty(), BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.PROGRESS); - protected final UUID uuid = progress.getId(); + protected ServerBossEvent progress = new ServerBossEvent(Component.empty(), BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.PROGRESS); + protected UUID uuid = progress.getId(); protected float progressPercent = progress.getProgress(); @@ -76,7 +75,8 @@ public void updateProgress() { public void updatePlayers() { final Set oldPlayers = Sets.newHashSet(progress.getPlayers()); - final Set newPlayers = Sets.newHashSet(level.getPlayers(this.validPlayer())); + List players1 = level.getPlayers(this.validPlayer()); + final Set newPlayers = Sets.newHashSet(players1); players.clear(); newPlayers.stream() .filter(player -> !oldPlayers.contains(player)) diff --git a/src/main/java/com/pancake/surviving_the_aftermath/common/event/PlayerEvent.java b/src/main/java/com/pancake/surviving_the_aftermath/common/event/PlayerEvent.java index 57f384b..8943240 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/common/event/PlayerEvent.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/event/PlayerEvent.java @@ -1,54 +1,12 @@ package com.pancake.surviving_the_aftermath.common.event; -import com.google.gson.JsonElement; -import com.mojang.serialization.DataResult; -import com.mojang.serialization.JsonOps; -import com.pancake.surviving_the_aftermath.SurvivingTheAftermath; -import com.pancake.surviving_the_aftermath.api.module.IAftermathModule; -import com.pancake.surviving_the_aftermath.api.module.IEntityInfoModule; -import com.pancake.surviving_the_aftermath.common.module.amount.IntegerAmountModule; -import com.pancake.surviving_the_aftermath.common.module.amount.RandomAmountModule; -import com.pancake.surviving_the_aftermath.common.module.condition.StructureConditionModule; -import com.pancake.surviving_the_aftermath.common.module.entity_info.EntityInfoModule; -import com.pancake.surviving_the_aftermath.common.module.entity_info.EntityInfoWithPredicateModule; -import com.pancake.surviving_the_aftermath.common.module.predicate.AttributePredicate; -import com.pancake.surviving_the_aftermath.common.module.predicate.EffectPredicate; -import com.pancake.surviving_the_aftermath.common.module.predicate.EquipmentPredicate; -import com.pancake.surviving_the_aftermath.common.module.predicate.NBTPredicate; -import com.pancake.surviving_the_aftermath.common.module.weighted.AttributeWeightedModule; -import com.pancake.surviving_the_aftermath.common.module.weighted.ItemWeightedModule; -import com.pancake.surviving_the_aftermath.common.raid.module.BaseRaidModule; -import com.pancake.surviving_the_aftermath.util.StructureUtils; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; -import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.effect.MobEffects; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.ai.attributes.AttributeModifier; -import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; -import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.block.BeaconBlock; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.NetherPortalBlock; -import net.minecraft.world.level.block.entity.BeaconBlockEntity; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.portal.PortalShape; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - @Mod.EventBusSubscriber public class PlayerEvent { private static Object blockPos; diff --git a/src/main/java/com/pancake/surviving_the_aftermath/common/event/subscriber/ClientForgeEvent.java b/src/main/java/com/pancake/surviving_the_aftermath/common/event/subscriber/ClientForgeEvent.java index 406c49b..52972c8 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/common/event/subscriber/ClientForgeEvent.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/event/subscriber/ClientForgeEvent.java @@ -2,6 +2,7 @@ import com.pancake.surviving_the_aftermath.SurvivingTheAftermath; import com.pancake.surviving_the_aftermath.api.AftermathManager; +import com.pancake.surviving_the_aftermath.api.IAftermath; import net.minecraft.client.gui.components.LerpingBossEvent; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; @@ -20,7 +21,6 @@ public static void netherRaidProgress(CustomizeGuiOverlayEvent.BossEventProgress LerpingBossEvent bossEvent = event.getBossEvent(); AftermathManager manager = AftermathManager.getInstance(); manager.getAftermath(bossEvent.getId()).ifPresent(aftermath -> { - event.setCanceled(true); var graphics = event.getGuiGraphics(); ResourceLocation resource = aftermath.getBarsResource(); int[] offset = aftermath.getBarsOffset(); @@ -43,6 +43,7 @@ public static void netherRaidProgress(CustomizeGuiOverlayEvent.BossEventProgress graphics.blit(resource, (graphics.guiWidth() - barWidth) / 2, event.getY() - 10 + barOffset, 0, 0, (int) (barWidth * event.getBossEvent().getProgress()), barHeight); event.setIncrement(frameHeight); + event.setCanceled(true); }); } } diff --git a/src/main/java/com/pancake/surviving_the_aftermath/common/event/subscriber/RaidEventSubscriber.java b/src/main/java/com/pancake/surviving_the_aftermath/common/event/subscriber/RaidEventSubscriber.java index fddec60..2e99124 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/common/event/subscriber/RaidEventSubscriber.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/event/subscriber/RaidEventSubscriber.java @@ -1,21 +1,15 @@ package com.pancake.surviving_the_aftermath.common.event.subscriber; -import com.pancake.surviving_the_aftermath.SurvivingTheAftermath; import com.pancake.surviving_the_aftermath.api.AftermathManager; import com.pancake.surviving_the_aftermath.common.init.ModStructures; -import com.pancake.surviving_the_aftermath.common.raid.BaseRaid; import com.pancake.surviving_the_aftermath.common.raid.NetherRaid; -import com.pancake.surviving_the_aftermath.common.raid.module.BaseRaidModule; -import com.pancake.surviving_the_aftermath.util.StructureUtils; import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; import net.minecraft.core.registries.Registries; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.portal.PortalShape; import net.minecraftforge.event.entity.EntityTravelToDimensionEvent; import net.minecraftforge.event.level.BlockEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; diff --git a/src/main/java/com/pancake/surviving_the_aftermath/common/module/condition/StructureConditionModule.java b/src/main/java/com/pancake/surviving_the_aftermath/common/module/condition/StructureConditionModule.java index 32ad368..9f9985a 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/common/module/condition/StructureConditionModule.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/module/condition/StructureConditionModule.java @@ -3,7 +3,7 @@ import com.mojang.serialization.Codec; import com.pancake.surviving_the_aftermath.api.module.IConditionModule; import com.pancake.surviving_the_aftermath.common.init.ModAftermathModule; -import com.pancake.surviving_the_aftermath.util.RegistryUtil; +import com.pancake.surviving_the_aftermath.common.util.RegistryUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; diff --git a/src/main/java/com/pancake/surviving_the_aftermath/common/module/entity_info/EntityInfoModule.java b/src/main/java/com/pancake/surviving_the_aftermath/common/module/entity_info/EntityInfoModule.java index 302d89b..5337254 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/common/module/entity_info/EntityInfoModule.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/module/entity_info/EntityInfoModule.java @@ -6,10 +6,8 @@ import com.pancake.surviving_the_aftermath.api.module.IAmountModule; import com.pancake.surviving_the_aftermath.api.module.IEntityInfoModule; import com.pancake.surviving_the_aftermath.common.init.ModAftermathModule; -import com.pancake.surviving_the_aftermath.common.init.ModuleRegistry; -import com.pancake.surviving_the_aftermath.util.RegistryUtil; +import com.pancake.surviving_the_aftermath.common.util.RegistryUtil; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.Level; diff --git a/src/main/java/com/pancake/surviving_the_aftermath/common/module/entity_info/EntityInfoWithPredicateModule.java b/src/main/java/com/pancake/surviving_the_aftermath/common/module/entity_info/EntityInfoWithPredicateModule.java index 66d0931..d5b0aec 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/common/module/entity_info/EntityInfoWithPredicateModule.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/module/entity_info/EntityInfoWithPredicateModule.java @@ -6,18 +6,11 @@ import com.pancake.surviving_the_aftermath.api.module.IAmountModule; import com.pancake.surviving_the_aftermath.api.module.IEntityInfoModule; import com.pancake.surviving_the_aftermath.api.module.IPredicateModule; -import com.pancake.surviving_the_aftermath.api.module.IWeightedModule; import com.pancake.surviving_the_aftermath.common.init.ModAftermathModule; -import com.pancake.surviving_the_aftermath.common.init.ModuleRegistry; -import com.pancake.surviving_the_aftermath.common.module.weighted.ItemWeightedModule; -import com.pancake.surviving_the_aftermath.util.RegistryUtil; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.util.random.WeightedEntry; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.Mob; import net.minecraft.world.level.Level; import net.minecraftforge.common.util.LazyOptional; diff --git a/src/main/java/com/pancake/surviving_the_aftermath/common/module/predicate/EquipmentPredicate.java b/src/main/java/com/pancake/surviving_the_aftermath/common/module/predicate/EquipmentPredicate.java index fb1099c..d103e48 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/common/module/predicate/EquipmentPredicate.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/module/predicate/EquipmentPredicate.java @@ -5,11 +5,9 @@ import com.pancake.surviving_the_aftermath.api.module.IPredicateModule; import com.pancake.surviving_the_aftermath.common.init.ModAftermathModule; import com.pancake.surviving_the_aftermath.common.module.weighted.ItemWeightedModule; -import com.pancake.surviving_the_aftermath.util.RegistryUtil; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; -import net.minecraft.world.item.Item; public class EquipmentPredicate implements IPredicateModule { public static final String IDENTIFIER = "equipment"; diff --git a/src/main/java/com/pancake/surviving_the_aftermath/common/module/weighted/AttributeWeightedModule.java b/src/main/java/com/pancake/surviving_the_aftermath/common/module/weighted/AttributeWeightedModule.java index 8a706bb..81418a6 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/common/module/weighted/AttributeWeightedModule.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/module/weighted/AttributeWeightedModule.java @@ -4,7 +4,7 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; import com.pancake.surviving_the_aftermath.api.module.IWeightedModule; import com.pancake.surviving_the_aftermath.common.init.ModAftermathModule; -import com.pancake.surviving_the_aftermath.util.CodecUtils; +import com.pancake.surviving_the_aftermath.common.util.CodecUtils; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.util.random.WeightedEntry; import net.minecraft.world.entity.ai.attributes.Attribute; diff --git a/src/main/java/com/pancake/surviving_the_aftermath/common/module/weighted/EffectWeightedModule.java b/src/main/java/com/pancake/surviving_the_aftermath/common/module/weighted/EffectWeightedModule.java index 28d4211..a781d44 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/common/module/weighted/EffectWeightedModule.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/module/weighted/EffectWeightedModule.java @@ -1,10 +1,9 @@ package com.pancake.surviving_the_aftermath.common.module.weighted; import com.mojang.serialization.Codec; -import com.mojang.serialization.codecs.RecordCodecBuilder; import com.pancake.surviving_the_aftermath.api.module.IWeightedModule; import com.pancake.surviving_the_aftermath.common.init.ModAftermathModule; -import com.pancake.surviving_the_aftermath.util.CodecUtils; +import com.pancake.surviving_the_aftermath.common.util.CodecUtils; import net.minecraft.util.random.WeightedEntry; import net.minecraft.world.effect.MobEffectInstance; diff --git a/src/main/java/com/pancake/surviving_the_aftermath/common/module/weighted/EntityTypeWeightedModule.java b/src/main/java/com/pancake/surviving_the_aftermath/common/module/weighted/EntityTypeWeightedModule.java index 43d6b62..08ab91d 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/common/module/weighted/EntityTypeWeightedModule.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/module/weighted/EntityTypeWeightedModule.java @@ -1,18 +1,14 @@ package com.pancake.surviving_the_aftermath.common.module.weighted; import com.mojang.serialization.Codec; -import com.mojang.serialization.DataResult; -import com.mojang.serialization.codecs.RecordCodecBuilder; import com.pancake.surviving_the_aftermath.api.module.IWeightedModule; import com.pancake.surviving_the_aftermath.common.init.ModAftermathModule; -import com.pancake.surviving_the_aftermath.util.RegistryUtil; +import com.pancake.surviving_the_aftermath.common.util.RegistryUtil; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.util.random.WeightedEntry; import net.minecraft.world.entity.EntityType; -import net.minecraftforge.registries.ForgeRegistries; import java.util.List; -import java.util.stream.Collectors; public class EntityTypeWeightedModule extends BaseWeightedModule> { public static final String IDENTIFIER = "entity_type_weighted"; diff --git a/src/main/java/com/pancake/surviving_the_aftermath/common/module/weighted/ItemWeightedModule.java b/src/main/java/com/pancake/surviving_the_aftermath/common/module/weighted/ItemWeightedModule.java index 7605a63..a6def35 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/common/module/weighted/ItemWeightedModule.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/module/weighted/ItemWeightedModule.java @@ -2,17 +2,14 @@ import com.google.common.collect.Lists; import com.mojang.serialization.Codec; -import com.mojang.serialization.DataResult; -import com.mojang.serialization.codecs.RecordCodecBuilder; import com.pancake.surviving_the_aftermath.api.module.IWeightedModule; import com.pancake.surviving_the_aftermath.common.init.ModAftermathModule; -import com.pancake.surviving_the_aftermath.util.RegistryUtil; +import com.pancake.surviving_the_aftermath.common.util.RegistryUtil; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.util.random.WeightedEntry; import net.minecraft.world.item.Item; import java.util.List; -import java.util.stream.Collectors; public class ItemWeightedModule extends BaseWeightedModule { public static final String IDENTIFIER = "item_weighted"; diff --git a/src/main/java/com/pancake/surviving_the_aftermath/common/raid/BaseRaid.java b/src/main/java/com/pancake/surviving_the_aftermath/common/raid/BaseRaid.java index ab86422..53aed69 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/common/raid/BaseRaid.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/raid/BaseRaid.java @@ -5,7 +5,6 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; import com.pancake.surviving_the_aftermath.SurvivingTheAftermath; import com.pancake.surviving_the_aftermath.api.AftermathManager; -import com.pancake.surviving_the_aftermath.api.SpawnPosHandler; import com.pancake.surviving_the_aftermath.api.AftermathState; import com.pancake.surviving_the_aftermath.api.IAftermath; import com.pancake.surviving_the_aftermath.api.base.BaseAftermath; @@ -13,13 +12,12 @@ import com.pancake.surviving_the_aftermath.api.module.IEntityInfoModule; import com.pancake.surviving_the_aftermath.common.init.ModAftermathModule; import com.pancake.surviving_the_aftermath.common.module.condition.StructureConditionModule; -import com.pancake.surviving_the_aftermath.common.module.entity_info.EntityInfoWithPredicateModule; import com.pancake.surviving_the_aftermath.common.raid.api.IRaid; import com.pancake.surviving_the_aftermath.common.raid.module.BaseRaidModule; -import com.pancake.surviving_the_aftermath.util.AftermathEventUtil; -import com.pancake.surviving_the_aftermath.util.CodecUtils; -import com.pancake.surviving_the_aftermath.util.RandomUtils; -import com.pancake.surviving_the_aftermath.util.StructureUtils; +import com.pancake.surviving_the_aftermath.common.util.AftermathEventUtil; +import com.pancake.surviving_the_aftermath.common.util.CodecUtils; +import com.pancake.surviving_the_aftermath.common.util.RandomUtils; +import com.pancake.surviving_the_aftermath.common.util.StructureUtils; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; @@ -44,7 +42,6 @@ public class BaseRaid extends BaseAftermath implements IRaid { public static final String IDENTIFIER = "raid"; public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - CodecUtils.UUID_CODEC.fieldOf("uuid").forGetter(BaseRaid::getUUID), AftermathState.CODEC.fieldOf("state").forGetter(BaseRaid::getState), BaseRaidModule.CODEC.fieldOf("module").forGetter(BaseRaid::getModule), CodecUtils.setOf(CodecUtils.UUID_CODEC).fieldOf("players").forGetter(BaseRaid::getPlayers), @@ -65,7 +62,7 @@ public class BaseRaid extends BaseAftermath implements IRaid { public BlockPos startPos; private int readyTime; public int rewardTime; - public BaseRaid(UUID uuid, AftermathState state, BaseRaidModule module, Set players, Float progressPercent, BlockPos startPos, Integer readyTime, Integer rewardTime, + public BaseRaid(AftermathState state, BaseRaidModule module, Set players, Float progressPercent, BlockPos startPos, Integer readyTime, Integer rewardTime, Set spawnPos, Set enemies, Integer currentWave, Integer totalEnemy) { super(state, module, players, progressPercent); this.startPos = startPos; @@ -75,7 +72,6 @@ public BaseRaid(UUID uuid, AftermathState state, BaseRaidModule module, Set validPlayer() { Predicate predicate = (Predicate) super.validPlayer(); - return predicate.and((player) -> Math.sqrt(player.distanceToSqr(Vec3.atCenterOf(startPos))) < getRadius()); + return predicate.and(player -> Math.sqrt(player.distanceToSqr(Vec3.atCenterOf(startPos))) < getRadius()); } @Override @@ -313,7 +309,7 @@ public BlockPos getStartPos() { public int getRadius() { return 50; } - private int getReadyTime() { + public int getReadyTime() { return readyTime; } @@ -340,4 +336,9 @@ public int getCurrentWave() { public int getTotalEnemy() { return totalEnemy; } + + @FunctionalInterface + public interface SpawnPosHandler { + void handleSpawnPos(Level level, BlockPos pos); + } } \ No newline at end of file diff --git a/src/main/java/com/pancake/surviving_the_aftermath/common/raid/NetherRaid.java b/src/main/java/com/pancake/surviving_the_aftermath/common/raid/NetherRaid.java index 0e0baca..c9a988c 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/common/raid/NetherRaid.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/raid/NetherRaid.java @@ -1,12 +1,16 @@ package com.pancake.surviving_the_aftermath.common.raid; import com.google.common.collect.ImmutableList; -import com.pancake.surviving_the_aftermath.SurvivingTheAftermath; +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; import com.pancake.surviving_the_aftermath.api.AftermathState; +import com.pancake.surviving_the_aftermath.api.IAftermath; import com.pancake.surviving_the_aftermath.api.PortalShapeAccessor; +import com.pancake.surviving_the_aftermath.common.init.ModAftermathModule; import com.pancake.surviving_the_aftermath.common.init.ModStructures; import com.pancake.surviving_the_aftermath.common.raid.module.BaseRaidModule; import com.pancake.surviving_the_aftermath.common.structure.NetherRaidStructure; +import com.pancake.surviving_the_aftermath.common.util.CodecUtils; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.registries.Registries; @@ -31,11 +35,30 @@ import java.util.*; public class NetherRaid extends BaseRaid { - private static final ResourceLocation BARS_RESOURCE = SurvivingTheAftermath.asResource("textures/gui/nether_raid_bars.png"); + public static final ResourceLocation BARS_RESOURCE = new ResourceLocation("surviving_the_aftermath:textures/gui/nether_raid_bars.png"); public static final String IDENTIFIER = "nether_raid"; + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( + AftermathState.CODEC.fieldOf("state").forGetter(BaseRaid::getState), + BaseRaidModule.CODEC.fieldOf("module").forGetter(BaseRaid::getModule), + CodecUtils.setOf(CodecUtils.UUID_CODEC).fieldOf("players").forGetter(BaseRaid::getPlayers), + Codec.FLOAT.fieldOf("progressPercent").forGetter(BaseRaid::getProgressPercent), + BlockPos.CODEC.fieldOf("startPos").forGetter(BaseRaid::getStartPos), + Codec.INT.fieldOf("readyTime").forGetter(BaseRaid::getReadyTime), + Codec.INT.fieldOf("rewardTime").forGetter(BaseRaid::getRewardTime), + CodecUtils.setOf(BlockPos.CODEC).fieldOf("spawnPos").forGetter(BaseRaid::getSpawnPos), + CodecUtils.setOf(CodecUtils.UUID_CODEC).fieldOf("enemies").forGetter(BaseRaid::getEnemies), + Codec.INT.fieldOf("currentWave").forGetter(BaseRaid::getCurrentWave), + Codec.INT.fieldOf("totalEnemy").forGetter(BaseRaid::getTotalEnemy) + ).apply(instance, NetherRaid::new)); + + public NetherRaid(AftermathState state, BaseRaidModule module, Set players, Float progressPercent, BlockPos startPos, Integer readyTime, Integer rewardTime, Set spawnPos, Set enemies, Integer currentWave, Integer totalEnemy) { + super(state, module, players, progressPercent, startPos, readyTime, rewardTime, spawnPos, enemies, currentWave, totalEnemy); + } + private PortalShape portalShape; private Direction rightDir; + public NetherRaid(ServerLevel level, BlockPos startPos) { super(level, startPos); } @@ -146,4 +169,14 @@ public ResourceLocation getBarsResource() { public int[] getBarsOffset() { return new int[]{192,23,182,4,5,4}; } + + @Override + public Codec codec() { + return CODEC; + } + + @Override + public IAftermath type() { + return ModAftermathModule.NETHER_RAID.get(); + } } diff --git a/src/main/java/com/pancake/surviving_the_aftermath/util/AftermathEventUtil.java b/src/main/java/com/pancake/surviving_the_aftermath/common/util/AftermathEventUtil.java similarity index 98% rename from src/main/java/com/pancake/surviving_the_aftermath/util/AftermathEventUtil.java rename to src/main/java/com/pancake/surviving_the_aftermath/common/util/AftermathEventUtil.java index 61558f5..e9ba590 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/util/AftermathEventUtil.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/util/AftermathEventUtil.java @@ -1,4 +1,4 @@ -package com.pancake.surviving_the_aftermath.util; +package com.pancake.surviving_the_aftermath.common.util; import com.pancake.surviving_the_aftermath.api.AftermathState; import com.pancake.surviving_the_aftermath.api.IAftermath; diff --git a/src/main/java/com/pancake/surviving_the_aftermath/util/CodecUtils.java b/src/main/java/com/pancake/surviving_the_aftermath/common/util/CodecUtils.java similarity index 97% rename from src/main/java/com/pancake/surviving_the_aftermath/util/CodecUtils.java rename to src/main/java/com/pancake/surviving_the_aftermath/common/util/CodecUtils.java index 2955cd3..de929e9 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/util/CodecUtils.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/util/CodecUtils.java @@ -1,4 +1,4 @@ -package com.pancake.surviving_the_aftermath.util; +package com.pancake.surviving_the_aftermath.common.util; import com.mojang.serialization.Codec; diff --git a/src/main/java/com/pancake/surviving_the_aftermath/util/RandomUtils.java b/src/main/java/com/pancake/surviving_the_aftermath/common/util/RandomUtils.java similarity index 94% rename from src/main/java/com/pancake/surviving_the_aftermath/util/RandomUtils.java rename to src/main/java/com/pancake/surviving_the_aftermath/common/util/RandomUtils.java index 638d4bd..4160e1b 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/util/RandomUtils.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/util/RandomUtils.java @@ -1,4 +1,4 @@ -package com.pancake.surviving_the_aftermath.util; +package com.pancake.surviving_the_aftermath.common.util; import java.util.Collection; import java.util.List; diff --git a/src/main/java/com/pancake/surviving_the_aftermath/util/RegistryUtil.java b/src/main/java/com/pancake/surviving_the_aftermath/common/util/RegistryUtil.java similarity index 97% rename from src/main/java/com/pancake/surviving_the_aftermath/util/RegistryUtil.java rename to src/main/java/com/pancake/surviving_the_aftermath/common/util/RegistryUtil.java index 068765b..66baded 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/util/RegistryUtil.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/util/RegistryUtil.java @@ -1,4 +1,4 @@ -package com.pancake.surviving_the_aftermath.util; +package com.pancake.surviving_the_aftermath.common.util; import com.mojang.logging.LogUtils; import net.minecraft.core.registries.Registries; diff --git a/src/main/java/com/pancake/surviving_the_aftermath/util/StructureUtils.java b/src/main/java/com/pancake/surviving_the_aftermath/common/util/StructureUtils.java similarity index 98% rename from src/main/java/com/pancake/surviving_the_aftermath/util/StructureUtils.java rename to src/main/java/com/pancake/surviving_the_aftermath/common/util/StructureUtils.java index f820334..5fbf4ff 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/util/StructureUtils.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/util/StructureUtils.java @@ -1,4 +1,4 @@ -package com.pancake.surviving_the_aftermath.util; +package com.pancake.surviving_the_aftermath.common.util; import com.google.common.collect.Lists; import net.minecraft.core.BlockPos; diff --git a/src/main/java/com/pancake/surviving_the_aftermath/compat/kubejs/ModKubeJSPlugin.java b/src/main/java/com/pancake/surviving_the_aftermath/compat/kubejs/ModKubeJSPlugin.java index e567df8..26ef0c4 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/compat/kubejs/ModKubeJSPlugin.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/compat/kubejs/ModKubeJSPlugin.java @@ -8,7 +8,7 @@ import com.pancake.surviving_the_aftermath.common.raid.BaseRaid; import com.pancake.surviving_the_aftermath.common.raid.module.BaseRaidModule; import com.pancake.surviving_the_aftermath.compat.kubejs.event.AftermathEvents; -import com.pancake.surviving_the_aftermath.util.StructureUtils; +import com.pancake.surviving_the_aftermath.common.util.StructureUtils; import dev.latvian.mods.kubejs.KubeJSPlugin; import dev.latvian.mods.kubejs.script.BindingsEvent; import net.minecraft.resources.ResourceLocation;