Compare commits
9 Commits
92b9438253
...
v1.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3f3a23c42 | ||
|
|
6b558f34b4 | ||
|
|
0a0333faed | ||
|
|
a88ac00cde | ||
|
|
8d4903e1f5 | ||
|
|
c2e58fbf0e | ||
|
|
f8e58cc2f1 | ||
|
|
08cba8216a | ||
|
|
b4c09a194e |
2
.github/workflows/build.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
|||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
|
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: gradle/actions/setup-gradle@v4
|
uses: gradle/actions/setup-gradle@v3
|
||||||
|
|
||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
run: ./gradlew build
|
run: ./gradlew build
|
||||||
@@ -43,7 +43,7 @@ mod包名为com.le.teleportmirror 。
|
|||||||
### 永久回城魔镜
|
### 永久回城魔镜
|
||||||
潜影壳 紫颂果 潜影壳
|
潜影壳 紫颂果 潜影壳
|
||||||
末影珍珠 高级回城魔镜 末影珍珠
|
末影珍珠 高级回城魔镜 末影珍珠
|
||||||
潜影壳 烈焰棒 潜影壳
|
潜影壳 回响碎片 潜影壳
|
||||||
|
|
||||||
## 传送魔镜
|
## 传送魔镜
|
||||||
### 初级传送魔镜
|
### 初级传送魔镜
|
||||||
@@ -64,7 +64,7 @@ mod包名为com.le.teleportmirror 。
|
|||||||
### 永久传送魔镜
|
### 永久传送魔镜
|
||||||
潜影壳 紫颂果 潜影壳
|
潜影壳 紫颂果 潜影壳
|
||||||
末影珍珠 高级传送魔镜 末影珍珠
|
末影珍珠 高级传送魔镜 末影珍珠
|
||||||
潜影壳 烈焰棒 潜影壳
|
潜影壳 回响碎片 潜影壳
|
||||||
|
|
||||||
# 五、特殊机制
|
# 五、特殊机制
|
||||||
待定(保留接口,暂时不实装):一次性魔镜:低成本、低副作用(例如红石+青金石合成),用后即毁。
|
待定(保留接口,暂时不实装):一次性魔镜:低成本、低副作用(例如红石+青金石合成),用后即毁。
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ mod_name=Teleport Mirror
|
|||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=MIT
|
mod_license=MIT
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
mod_version=1.0.0
|
mod_version=1.0.2
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||||
# This should match the base package used for the mod sources.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
|
|||||||
@@ -1,100 +1,137 @@
|
|||||||
package com.le.teleportmirror;
|
package com.le.teleportmirror;
|
||||||
|
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.neoforged.neoforge.common.ModConfigSpec;
|
import net.neoforged.neoforge.common.ModConfigSpec;
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
private static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder();
|
private static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder();
|
||||||
|
|
||||||
|
// ==================== General ====================
|
||||||
|
|
||||||
public static final ModConfigSpec.IntValue COOLDOWN_SECONDS = BUILDER
|
public static final ModConfigSpec.IntValue COOLDOWN_SECONDS = BUILDER
|
||||||
.comment("Cooldown in seconds between mirror uses")
|
.comment("Cooldown in seconds between mirror uses")
|
||||||
.defineInRange("cooldownSeconds", 60, 0, Integer.MAX_VALUE);
|
.defineInRange("cooldownSeconds", 60, 0, Integer.MAX_VALUE);
|
||||||
|
|
||||||
public static final ModConfigSpec.IntValue CHARGE_TICKS = BUILDER
|
public static final ModConfigSpec.IntValue CHARGE_TICKS = BUILDER
|
||||||
.comment("Number of ticks required to charge the mirror (20 ticks = 1 second)")
|
.comment("Ticks required to charge the mirror (20 ticks = 1 second)")
|
||||||
.defineInRange("chargeTicks", 40, 1, Integer.MAX_VALUE);
|
.defineInRange("chargeTicks", 40, 1, Integer.MAX_VALUE);
|
||||||
|
|
||||||
|
// ==================== Cross-Dimension ====================
|
||||||
|
|
||||||
public static final ModConfigSpec.BooleanValue ALLOW_CROSS_DIMENSION_BASIC = BUILDER
|
public static final ModConfigSpec.BooleanValue ALLOW_CROSS_DIMENSION_BASIC = BUILDER
|
||||||
.comment("Allow Basic tier mirrors to teleport across dimensions")
|
.comment("Allow Basic mirrors to teleport across dimensions")
|
||||||
.define("allowCrossDimension.basic", false);
|
.define("allowCrossDimension.basic", false);
|
||||||
|
|
||||||
public static final ModConfigSpec.BooleanValue ALLOW_CROSS_DIMENSION_INTERMEDIATE = BUILDER
|
public static final ModConfigSpec.BooleanValue ALLOW_CROSS_DIMENSION_INTERMEDIATE = BUILDER
|
||||||
.comment("Allow Intermediate tier mirrors to teleport across dimensions")
|
.comment("Allow Intermediate mirrors to teleport across dimensions")
|
||||||
.define("allowCrossDimension.intermediate", false);
|
.define("allowCrossDimension.intermediate", false);
|
||||||
|
|
||||||
public static final ModConfigSpec.BooleanValue ALLOW_CROSS_DIMENSION_ADVANCED = BUILDER
|
public static final ModConfigSpec.BooleanValue ALLOW_CROSS_DIMENSION_ADVANCED = BUILDER
|
||||||
.comment("Allow Advanced tier mirrors to teleport across dimensions")
|
.comment("Allow Advanced mirrors to teleport across dimensions")
|
||||||
.define("allowCrossDimension.advanced", true);
|
.define("allowCrossDimension.advanced", true);
|
||||||
|
|
||||||
public static final ModConfigSpec.BooleanValue ALLOW_CROSS_DIMENSION_PERMANENT = BUILDER
|
public static final ModConfigSpec.BooleanValue ALLOW_CROSS_DIMENSION_PERMANENT = BUILDER
|
||||||
.comment("Allow Permanent tier mirrors to teleport across dimensions")
|
.comment("Allow Permanent mirrors to teleport across dimensions")
|
||||||
.define("allowCrossDimension.permanent", true);
|
.define("allowCrossDimension.permanent", true);
|
||||||
|
|
||||||
|
// ==================== Teleport Restrictions ====================
|
||||||
|
|
||||||
public static final ModConfigSpec.BooleanValue TELEPORT_TEAM_ONLY = BUILDER
|
public static final ModConfigSpec.BooleanValue TELEPORT_TEAM_ONLY = BUILDER
|
||||||
.comment("Teleport Mirror can only target players on the same team")
|
.comment("Teleport Mirror can only target players with the same team name (tag)")
|
||||||
.define("teleportTeamOnly", true);
|
.define("teleportTeamOnly", false);
|
||||||
|
|
||||||
|
// ==================== Durability ====================
|
||||||
|
|
||||||
public static final ModConfigSpec.IntValue BASIC_DURABILITY = BUILDER
|
public static final ModConfigSpec.IntValue BASIC_DURABILITY = BUILDER
|
||||||
.comment("Durability for Basic tier mirrors")
|
.comment("Durability of Basic tier mirrors")
|
||||||
.defineInRange("basicDurability", 10, 0, Integer.MAX_VALUE);
|
.defineInRange("durability.basic", 10, 0, Integer.MAX_VALUE);
|
||||||
|
|
||||||
public static final ModConfigSpec.IntValue INTERMEDIATE_DURABILITY = BUILDER
|
public static final ModConfigSpec.IntValue INTERMEDIATE_DURABILITY = BUILDER
|
||||||
.comment("Durability for Intermediate tier mirrors")
|
.comment("Durability of Intermediate tier mirrors")
|
||||||
.defineInRange("intermediateDurability", 50, 0, Integer.MAX_VALUE);
|
.defineInRange("durability.intermediate", 50, 0, Integer.MAX_VALUE);
|
||||||
|
|
||||||
public static final ModConfigSpec.IntValue ADVANCED_DURABILITY = BUILDER
|
public static final ModConfigSpec.IntValue ADVANCED_DURABILITY = BUILDER
|
||||||
.comment("Durability for Advanced tier mirrors")
|
.comment("Durability of Advanced tier mirrors")
|
||||||
.defineInRange("advancedDurability", 100, 0, Integer.MAX_VALUE);
|
.defineInRange("durability.advanced", 100, 0, Integer.MAX_VALUE);
|
||||||
|
|
||||||
public static final ModConfigSpec.BooleanValue HALVE_FOOD_BASIC = BUILDER
|
// Permanent tier has no configurable durability (unlimited)
|
||||||
.comment("Halve food when using Basic tier mirrors")
|
|
||||||
.define("halveFood.basic", true);
|
|
||||||
|
|
||||||
public static final ModConfigSpec.BooleanValue HALVE_FOOD_INTERMEDIATE = BUILDER
|
// ==================== Food Cost ====================
|
||||||
.comment("Halve food when using Intermediate tier mirrors")
|
|
||||||
.define("halveFood.intermediate", true);
|
|
||||||
|
|
||||||
public static final ModConfigSpec.BooleanValue HALVE_FOOD_ADVANCED = BUILDER
|
// -- Basic --
|
||||||
.comment("Halve food when using Advanced tier mirrors")
|
public static final ModConfigSpec.ConfigValue<String> FOOD_LEVEL_BASIC = BUILDER
|
||||||
.define("halveFood.advanced", true);
|
.comment("Food level cost for Basic mirrors. \"50%\"=percentage, \"10\"=fixed, \"\"=none")
|
||||||
|
.define("foodCost.basic.foodLevel", "50%");
|
||||||
|
|
||||||
public static final ModConfigSpec.BooleanValue HALVE_FOOD_PERMANENT = BUILDER
|
public static final ModConfigSpec.ConfigValue<String> SATURATION_COST_BASIC = BUILDER
|
||||||
.comment("Halve food when using Permanent tier mirrors")
|
.comment("Saturation cost for Basic mirrors. \"50%\"=percentage, \"4.0\"=fixed, \"\"=none")
|
||||||
.define("halveFood.permanent", false);
|
.define("foodCost.basic.saturation", "50%");
|
||||||
|
|
||||||
|
// -- Intermediate --
|
||||||
|
public static final ModConfigSpec.ConfigValue<String> FOOD_LEVEL_INTERMEDIATE = BUILDER
|
||||||
|
.comment("Food level cost for Intermediate mirrors. \"50%\"=percentage, \"10\"=fixed, \"\"=none")
|
||||||
|
.define("foodCost.intermediate.foodLevel", "50%");
|
||||||
|
|
||||||
|
public static final ModConfigSpec.ConfigValue<String> SATURATION_COST_INTERMEDIATE = BUILDER
|
||||||
|
.comment("Saturation cost for Intermediate mirrors. \"50%\"=percentage, \"4.0\"=fixed, \"\"=none")
|
||||||
|
.define("foodCost.intermediate.saturation", "50%");
|
||||||
|
|
||||||
|
// -- Advanced --
|
||||||
|
public static final ModConfigSpec.ConfigValue<String> FOOD_LEVEL_ADVANCED = BUILDER
|
||||||
|
.comment("Food level cost for Advanced mirrors. \"50%\"=percentage, \"10\"=fixed, \"\"=none")
|
||||||
|
.define("foodCost.advanced.foodLevel", "50%");
|
||||||
|
|
||||||
|
public static final ModConfigSpec.ConfigValue<String> SATURATION_COST_ADVANCED = BUILDER
|
||||||
|
.comment("Saturation cost for Advanced mirrors. \"50%\"=percentage, \"4.0\"=fixed, \"\"=none")
|
||||||
|
.define("foodCost.advanced.saturation", "50%");
|
||||||
|
|
||||||
|
// -- Permanent --
|
||||||
|
public static final ModConfigSpec.ConfigValue<String> FOOD_LEVEL_PERMANENT = BUILDER
|
||||||
|
.comment("Food level cost for Permanent mirrors. \"50%\"=percentage, \"10\"=fixed, \"\"=none")
|
||||||
|
.define("foodCost.permanent.foodLevel", "");
|
||||||
|
|
||||||
|
public static final ModConfigSpec.ConfigValue<String> SATURATION_COST_PERMANENT = BUILDER
|
||||||
|
.comment("Saturation cost for Permanent mirrors. \"50%\"=percentage, \"4.0\"=fixed, \"\"=none")
|
||||||
|
.define("foodCost.permanent.saturation", "");
|
||||||
|
|
||||||
|
// ==================== Side Effects ====================
|
||||||
|
// Format per entry: "effect_id,dur_seconds,amplifier;..."
|
||||||
|
|
||||||
|
// -- Return Mirrors --
|
||||||
public static final ModConfigSpec.ConfigValue<String> EFFECTS_RETURN_BASIC = BUILDER
|
public static final ModConfigSpec.ConfigValue<String> EFFECTS_RETURN_BASIC = BUILDER
|
||||||
.comment("Effects for Basic Return Mirror. Format: \"effect_id,dur_sec,amplifier;...\"")
|
.comment("Side effects for Basic Return Mirror")
|
||||||
.define("effects.return.basic", "minecraft:nausea,10,0;minecraft:wither,5,0");
|
.define("effects.return.basic", "minecraft:nausea,10,0;minecraft:wither,5,0");
|
||||||
|
|
||||||
public static final ModConfigSpec.ConfigValue<String> EFFECTS_RETURN_INTERMEDIATE = BUILDER
|
public static final ModConfigSpec.ConfigValue<String> EFFECTS_RETURN_INTERMEDIATE = BUILDER
|
||||||
.comment("Effects for Intermediate Return Mirror. Format: \"effect_id,dur_sec,amplifier;...\"")
|
.comment("Side effects for Intermediate Return Mirror")
|
||||||
.define("effects.return.intermediate", "minecraft:nausea,5,0;minecraft:wither,3,0");
|
.define("effects.return.intermediate", "minecraft:nausea,5,0;minecraft:wither,3,0");
|
||||||
|
|
||||||
public static final ModConfigSpec.ConfigValue<String> EFFECTS_RETURN_ADVANCED = BUILDER
|
public static final ModConfigSpec.ConfigValue<String> EFFECTS_RETURN_ADVANCED = BUILDER
|
||||||
.comment("Effects for Advanced Return Mirror. Format: \"effect_id,dur_sec,amplifier;...\"")
|
.comment("Side effects for Advanced Return Mirror")
|
||||||
.define("effects.return.advanced", "minecraft:nausea,3,0");
|
.define("effects.return.advanced", "minecraft:nausea,3,0");
|
||||||
|
|
||||||
public static final ModConfigSpec.ConfigValue<String> EFFECTS_RETURN_PERMANENT = BUILDER
|
public static final ModConfigSpec.ConfigValue<String> EFFECTS_RETURN_PERMANENT = BUILDER
|
||||||
.comment("Effects for Permanent Return Mirror. Format: \"effect_id,dur_sec,amplifier;...\"")
|
.comment("Side effects for Permanent Return Mirror")
|
||||||
.define("effects.return.permanent", "");
|
.define("effects.return.permanent", "");
|
||||||
|
|
||||||
|
// -- Teleport Mirrors --
|
||||||
public static final ModConfigSpec.ConfigValue<String> EFFECTS_TELEPORT_BASIC = BUILDER
|
public static final ModConfigSpec.ConfigValue<String> EFFECTS_TELEPORT_BASIC = BUILDER
|
||||||
.comment("Effects for Basic Teleport Mirror. Format: \"effect_id,dur_sec,amplifier;...\"")
|
.comment("Side effects for Basic Teleport Mirror")
|
||||||
.define("effects.teleport.basic", "minecraft:nausea,10,0;minecraft:wither,5,0");
|
.define("effects.teleport.basic", "minecraft:nausea,10,0;minecraft:wither,5,0");
|
||||||
|
|
||||||
public static final ModConfigSpec.ConfigValue<String> EFFECTS_TELEPORT_INTERMEDIATE = BUILDER
|
public static final ModConfigSpec.ConfigValue<String> EFFECTS_TELEPORT_INTERMEDIATE = BUILDER
|
||||||
.comment("Effects for Intermediate Teleport Mirror. Format: \"effect_id,dur_sec,amplifier;...\"")
|
.comment("Side effects for Intermediate Teleport Mirror")
|
||||||
.define("effects.teleport.intermediate", "minecraft:nausea,5,0;minecraft:wither,3,0");
|
.define("effects.teleport.intermediate", "minecraft:nausea,5,0;minecraft:wither,3,0");
|
||||||
|
|
||||||
public static final ModConfigSpec.ConfigValue<String> EFFECTS_TELEPORT_ADVANCED = BUILDER
|
public static final ModConfigSpec.ConfigValue<String> EFFECTS_TELEPORT_ADVANCED = BUILDER
|
||||||
.comment("Effects for Advanced Teleport Mirror. Format: \"effect_id,dur_sec,amplifier;...\"")
|
.comment("Side effects for Advanced Teleport Mirror")
|
||||||
.define("effects.teleport.advanced", "minecraft:nausea,3,0");
|
.define("effects.teleport.advanced", "minecraft:nausea,3,0");
|
||||||
|
|
||||||
public static final ModConfigSpec.ConfigValue<String> EFFECTS_TELEPORT_PERMANENT = BUILDER
|
public static final ModConfigSpec.ConfigValue<String> EFFECTS_TELEPORT_PERMANENT = BUILDER
|
||||||
.comment("Effects for Permanent Teleport Mirror. Format: \"effect_id,dur_sec,amplifier;...\"")
|
.comment("Side effects for Permanent Teleport Mirror")
|
||||||
.define("effects.teleport.permanent", "");
|
.define("effects.teleport.permanent", "");
|
||||||
|
|
||||||
|
// ==================== Recipe Toggles ====================
|
||||||
|
|
||||||
public static final ModConfigSpec.BooleanValue ENABLE_BASIC_RECIPE = BUILDER
|
public static final ModConfigSpec.BooleanValue ENABLE_BASIC_RECIPE = BUILDER
|
||||||
.comment("Enable crafting recipe for Basic tier mirrors")
|
.comment("Enable crafting recipe for Basic tier mirrors")
|
||||||
.define("enableRecipe.basic", true);
|
.define("enableRecipe.basic", true);
|
||||||
@@ -111,36 +148,43 @@ public class Config {
|
|||||||
.comment("Enable crafting recipe for Permanent tier mirrors")
|
.comment("Enable crafting recipe for Permanent tier mirrors")
|
||||||
.define("enableRecipe.permanent", true);
|
.define("enableRecipe.permanent", true);
|
||||||
|
|
||||||
|
// ==================== Recipe Overrides ====================
|
||||||
|
// Format: "row1;row2;row3|key=item_id;..."
|
||||||
|
// Example: " C ;CGC; C |C=minecraft:copper_ingot;G=minecraft:glass_pane"
|
||||||
|
// Empty "" means use the default JSON recipe.
|
||||||
|
|
||||||
|
// -- Return Mirrors --
|
||||||
public static final ModConfigSpec.ConfigValue<String> RECIPE_OVERRIDE_RETURN_BASIC = BUILDER
|
public static final ModConfigSpec.ConfigValue<String> RECIPE_OVERRIDE_RETURN_BASIC = BUILDER
|
||||||
.comment("Override recipe for Basic Return Mirror. Format: \"row1;row2;row3|key=item_id;...\". Empty=use default.")
|
.comment("Override recipe for Basic Return Mirror. Empty = use default.")
|
||||||
.define("recipeOverride.return.basic", "");
|
.define("recipeOverride.return.basic", "");
|
||||||
|
|
||||||
public static final ModConfigSpec.ConfigValue<String> RECIPE_OVERRIDE_RETURN_INTERMEDIATE = BUILDER
|
public static final ModConfigSpec.ConfigValue<String> RECIPE_OVERRIDE_RETURN_INTERMEDIATE = BUILDER
|
||||||
.comment("Override recipe for Intermediate Return Mirror.")
|
.comment("Override recipe for Intermediate Return Mirror. Empty = use default.")
|
||||||
.define("recipeOverride.return.intermediate", "");
|
.define("recipeOverride.return.intermediate", "");
|
||||||
|
|
||||||
public static final ModConfigSpec.ConfigValue<String> RECIPE_OVERRIDE_RETURN_ADVANCED = BUILDER
|
public static final ModConfigSpec.ConfigValue<String> RECIPE_OVERRIDE_RETURN_ADVANCED = BUILDER
|
||||||
.comment("Override recipe for Advanced Return Mirror.")
|
.comment("Override recipe for Advanced Return Mirror. Empty = use default.")
|
||||||
.define("recipeOverride.return.advanced", "");
|
.define("recipeOverride.return.advanced", "");
|
||||||
|
|
||||||
public static final ModConfigSpec.ConfigValue<String> RECIPE_OVERRIDE_RETURN_PERMANENT = BUILDER
|
public static final ModConfigSpec.ConfigValue<String> RECIPE_OVERRIDE_RETURN_PERMANENT = BUILDER
|
||||||
.comment("Override recipe for Permanent Return Mirror.")
|
.comment("Override recipe for Permanent Return Mirror. Empty = use default.")
|
||||||
.define("recipeOverride.return.permanent", "");
|
.define("recipeOverride.return.permanent", "");
|
||||||
|
|
||||||
|
// -- Teleport Mirrors --
|
||||||
public static final ModConfigSpec.ConfigValue<String> RECIPE_OVERRIDE_TELEPORT_BASIC = BUILDER
|
public static final ModConfigSpec.ConfigValue<String> RECIPE_OVERRIDE_TELEPORT_BASIC = BUILDER
|
||||||
.comment("Override recipe for Basic Teleport Mirror.")
|
.comment("Override recipe for Basic Teleport Mirror. Empty = use default.")
|
||||||
.define("recipeOverride.teleport.basic", "");
|
.define("recipeOverride.teleport.basic", "");
|
||||||
|
|
||||||
public static final ModConfigSpec.ConfigValue<String> RECIPE_OVERRIDE_TELEPORT_INTERMEDIATE = BUILDER
|
public static final ModConfigSpec.ConfigValue<String> RECIPE_OVERRIDE_TELEPORT_INTERMEDIATE = BUILDER
|
||||||
.comment("Override recipe for Intermediate Teleport Mirror.")
|
.comment("Override recipe for Intermediate Teleport Mirror. Empty = use default.")
|
||||||
.define("recipeOverride.teleport.intermediate", "");
|
.define("recipeOverride.teleport.intermediate", "");
|
||||||
|
|
||||||
public static final ModConfigSpec.ConfigValue<String> RECIPE_OVERRIDE_TELEPORT_ADVANCED = BUILDER
|
public static final ModConfigSpec.ConfigValue<String> RECIPE_OVERRIDE_TELEPORT_ADVANCED = BUILDER
|
||||||
.comment("Override recipe for Advanced Teleport Mirror.")
|
.comment("Override recipe for Advanced Teleport Mirror. Empty = use default.")
|
||||||
.define("recipeOverride.teleport.advanced", "");
|
.define("recipeOverride.teleport.advanced", "");
|
||||||
|
|
||||||
public static final ModConfigSpec.ConfigValue<String> RECIPE_OVERRIDE_TELEPORT_PERMANENT = BUILDER
|
public static final ModConfigSpec.ConfigValue<String> RECIPE_OVERRIDE_TELEPORT_PERMANENT = BUILDER
|
||||||
.comment("Override recipe for Permanent Teleport Mirror.")
|
.comment("Override recipe for Permanent Teleport Mirror. Empty = use default.")
|
||||||
.define("recipeOverride.teleport.permanent", "");
|
.define("recipeOverride.teleport.permanent", "");
|
||||||
|
|
||||||
static final ModConfigSpec SPEC = BUILDER.build();
|
static final ModConfigSpec SPEC = BUILDER.build();
|
||||||
|
|||||||
@@ -191,12 +191,21 @@ public class MirrorItem extends Item {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldHalveFood() {
|
private String getFoodLevelConfig() {
|
||||||
return switch (tier) {
|
return switch (tier) {
|
||||||
case BASIC -> Config.HALVE_FOOD_BASIC.get();
|
case BASIC -> Config.FOOD_LEVEL_BASIC.get();
|
||||||
case INTERMEDIATE -> Config.HALVE_FOOD_INTERMEDIATE.get();
|
case INTERMEDIATE -> Config.FOOD_LEVEL_INTERMEDIATE.get();
|
||||||
case ADVANCED -> Config.HALVE_FOOD_ADVANCED.get();
|
case ADVANCED -> Config.FOOD_LEVEL_ADVANCED.get();
|
||||||
case PERMANENT -> Config.HALVE_FOOD_PERMANENT.get();
|
case PERMANENT -> Config.FOOD_LEVEL_PERMANENT.get();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSaturationConfig() {
|
||||||
|
return switch (tier) {
|
||||||
|
case BASIC -> Config.SATURATION_COST_BASIC.get();
|
||||||
|
case INTERMEDIATE -> Config.SATURATION_COST_INTERMEDIATE.get();
|
||||||
|
case ADVANCED -> Config.SATURATION_COST_ADVANCED.get();
|
||||||
|
case PERMANENT -> Config.SATURATION_COST_PERMANENT.get();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,15 +242,34 @@ public class MirrorItem extends Item {
|
|||||||
player.addEffect(new MobEffectInstance(holder, durationSeconds * 20, amplifier)));
|
player.addEffect(new MobEffectInstance(holder, durationSeconds * 20, amplifier)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldHalveFood()) {
|
applyFoodCost(player);
|
||||||
halveFood(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void halveFood(Player player) {
|
private void applyFoodCost(Player player) {
|
||||||
FoodData foodData = player.getFoodData();
|
FoodData foodData = player.getFoodData();
|
||||||
foodData.setFoodLevel(Math.max(1, foodData.getFoodLevel() / 2));
|
applyCostValue(getFoodLevelConfig(), (float) foodData.getFoodLevel(), newVal -> foodData.setFoodLevel(newVal.intValue()));
|
||||||
foodData.setSaturation(0);
|
applyCostValue(getSaturationConfig(), foodData.getSaturationLevel(), newVal -> foodData.setSaturation(newVal));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyCostValue(String config, float currentValue, java.util.function.Consumer<Float> setter) {
|
||||||
|
if (config == null || config.isBlank()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String trimmed = config.trim();
|
||||||
|
if (trimmed.endsWith("%")) {
|
||||||
|
String pctStr = trimmed.substring(0, trimmed.length() - 1);
|
||||||
|
try {
|
||||||
|
float percentage = Float.parseFloat(pctStr) / 100f;
|
||||||
|
setter.accept(Math.max(0, currentValue * (1f - percentage)));
|
||||||
|
} catch (NumberFormatException ignored) {
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
float cost = Float.parseFloat(trimmed);
|
||||||
|
setter.accept(Math.max(0, currentValue - cost));
|
||||||
|
} catch (NumberFormatException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.le.teleportmirror;
|
package com.le.teleportmirror;
|
||||||
|
|
||||||
import com.le.teleportmirror.screen.PlayerSelectionScreen;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
@@ -44,8 +42,13 @@ public class MirrorNetwork {
|
|||||||
if (onlinePlayer.getUUID().equals(player.getUUID())) {
|
if (onlinePlayer.getUUID().equals(player.getUUID())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (teamOnly && player.getTeam() != null) {
|
if (teamOnly) {
|
||||||
if (onlinePlayer.getTeam() != player.getTeam()) {
|
var playerTeam = player.getTeam();
|
||||||
|
var targetTeam = onlinePlayer.getTeam();
|
||||||
|
if (playerTeam == null || targetTeam == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!playerTeam.getName().equals(targetTeam.getName())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,9 +61,13 @@ public class MirrorNetwork {
|
|||||||
|
|
||||||
private static void handleOpenSelection(OpenPlayerSelectionPayload payload, IPayloadContext context) {
|
private static void handleOpenSelection(OpenPlayerSelectionPayload payload, IPayloadContext context) {
|
||||||
context.enqueueWork(() -> {
|
context.enqueueWork(() -> {
|
||||||
Minecraft client = Minecraft.getInstance();
|
try {
|
||||||
MirrorTier tier = MirrorTier.valueOf(payload.tierName.toUpperCase());
|
Class<?> clientHandlerClass = Class.forName("com.le.teleportmirror.MirrorNetworkClient");
|
||||||
client.setScreen(new PlayerSelectionScreen(payload.playerNames, payload.playerUuids, tier));
|
clientHandlerClass.getMethod("openPlayerSelection", OpenPlayerSelectionPayload.class)
|
||||||
|
.invoke(null, payload);
|
||||||
|
} catch (ReflectiveOperationException e) {
|
||||||
|
throw new RuntimeException("Failed to open player selection screen", e);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
16
src/main/java/com/le/teleportmirror/MirrorNetworkClient.java
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package com.le.teleportmirror;
|
||||||
|
|
||||||
|
import com.le.teleportmirror.screen.PlayerSelectionScreen;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.neoforged.api.distmarker.Dist;
|
||||||
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public class MirrorNetworkClient {
|
||||||
|
|
||||||
|
public static void openPlayerSelection(MirrorNetwork.OpenPlayerSelectionPayload payload) {
|
||||||
|
Minecraft client = Minecraft.getInstance();
|
||||||
|
MirrorTier tier = MirrorTier.valueOf(payload.tierName().toUpperCase());
|
||||||
|
client.setScreen(new PlayerSelectionScreen(payload.playerNames(), payload.playerUuids(), tier));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -90,7 +90,14 @@ public class PlayerSelectionScreen extends Screen {
|
|||||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
|
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
|
||||||
guiGraphics.fill(0, 0, this.width, this.height, 0xC0101010);
|
guiGraphics.fill(0, 0, this.width, this.height, 0xC0101010);
|
||||||
guiGraphics.drawCenteredString(this.font, this.title, this.width / 2, 12, 0xFFFFFF);
|
guiGraphics.drawCenteredString(this.font, this.title, this.width / 2, 12, 0xFFFFFF);
|
||||||
super.render(guiGraphics, mouseX, mouseY, partialTick);
|
|
||||||
|
for (var renderable : this.renderables) {
|
||||||
|
renderable.render(guiGraphics, mouseX, mouseY, partialTick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderBackground(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 401 B |
|
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 397 B |
|
Before Width: | Height: | Size: 144 B After Width: | Height: | Size: 360 B |
|
Before Width: | Height: | Size: 144 B After Width: | Height: | Size: 276 B |
|
Before Width: | Height: | Size: 144 B After Width: | Height: | Size: 403 B |
|
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 380 B |
|
Before Width: | Height: | Size: 144 B After Width: | Height: | Size: 439 B |
|
Before Width: | Height: | Size: 144 B After Width: | Height: | Size: 442 B |
@@ -10,7 +10,7 @@
|
|||||||
"C": { "item": "minecraft:chorus_fruit" },
|
"C": { "item": "minecraft:chorus_fruit" },
|
||||||
"E": { "item": "minecraft:ender_pearl" },
|
"E": { "item": "minecraft:ender_pearl" },
|
||||||
"R": { "item": "teleportmirror:advanced_return_mirror" },
|
"R": { "item": "teleportmirror:advanced_return_mirror" },
|
||||||
"B": { "item": "minecraft:blaze_rod" }
|
"B": { "item": "minecraft:echo_shard" }
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
"id": "teleportmirror:permanent_return_mirror",
|
"id": "teleportmirror:permanent_return_mirror",
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"C": { "item": "minecraft:chorus_fruit" },
|
"C": { "item": "minecraft:chorus_fruit" },
|
||||||
"E": { "item": "minecraft:ender_pearl" },
|
"E": { "item": "minecraft:ender_pearl" },
|
||||||
"R": { "item": "teleportmirror:advanced_teleport_mirror" },
|
"R": { "item": "teleportmirror:advanced_teleport_mirror" },
|
||||||
"B": { "item": "minecraft:blaze_rod" }
|
"B": { "item": "minecraft:echo_shard" }
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
"id": "teleportmirror:permanent_teleport_mirror",
|
"id": "teleportmirror:permanent_teleport_mirror",
|
||||||
|
|||||||