Skip to content

Commit

Permalink
Cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaoHuNao committed Jan 22, 2024
1 parent 1267cae commit bde77e1
Show file tree
Hide file tree
Showing 38 changed files with 42 additions and 124 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ mod_id=surviving_the_aftermath
# The human-readable display name for the mod.
mod_name=SurvivingTheAftermath
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=All-Rights-Reserved
mod_license=MIT
# The mod version. See https://semver.org/
mod_version=1.20.1-0.0.2
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nullable;
import java.util.Iterator;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
package com.pancake.surviving_the_aftermath.api;

import com.mojang.serialization.Codec;
import com.pancake.surviving_the_aftermath.api.base.BaseAftermathModule;
import com.pancake.surviving_the_aftermath.api.module.IAftermathModule;
import com.pancake.surviving_the_aftermath.common.init.ModuleRegistry;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;

import javax.annotation.Nullable;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.function.Predicate;
import java.util.function.Supplier;

public interface IAftermath extends IModule<IAftermath> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.pancake.surviving_the_aftermath.common.module.condition.PlayerConditionModule;
import com.pancake.surviving_the_aftermath.common.module.condition.StructureConditionModule;
import com.pancake.surviving_the_aftermath.common.module.weighted.ItemWeightedModule;
import com.pancake.surviving_the_aftermath.common.raid.module.BaseRaidModule;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
Expand Down Expand Up @@ -95,7 +94,7 @@ public BaseAftermathModule setConditions(List<IConditionModule> conditions) {
public static class Builder<T extends IAftermathModule> {
protected T module;
protected List<IConditionModule> conditions = Lists.newArrayList();
protected ItemWeightedModule rewards;
protected ItemWeightedModule rewards;
protected String name;
public Builder(String name) {
this.name = name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.function.Supplier;

public interface IAftermathModule extends IModule<IAftermathModule> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.pancake.surviving_the_aftermath.api.module;

import com.mojang.serialization.Codec;
import com.pancake.surviving_the_aftermath.api.ICodec;
import com.pancake.surviving_the_aftermath.api.IModule;
import com.pancake.surviving_the_aftermath.common.init.ModuleRegistry;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.pancake.surviving_the_aftermath.api.module;

import com.mojang.serialization.Codec;
import com.pancake.surviving_the_aftermath.api.ICodec;
import com.pancake.surviving_the_aftermath.api.IModule;
import com.pancake.surviving_the_aftermath.common.init.ModuleRegistry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.pancake.surviving_the_aftermath.SurvivingTheAftermath;
import com.pancake.surviving_the_aftermath.api.AftermathManager;
import com.pancake.surviving_the_aftermath.api.IAftermath;
import com.pancake.surviving_the_aftermath.api.module.IAftermathModule;
import com.pancake.surviving_the_aftermath.common.init.ModCapability;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
Expand All @@ -26,13 +25,12 @@ public class AftermathCap implements INBTSerializable<CompoundTag> {
@Override
public CompoundTag serializeNBT() {
CompoundTag compoundTag = new CompoundTag();
AFTERMATH_MANAGER.getAftermathMap().forEach((uuid, aftermath) -> {
IAftermath.CODEC.get().encodeStart(NbtOps.INSTANCE, aftermath)
.resultOrPartial(SurvivingTheAftermath.LOGGER::error)
.ifPresent(tag -> {
compoundTag.put(uuid.toString(), tag);
});
});
AFTERMATH_MANAGER.getAftermathMap().forEach((uuid, aftermath) ->
IAftermath.CODEC.get().encodeStart(NbtOps.INSTANCE, aftermath)
.resultOrPartial(SurvivingTheAftermath.LOGGER::error)
.ifPresent(tag -> {
compoundTag.put(uuid.toString(), tag);
}));
return compoundTag;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import java.util.Set;

public class AftermathStageCap implements INBTSerializable<ListTag> {
private Set<String> stages = Sets.newHashSet();
private final Set<String> stages = Sets.newHashSet();

@Override
public ListTag serializeNBT() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ public class AftermathConfig {
public static final ForgeConfigSpec SPEC;
public static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();

public static ForgeConfigSpec.BooleanValue enableMobBattleTrackerHighlight;
public static ForgeConfigSpec.BooleanValue enableMobBattleTrackerRestrictedRange;
public static ForgeConfigSpec.BooleanValue enableSpawnPointStructure;
public final static ForgeConfigSpec.BooleanValue enableMobBattleTrackerHighlight;
public final static ForgeConfigSpec.BooleanValue enableMobBattleTrackerRestrictedRange;
public final static ForgeConfigSpec.BooleanValue enableSpawnPointStructure;


static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,11 @@
import com.google.common.hash.Hashing;
import com.google.common.hash.HashingOutputStream;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter;
import com.mojang.serialization.Codec;
import com.mojang.serialization.DataResult;
import com.mojang.serialization.JsonOps;
import com.pancake.surviving_the_aftermath.SurvivingTheAftermath;
import com.pancake.surviving_the_aftermath.api.base.BaseAftermathModule;
import com.pancake.surviving_the_aftermath.api.module.IAftermathModule;
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.ModuleRegistry;
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.raid.module.BaseRaidModule;
import net.minecraft.Util;
import net.minecraft.data.CachedOutput;
import net.minecraft.data.DataProvider;
Expand All @@ -31,7 +22,6 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;

public abstract class AftermathModuleProviders<T extends BaseAftermathModule> implements DataProvider {
Expand All @@ -53,14 +43,13 @@ public AftermathModuleProviders(PackOutput output ,String locale) {
@NotNull
public CompletableFuture<?> run(@NotNull CachedOutput output) {
addModules();
return CompletableFuture.runAsync(() -> modules.forEach(module -> {
IAftermathModule.CODEC.get()
.encodeStart(JsonOps.INSTANCE, module)
.resultOrPartial(SurvivingTheAftermath.LOGGER::error)
.ifPresent(jsonElement -> {
Save(output, module, jsonElement);
});
}), Util.backgroundExecutor());
return CompletableFuture.runAsync(() -> modules.forEach(module ->
IAftermathModule.CODEC.get()
.encodeStart(JsonOps.INSTANCE, module)
.resultOrPartial(SurvivingTheAftermath.LOGGER::error)
.ifPresent(jsonElement -> {
Save(output, module, jsonElement);
})), Util.backgroundExecutor());
}

private void Save(CachedOutput output, T module, JsonElement jsonElement) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,21 @@
package com.pancake.surviving_the_aftermath.common.data.datagen.raid;

import com.google.common.collect.Lists;
import com.pancake.surviving_the_aftermath.SurvivingTheAftermath;
import com.pancake.surviving_the_aftermath.api.module.IEntityInfoModule;
import com.pancake.surviving_the_aftermath.common.data.datagen.AftermathModuleProviders;
import com.pancake.surviving_the_aftermath.common.init.ModStructures;
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.LevelStageConditionModule;
import com.pancake.surviving_the_aftermath.common.module.condition.PlayerStageConditionModule;
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.BaseRaid;
import com.pancake.surviving_the_aftermath.common.raid.NetherRaid;
import com.pancake.surviving_the_aftermath.common.raid.module.BaseRaidModule;
import net.minecraft.data.PackOutput;
import net.minecraft.util.random.WeightedEntry;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.item.Items;
import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.ArrayList;
import java.util.List;

public class RaidModuleProvider extends AftermathModuleProviders<BaseRaidModule> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import net.minecraft.util.profiling.ProfilerFiller;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;

import java.util.Map;

public class AftermathModuleLoader extends SimpleJsonResourceReloadListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.pancake.surviving_the_aftermath.api.IAftermath;
import com.pancake.surviving_the_aftermath.api.IAftermathEvent;
import com.pancake.surviving_the_aftermath.api.base.BaseAftermath;
import com.pancake.surviving_the_aftermath.api.base.BaseAftermathModule;
import com.pancake.surviving_the_aftermath.api.module.IAftermathModule;
import dev.latvian.mods.kubejs.event.EventJS;
import net.minecraft.server.level.ServerLevel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@

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;
import net.minecraftforge.client.event.CustomizeGuiOverlayEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

import java.util.Map;
import java.util.Optional;
import java.util.UUID;

@Mod.EventBusSubscriber(modid = SurvivingTheAftermath.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
public class ClientForgeEvent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;

import java.util.Collection;

@EventBusSubscriber(modid = SurvivingTheAftermath.MOD_ID, bus = Bus.FORGE)
public class ForgeEventSubscriber {
Expand Down Expand Up @@ -47,9 +46,7 @@ public static void onLevel(LevelEvent.Unload event) {
if (event.getLevel().isClientSide()) return;
AftermathManager.getInstance().getAftermathMap().values().stream()
.map(IAftermath::getTrackers)
.forEach(trackers -> {
trackers.forEach(ITracker::unregister);
});
.forEach(trackers -> trackers.forEach(ITracker::unregister));
AftermathManager.getInstance().getAftermathMap().clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.pancake.surviving_the_aftermath.common.event.AftermathEvent;
import com.pancake.surviving_the_aftermath.common.init.ModSoundEvents;
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 net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
Expand All @@ -16,7 +15,6 @@
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.monster.MagmaCube;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
Expand All @@ -27,7 +25,6 @@
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

import java.util.Objects;


@Mod.EventBusSubscriber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
import com.pancake.surviving_the_aftermath.common.config.AftermathConfig;
import com.pancake.surviving_the_aftermath.common.init.ModAftermathModule;
import com.pancake.surviving_the_aftermath.common.raid.BaseRaid;
import net.minecraft.nbt.Tag;
import net.minecraft.world.entity.LivingEntity;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;

import java.util.Set;
import java.util.UUID;


public class MobBattleTracker extends BaseTracker {
@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;

import java.util.Optional;

import java.util.UUID;

public class RaidMobBattleTracker extends BaseTracker {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
import com.google.common.collect.Sets;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import com.pancake.surviving_the_aftermath.api.AftermathManager;
import com.pancake.surviving_the_aftermath.api.IAftermath;
import com.pancake.surviving_the_aftermath.api.ITracker;
import com.pancake.surviving_the_aftermath.api.base.BaseTracker;
import com.pancake.surviving_the_aftermath.common.event.AftermathEvent;
import com.pancake.surviving_the_aftermath.common.init.ModAftermathModule;
import com.pancake.surviving_the_aftermath.common.init.ModMobEffects;
import com.pancake.surviving_the_aftermath.common.raid.BaseRaid;
import com.pancake.surviving_the_aftermath.common.raid.api.IRaid;
import com.pancake.surviving_the_aftermath.common.util.CodecUtils;
import com.pancake.surviving_the_aftermath.common.util.RandomUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,29 @@

public class ModuleRegistry {
public static final DeferredRegister<IAftermath> AFTERMATH = DeferredRegister.create(Keys.AFTERMATH, SurvivingTheAftermath.MOD_ID);
public static Supplier<IForgeRegistry<IAftermath>> AFTERMATH_REGISTRY = AFTERMATH.makeRegistry(RegistryBuilder::new);
public static final Supplier<IForgeRegistry<IAftermath>> AFTERMATH_REGISTRY = AFTERMATH.makeRegistry(RegistryBuilder::new);
public static final DeferredRegister<IAftermathModule> AFTERMATH_MODULE = DeferredRegister.create(Keys.AFTERMATH_MODULE, SurvivingTheAftermath.MOD_ID);
public static Supplier<IForgeRegistry<IAftermathModule>> AFTERMATH_MODULE_REGISTRY = AFTERMATH_MODULE.makeRegistry(RegistryBuilder::new);
public static final Supplier<IForgeRegistry<IAftermathModule>> AFTERMATH_MODULE_REGISTRY = AFTERMATH_MODULE.makeRegistry(RegistryBuilder::new);


public static final DeferredRegister<IEntityInfoModule> ENTITY_INFO_MODULE = DeferredRegister.create(Keys.ENTITY_INFO, SurvivingTheAftermath.MOD_ID);
public static Supplier<IForgeRegistry<IEntityInfoModule>> ENTITY_INFO_REGISTRY = ENTITY_INFO_MODULE.makeRegistry(RegistryBuilder::new);
public static final Supplier<IForgeRegistry<IEntityInfoModule>> ENTITY_INFO_REGISTRY = ENTITY_INFO_MODULE.makeRegistry(RegistryBuilder::new);

public static final DeferredRegister<IAmountModule> AMOUNT_MODULE = DeferredRegister.create(Keys.AMOUNT, SurvivingTheAftermath.MOD_ID);
public static Supplier<IForgeRegistry<IAmountModule>> AMOUNT_REGISTRY = AMOUNT_MODULE.makeRegistry(RegistryBuilder::new);
public static final Supplier<IForgeRegistry<IAmountModule>> AMOUNT_REGISTRY = AMOUNT_MODULE.makeRegistry(RegistryBuilder::new);

public static final DeferredRegister<IWeightedModule<?>> WEIGHTED_MODULE = DeferredRegister.create(Keys.WEIGHTED, SurvivingTheAftermath.MOD_ID);
public static Supplier<IForgeRegistry<IWeightedModule<?>>> WEIGHTED_REGISTRY = WEIGHTED_MODULE.makeRegistry(RegistryBuilder::new);
public static final Supplier<IForgeRegistry<IWeightedModule<?>>> WEIGHTED_REGISTRY = WEIGHTED_MODULE.makeRegistry(RegistryBuilder::new);

public static final DeferredRegister<IConditionModule> CONDITION_MODULE = DeferredRegister.create(Keys.CONDITION, SurvivingTheAftermath.MOD_ID);
public static Supplier<IForgeRegistry<IConditionModule>> CONDITION_REGISTRY = CONDITION_MODULE.makeRegistry(RegistryBuilder::new);
public static final Supplier<IForgeRegistry<IConditionModule>> CONDITION_REGISTRY = CONDITION_MODULE.makeRegistry(RegistryBuilder::new);

public static final DeferredRegister<IPredicateModule> PREDICATE_MODULE = DeferredRegister.create(Keys.PREDICATE, SurvivingTheAftermath.MOD_ID);
public static Supplier<IForgeRegistry<IPredicateModule>> PREDICATE_REGISTRY = PREDICATE_MODULE.makeRegistry(RegistryBuilder::new);
public static final Supplier<IForgeRegistry<IPredicateModule>> PREDICATE_REGISTRY = PREDICATE_MODULE.makeRegistry(RegistryBuilder::new);


public static final DeferredRegister<ITracker> TRACKER_MODULE = DeferredRegister.create(Keys.TRACKER, SurvivingTheAftermath.MOD_ID);
public static Supplier<IForgeRegistry<ITracker>> TRACKER_REGISTRY = TRACKER_MODULE.makeRegistry(RegistryBuilder::new);
public static final Supplier<IForgeRegistry<ITracker>> TRACKER_REGISTRY = TRACKER_MODULE.makeRegistry(RegistryBuilder::new);

public static void register(IEventBus bus) {
AFTERMATH.register(bus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import com.pancake.surviving_the_aftermath.api.module.IAmountModule;
import com.pancake.surviving_the_aftermath.common.init.ModAftermathModule;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.pancake.surviving_the_aftermath.common.module.condition;

import com.mojang.serialization.Codec;
import com.pancake.surviving_the_aftermath.api.module.IConditionModule;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;

public abstract class LevelConditionModule implements IConditionModule {
Expand Down
Loading

0 comments on commit bde77e1

Please sign in to comment.