Skip to content

Commit

Permalink
Some Work for 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
FirstMegaGame4 committed Sep 9, 2024
1 parent 6f63e9d commit b7e7f79
Show file tree
Hide file tree
Showing 50 changed files with 574 additions and 589 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_mappings=1.21+build.2
loader_version=0.15.11

# Mod Properties
mod_version=0.4.2-beta
mod_version=1.0.0
maven_group=com.mmodding.env.json
archives_base_name=env_json

Expand Down
9 changes: 3 additions & 6 deletions src/main/java/com/mmodding/env/json/api/EnvJsonVisitor.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.mmodding.env.json.api;

import com.mmodding.env.json.api.rule.SkyEnvJsonRule;
import com.mmodding.env.json.api.rule.VoidEnvJsonRule;
import com.mmodding.env.json.api.rule.WaterEnvJsonRule;
import it.unimi.dsi.fastutil.ints.Int2BooleanFunction;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.tag.TagKey;
Expand All @@ -27,9 +24,9 @@ public interface EnvJsonVisitor {

boolean applySubmerged(boolean submerged);

boolean applySky(SkyEnvJsonRule.Localization localization);
boolean applySky(RelativeLocation localization);

boolean applyWater(WaterEnvJsonRule.Localization localization);
boolean applyWater(RelativeLocation localization);

boolean applyVoid(VoidEnvJsonRule.Localization localization);
boolean applyVoid(RelativeLocation localization);
}
7 changes: 7 additions & 0 deletions src/main/java/com/mmodding/env/json/api/RelativeLocation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.mmodding.env.json.api;

public enum RelativeLocation {
BELOW,
AT,
ABOVE
}

This file was deleted.

This file was deleted.

65 changes: 0 additions & 65 deletions src/main/java/com/mmodding/env/json/api/rule/EnvJsonRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,70 +9,5 @@ static <T extends EnvJsonRule> T safeCast(EnvJsonRule rule, Class<T> type) {
return EnvJsonRuleImpl.safeCast(rule, type);
}

Type type();

boolean apply(EnvJsonVisitor visitor);

enum Type {

/**
* Represents a sequence of combined rules with the AND operator.
*/
SEQUENCE,

/**
* Represents a sequence of combined rules with the OR operator.
*/
ANY,

/**
* Reverses the rule.
*/
NOT,

/**
* Represents a dimension rule where the object should be.
*/
DIMENSION,

/**
* Represents a biome rule where the object should be.
*/
BIOME,

/**
* Represents an x coordinate comparator rule which is applied to the object.
*/
X_COORD,

/**
* Represents a y coordinate comparator rule which is applied to the object.
*/
Y_COORD,

/**
* Represents a z coordinate comparator rule which is applied to the object.
*/
Z_COORD,

/**
* Represents a rule checking if the object os surrounded by water.
*/
SUBMERGED,

/**
* Represents a rule checking if the object is below or above the sky limit.
*/
SKY,

/**
* Represents a rule checking if the object is below or above the water level.
*/
WATER,

/**
* Represents a rule checking if the object is below or above the void limit.
*/
VOID;
}
}
25 changes: 25 additions & 0 deletions src/main/java/com/mmodding/env/json/api/rule/EnvJsonRules.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.mmodding.env.json.api.rule;

import com.google.gson.JsonElement;
import com.mmodding.env.json.api.rule.parsing.EnvJsonRuleParser;
import com.mmodding.env.json.impl.rule.EnvJsonRulesImpl;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.ApiStatus;

@ApiStatus.NonExtendable
public final class EnvJsonRules {

public EnvJsonRules() {
throw new IllegalStateException("EnvJsonRules class only contains static definitions");
}

/**
* Allows to register a new {@link EnvJsonRuleParser} under an identifier
* @param identifier the identifier
* @param parser the parser
* @param <E> the class of the shape of the json element the parser should parse
*/
public static <E extends JsonElement> void register(Identifier identifier, EnvJsonRuleParser<E, ? extends EnvJsonRule> parser) {
EnvJsonRulesImpl.REGISTRY.put(identifier, parser);
}
}

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions src/main/java/com/mmodding/env/json/api/rule/SkyEnvJsonRule.java

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions src/main/java/com/mmodding/env/json/api/rule/VoidEnvJsonRule.java

This file was deleted.

12 changes: 0 additions & 12 deletions src/main/java/com/mmodding/env/json/api/rule/WaterEnvJsonRule.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.mmodding.env.json.api.rule.builtin;

import com.mmodding.env.json.api.rule.EnvJsonRule;
import org.jetbrains.annotations.ApiStatus;

import java.util.List;

