diff --git a/src/main/java/de/dafuqs/spectrum/api/predicate/entity/EntityFishingPredicate.java b/src/main/java/de/dafuqs/spectrum/api/predicate/entity/EntityFishingPredicate.java index 7e53dcb099..8ffa726e9f 100644 --- a/src/main/java/de/dafuqs/spectrum/api/predicate/entity/EntityFishingPredicate.java +++ b/src/main/java/de/dafuqs/spectrum/api/predicate/entity/EntityFishingPredicate.java @@ -1,8 +1,7 @@ package de.dafuqs.spectrum.api.predicate.entity; import com.google.gson.*; -import de.dafuqs.spectrum.api.predicate.block.LightPredicate; -import de.dafuqs.spectrum.api.predicate.block.*; +import de.dafuqs.spectrum.api.predicate.world.LightPredicate; import de.dafuqs.spectrum.api.predicate.world.*; import net.minecraft.predicate.*; import net.minecraft.server.world.*; diff --git a/src/main/java/de/dafuqs/spectrum/api/predicate/block/BiomePredicate.java b/src/main/java/de/dafuqs/spectrum/api/predicate/world/BiomePredicate.java similarity index 97% rename from src/main/java/de/dafuqs/spectrum/api/predicate/block/BiomePredicate.java rename to src/main/java/de/dafuqs/spectrum/api/predicate/world/BiomePredicate.java index 0f47a12daf..3f02e3c1bb 100644 --- a/src/main/java/de/dafuqs/spectrum/api/predicate/block/BiomePredicate.java +++ b/src/main/java/de/dafuqs/spectrum/api/predicate/world/BiomePredicate.java @@ -1,4 +1,4 @@ -package de.dafuqs.spectrum.api.predicate.block; +package de.dafuqs.spectrum.api.predicate.world; import com.google.gson.*; import net.minecraft.registry.*; diff --git a/src/main/java/de/dafuqs/spectrum/api/predicate/world/CommandType.java b/src/main/java/de/dafuqs/spectrum/api/predicate/world/CommandType.java index 662c1993bf..d427a090e4 100644 --- a/src/main/java/de/dafuqs/spectrum/api/predicate/world/CommandType.java +++ b/src/main/java/de/dafuqs/spectrum/api/predicate/world/CommandType.java @@ -20,7 +20,7 @@ public CommandType(Codec codec) { public boolean test(Config config, ServerWorld world, BlockPos pos) { AtomicBoolean passed = new AtomicBoolean(false); MinecraftServer minecraftServer = world.getServer(); - ServerCommandSource serverCommandSource = new ServerCommandSource(this, Vec3d.ofCenter(pos), Vec2f.ZERO, world, 2, "FusionShrine", world.getBlockState(pos).getBlock().getName(), minecraftServer, null) + ServerCommandSource serverCommandSource = new ServerCommandSource(this, Vec3d.ofCenter(pos), Vec2f.ZERO, world, 2, "SpectrumCommandWorldCondition", world.getBlockState(pos).getBlock().getName(), minecraftServer, null) .withReturnValueConsumer((successful, returnValue) -> { passed.set(returnValue > 0); }); diff --git a/src/main/java/de/dafuqs/spectrum/api/predicate/block/LightPredicate.java b/src/main/java/de/dafuqs/spectrum/api/predicate/world/LightPredicate.java similarity index 76% rename from src/main/java/de/dafuqs/spectrum/api/predicate/block/LightPredicate.java rename to src/main/java/de/dafuqs/spectrum/api/predicate/world/LightPredicate.java index 7cf51e0e50..88f27a1ce6 100644 --- a/src/main/java/de/dafuqs/spectrum/api/predicate/block/LightPredicate.java +++ b/src/main/java/de/dafuqs/spectrum/api/predicate/world/LightPredicate.java @@ -1,15 +1,12 @@ -package de.dafuqs.spectrum.api.predicate.block; +package de.dafuqs.spectrum.api.predicate.world; -import org.jetbrains.annotations.Nullable; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -import net.minecraft.predicate.NumberRange; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.JsonHelper; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.LightType; +import com.google.gson.*; +import net.minecraft.predicate.*; +import net.minecraft.server.world.*; +import net.minecraft.util.*; +import net.minecraft.util.math.*; +import net.minecraft.world.*; +import org.jetbrains.annotations.*; public class LightPredicate { public static final LightPredicate ANY = new LightPredicate(null, null); diff --git a/src/main/java/de/dafuqs/spectrum/api/predicate/world/MoonPhaseType.java b/src/main/java/de/dafuqs/spectrum/api/predicate/world/MoonPhaseType.java index d3a57eca88..872c820b54 100644 --- a/src/main/java/de/dafuqs/spectrum/api/predicate/world/MoonPhaseType.java +++ b/src/main/java/de/dafuqs/spectrum/api/predicate/world/MoonPhaseType.java @@ -12,15 +12,11 @@ public MoonPhaseType(Codec codec) { super(codec); } - Override - + @Override public boolean test(Config config, ServerWorld world, BlockPos pos) { return config.moonPhase == world.getMoonPhase(); } - - @ - public static class Config extends WorldConditionType.Config { public static final Codec CODEC = RecordCodecBuilder.create((instance) -> instance.group( diff --git a/src/main/java/de/dafuqs/spectrum/api/predicate/world/TimeOfDayType.java b/src/main/java/de/dafuqs/spectrum/api/predicate/world/TimeOfDayType.java index 817cfac608..90c548aceb 100644 --- a/src/main/java/de/dafuqs/spectrum/api/predicate/world/TimeOfDayType.java +++ b/src/main/java/de/dafuqs/spectrum/api/predicate/world/TimeOfDayType.java @@ -15,11 +15,10 @@ public TimeOfDayType(Codec codec) { super(codec); } - Override - + @Override public boolean test(Config config, ServerWorld world, BlockPos pos) { TimeHelper.TimeOfDay worldTimeOfDay = TimeHelper.getTimeOfDay(world); - switch (this.timeOfDay) { + switch (config.timeOfDay) { case DAY -> { return worldTimeOfDay.isDay(); } @@ -27,29 +26,28 @@ public boolean test(Config config, ServerWorld world, BlockPos pos) { return worldTimeOfDay.isNight(); } default -> { - return this.timeOfDay == worldTimeOfDay; + return config.timeOfDay == worldTimeOfDay; } } } - @ - public static class Config extends WorldConditionType.Config { + public static TimeOfDayType fromJson(JsonObject json) { + if (json == null || json.isJsonNull()) return ANY; + return new TimeOfDayType(TimeHelper.TimeOfDay.valueOf(json.get("time").getAsString().toUpperCase(Locale.ROOT))); + } + public static final Codec CODEC = RecordCodecBuilder.create((instance) -> instance.group( ).apply(instance, Config::new)); + public final TimeHelper.TimeOfDay timeOfDay; public Config(TimeHelper.TimeOfDay timeOfDay) { this.timeOfDay = timeOfDay; } - public static TimeOfDayType fromJson(JsonObject json) { - if (json == null || json.isJsonNull()) return ANY; - return new TimeOfDayType(TimeHelper.TimeOfDay.valueOf(json.get("time").getAsString().toUpperCase(Locale.ROOT))); - } - } } \ No newline at end of file diff --git a/src/main/java/de/dafuqs/spectrum/api/predicate/world/WeatherType.java b/src/main/java/de/dafuqs/spectrum/api/predicate/world/WeatherType.java index 0d2fdbc058..866c5616c2 100644 --- a/src/main/java/de/dafuqs/spectrum/api/predicate/world/WeatherType.java +++ b/src/main/java/de/dafuqs/spectrum/api/predicate/world/WeatherType.java @@ -14,8 +14,15 @@ public WeatherType(Codec codec) { super(codec); } - Override + public enum WeatherCondition { + CLEAR_SKY, + RAIN, // rain or thunder + STRICT_RAIN, // rain without thunder + THUNDER, + NOT_THUNDER + } + @Override public boolean test(Config config, ServerWorld world, BlockPos pos) { switch (config.weatherCondition) { case CLEAR_SKY -> { @@ -37,18 +44,12 @@ public boolean test(Config config, ServerWorld world, BlockPos pos) { return true; } - - public enum WeatherCondition { - CLEAR_SKY, - RAIN, // rain or thunder - STRICT_RAIN, // rain without thunder - THUNDER, - NOT_THUNDER - } - @ - public static class Config extends WorldConditionType.Config { + public static WeatherType fromJson(JsonObject json) { + return new WeatherType(WeatherCondition.valueOf(json.get("weather_condition").getAsString().toUpperCase(Locale.ROOT))); + } + public static final Codec CODEC = RecordCodecBuilder.create((instance) -> instance.group( ).apply(instance, Config::new)); @@ -58,10 +59,6 @@ public Config(WeatherCondition weatherCondition) { this.weatherCondition = weatherCondition; } - public static WeatherType fromJson(JsonObject json) { - return new WeatherType(WeatherCondition.valueOf(json.get("weather_condition").getAsString().toUpperCase(Locale.ROOT))); - } - } } \ No newline at end of file diff --git a/src/main/java/de/dafuqs/spectrum/api/predicate/world/WorldCondition.java b/src/main/java/de/dafuqs/spectrum/api/predicate/world/WorldCondition.java index 0280229d35..cb33b850c6 100644 --- a/src/main/java/de/dafuqs/spectrum/api/predicate/world/WorldCondition.java +++ b/src/main/java/de/dafuqs/spectrum/api/predicate/world/WorldCondition.java @@ -5,7 +5,7 @@ import net.minecraft.server.world.*; import net.minecraft.util.math.*; -public abstract class WorldCondition, SC extends WorldConditionType.Config> { +public class WorldCondition, SC extends WorldConditionType.Config> { public static final Codec> CODEC = SpectrumRegistries.WORLD_CONDITION_TYPE.getCodec().dispatch((condition) -> condition.type, WorldConditionType::getCodec);