Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaoHuNao committed Jan 20, 2024
1 parent 6bd9ee9 commit 395b5db
Show file tree
Hide file tree
Showing 22 changed files with 66 additions and 112 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,8 +27,8 @@ public abstract class BaseAftermath implements IAftermath {

protected Set<UUID> 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();


Expand Down Expand Up @@ -76,7 +75,8 @@ public void updateProgress() {

public void updatePlayers() {
final Set<ServerPlayer> oldPlayers = Sets.newHashSet(progress.getPlayers());
final Set<ServerPlayer> newPlayers = Sets.newHashSet(level.getPlayers(this.validPlayer()));
List<ServerPlayer> players1 = level.getPlayers(this.validPlayer());
final Set<ServerPlayer> newPlayers = Sets.newHashSet(players1);
players.clear();
newPlayers.stream()
.filter(player -> !oldPlayers.contains(player))
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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);
});
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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<EntityType<?>> {
public static final String IDENTIFIER = "entity_type_weighted";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Item> {
public static final String IDENTIFIER = "item_weighted";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@
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;
import com.pancake.surviving_the_aftermath.api.module.IConditionModule;
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;
Expand All @@ -44,7 +42,6 @@
public class BaseRaid extends BaseAftermath implements IRaid {
public static final String IDENTIFIER = "raid";
public static final Codec<BaseRaid> 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),
Expand All @@ -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<UUID> players, Float progressPercent, BlockPos startPos, Integer readyTime, Integer rewardTime,
public BaseRaid(AftermathState state, BaseRaidModule module, Set<UUID> players, Float progressPercent, BlockPos startPos, Integer readyTime, Integer rewardTime,
Set<BlockPos> spawnPos, Set<UUID> enemies, Integer currentWave, Integer totalEnemy) {
super(state, module, players, progressPercent);
this.startPos = startPos;
Expand All @@ -75,7 +72,6 @@ public BaseRaid(UUID uuid, AftermathState state, BaseRaidModule module, Set<UUID
this.enemies = enemies;
this.currentWave = currentWave;
this.totalEnemy = totalEnemy;
init();
}

public BaseRaid(ServerLevel level,BlockPos startPos) {
Expand Down Expand Up @@ -270,7 +266,7 @@ public void ready(){
@Override
public Predicate<? super ServerPlayer> validPlayer() {
Predicate<ServerPlayer> predicate = (Predicate<ServerPlayer>) 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
Expand Down Expand Up @@ -313,7 +309,7 @@ public BlockPos getStartPos() {
public int getRadius() {
return 50;
}
private int getReadyTime() {
public int getReadyTime() {
return readyTime;
}

Expand All @@ -340,4 +336,9 @@ public int getCurrentWave() {
public int getTotalEnemy() {
return totalEnemy;
}

@FunctionalInterface
public interface SpawnPosHandler {
void handleSpawnPos(Level level, BlockPos pos);
}
}
Loading

0 comments on commit 395b5db

Please sign in to comment.