/**
* Represents a sequence of combined rules with the OR operator.
*/
@ApiStatus.NonExtendable
public interface AnyEnvJsonRule extends EnvJsonRule {

List<EnvJsonRule> rules();
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package com.mmodding.env.json.api.rule;
package com.mmodding.env.json.api.rule.builtin;

import com.mmodding.env.json.api.rule.EnvJsonRule;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.world.biome.Biome;
import org.jetbrains.annotations.ApiStatus;

/**
* Represents a biome rule where the object should be.
*/
@ApiStatus.NonExtendable
public interface BiomeEnvJsonRule extends EnvJsonRule {

RegistryKey<Biome> biome();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package com.mmodding.env.json.api.rule;
package com.mmodding.env.json.api.rule.builtin;

import com.mmodding.env.json.impl.rule.CoordEnvJsonRuleImpl;
import com.mmodding.env.json.api.rule.EnvJsonRule;
import com.mmodding.env.json.impl.rule.builtin.CoordEnvJsonRuleImpl;
import org.jetbrains.annotations.ApiStatus;

import java.util.function.BiFunction;

/**
* Represents a coordinate comparator rule which is applied to the object.
*/
@ApiStatus.NonExtendable
public interface CoordEnvJsonRule extends EnvJsonRule {

Coord coord();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.mmodding.env.json.api.rule.builtin;

import com.mmodding.env.json.api.rule.EnvJsonRule;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.world.World;
import org.jetbrains.annotations.ApiStatus;

/**
* Represents a dimension rule where the object should be.
*/
@ApiStatus.NonExtendable
public interface DimensionEnvJsonRule extends EnvJsonRule {

/**
* If this method returns null, then {@link DimensionEnvJsonRule#tag()} must return a nonnull value.
*/
RegistryKey<World> dimension();

/**
* If this method returns null, then {@link DimensionEnvJsonRule#dimension()} must return a nonnull value.
*/
TagKey<World> tag();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.mmodding.env.json.api.rule.builtin;

import com.mmodding.env.json.api.rule.EnvJsonRule;
import org.jetbrains.annotations.ApiStatus;

/**
* Reverses the rule.
*/
@ApiStatus.NonExtendable
public interface NotEnvJsonRule extends EnvJsonRule {

EnvJsonRule rule();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.mmodding.env.json.api.rule.builtin;

import com.mmodding.env.json.api.rule.EnvJsonRule;
import org.jetbrains.annotations.ApiStatus;

import java.util.List;

/**
* Represents a sequence of combined rules with the AND operator.
*/
@ApiStatus.NonExtendable
public interface SequenceEnvJsonRule extends EnvJsonRule {

List<EnvJsonRule> rules();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.mmodding.env.json.api.rule.builtin;

import com.mmodding.env.json.api.RelativeLocation;
import com.mmodding.env.json.api.rule.EnvJsonRule;
import org.jetbrains.annotations.ApiStatus;

/**
* Represents a rule checking if the object is below or above the sky limit.
*/
@ApiStatus.NonExtendable
public interface SkyEnvJsonRule extends EnvJsonRule {

RelativeLocation location();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.mmodding.env.json.api.rule.builtin;

import com.mmodding.env.json.api.rule.EnvJsonRule;
import org.jetbrains.annotations.ApiStatus;

/**
* Represents a rule checking if the object is surrounded by water.
*/
@ApiStatus.NonExtendable
public interface SubmergedEnvJsonRule extends EnvJsonRule {

boolean submerged();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.mmodding.env.json.api.rule.builtin;

import com.mmodding.env.json.api.RelativeLocation;
import com.mmodding.env.json.api.rule.EnvJsonRule;
import org.jetbrains.annotations.ApiStatus;

/**
* Represents a rule checking if the object is below or above the void limit.
*/
@ApiStatus.NonExtendable
public interface VoidEnvJsonRule extends EnvJsonRule {

RelativeLocation location();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.mmodding.env.json.api.rule.builtin;

import com.mmodding.env.json.api.RelativeLocation;
import com.mmodding.env.json.api.rule.EnvJsonRule;
import org.jetbrains.annotations.ApiStatus;

/**
* Represents a rule checking if the object is below or above the water level.
*/
@ApiStatus.NonExtendable
public interface WaterEnvJsonRule extends EnvJsonRule {

RelativeLocation location();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.mmodding.env.json.api.rule.parsing;

import com.google.gson.JsonElement;
import com.mmodding.env.json.api.rule.EnvJsonRule;

@FunctionalInterface
public interface EnvJsonRuleParser<E extends JsonElement, R extends EnvJsonRule> {

R parse(E element, ParserCallback callback);
}
Loading

0 comments on commit b7e7f79

Please sign in to comment.