From ac734fbad5b272e16e1ed1f0467aea0e2e9c11ed Mon Sep 17 00:00:00 2001 From: topi-banana Date: Sat, 7 Sep 2024 17:10:55 +0900 Subject: [PATCH 01/15] added 1.20.2 --- build.gradle | 4 +++- settings.json | 1 + versions/1.20.1/gradle.properties | 6 +++--- versions/1.20.2/gradle.properties | 15 +++++++++++++++ versions/1.20.6/gradle.properties | 2 +- 5 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 versions/1.20.2/gradle.properties diff --git a/build.gradle b/build.gradle index 0f6b141..b323f9d 100644 --- a/build.gradle +++ b/build.gradle @@ -14,11 +14,13 @@ plugins { preprocess { def mc119 = createNode('1.19.4', 1_19_04, '') def mc1201 = createNode('1.20.1', 1_20_01, '') + def mc1202 = createNode('1.20.2', 1_20_02, '') def mc1206 = createNode('1.20.6', 1_20_06, '') def mc121 = createNode('1.21.1', 1_21_01, '') mc119.link(mc1201, null) - mc1201.link(mc1206, null) + mc1201.link(mc1202, null) + mc1202.link(mc1206, null) mc1206.link(mc121, null) } diff --git a/settings.json b/settings.json index 043080b..b4664de 100644 --- a/settings.json +++ b/settings.json @@ -2,6 +2,7 @@ "versions": [ "1.19.4", "1.20.1", + "1.20.2", "1.20.6", "1.21.1" ] diff --git a/versions/1.20.1/gradle.properties b/versions/1.20.1/gradle.properties index 98ddf92..af3e41c 100644 --- a/versions/1.20.1/gradle.properties +++ b/versions/1.20.1/gradle.properties @@ -1,10 +1,10 @@ # Fabric Properties - # check these on https://fallen-breath.github.io/fabric-versions/?&version=1.21.1 + # check these on https://fallen-breath.github.io/fabric-versions/?&version=1.20.1 minecraft_version=1.20.1 yarn_mappings=1.20.1+build.10 # Fabric Mod Metadata - minecraft_dependency=1.20.x + minecraft_dependency=>=1.20.1 # Build Information # The target mc versions for the mod during mod publishing, separated with \n @@ -12,4 +12,4 @@ # Dependencies fabric_api_version=0.92.2+1.20.1 - carpet_version=1.20-1.4.112+v230608 \ No newline at end of file + carpet_version=1.20.2-1.4.118+v230921 \ No newline at end of file diff --git a/versions/1.20.2/gradle.properties b/versions/1.20.2/gradle.properties new file mode 100644 index 0000000..3f49755 --- /dev/null +++ b/versions/1.20.2/gradle.properties @@ -0,0 +1,15 @@ +# Fabric Properties + # check these on https://fallen-breath.github.io/fabric-versions/?&version=1.20.2 + minecraft_version=1.20.2 + yarn_mappings=1.20.2+build.1 + +# Fabric Mod Metadata + minecraft_dependency=>=1.20.2 + +# Build Information + # The target mc versions for the mod during mod publishing, separated with \n + game_versions=1.20.2\n1.20.3\n1.20.4 + +# Dependencies + fabric_api_version=0.91.6+1.20.2 + carpet_version=1.20.6-1.4.141+v240429 \ No newline at end of file diff --git a/versions/1.20.6/gradle.properties b/versions/1.20.6/gradle.properties index f658556..6c15f47 100644 --- a/versions/1.20.6/gradle.properties +++ b/versions/1.20.6/gradle.properties @@ -4,7 +4,7 @@ yarn_mappings=1.20.6+build.3 # Fabric Mod Metadata - minecraft_dependency=1.20.x + minecraft_dependency=>=1.20.6 # Build Information # The target mc versions for the mod during mod publishing, separated with \n From 32b378438fbef2de14f973cd1cbb153f223dcacb Mon Sep 17 00:00:00 2001 From: topi-banana Date: Sun, 8 Sep 2024 16:45:46 +0900 Subject: [PATCH 02/15] added rule "fixedTickMemoriesEntityAI" --- common.gradle | 2 +- .../vulpeus_carpet/VulpeusCarpetSettings.java | 10 ++- .../MixinMemory.java | 61 +++++++++++++++++++ .../vulpeus_carpet/utils/DummyClass.java | 24 ++++++++ .../assets/vulpeus_carpet/lang/en_us.yml | 3 + src/main/resources/vulpeus_carpet.mixins.json | 1 + versions/1.20.1/gradle.properties | 6 +- 7 files changed, 100 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/vulpeus/vulpeus_carpet/mixins/fixedTickMemoriesEntityAI/MixinMemory.java create mode 100644 src/main/java/com/vulpeus/vulpeus_carpet/utils/DummyClass.java diff --git a/common.gradle b/common.gradle index dcdb654..322b14c 100644 --- a/common.gradle +++ b/common.gradle @@ -38,7 +38,7 @@ dependencies { // dependencies // library mods - include(modImplementation(fabricApi.module("fabric-resource-loader-v0", project.fabric_api_version))) +// include(modImplementation(fabricApi.module("fabric-resource-loader-v0", project.fabric_api_version))) include(modImplementation("me.fallenbreath:conditional-mixin-fabric:${project.conditionalmixin_version}")) include(annotationProcessor(implementation("io.github.llamalad7:mixinextras-fabric:${project.mixinextras_version}"))) diff --git a/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetSettings.java b/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetSettings.java index df79499..6d0f4d0 100644 --- a/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetSettings.java +++ b/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetSettings.java @@ -20,9 +20,7 @@ package com.vulpeus.vulpeus_carpet; -import static carpet.api.settings.RuleCategory.COMMAND; -import static carpet.api.settings.RuleCategory.OPTIMIZATION; -import static carpet.api.settings.RuleCategory.SURVIVAL; +import static carpet.api.settings.RuleCategory.*; import carpet.api.settings.Rule; @@ -48,6 +46,12 @@ public class VulpeusCarpetSettings { @Rule(categories = {VULPEUS}) public static boolean disableSOECrash = false; + //#if MC<=12001 + //$$ @Rule(categories = {BUGFIX, VULPEUS}) + //#endif + public static boolean fixedTickMemoriesEntityAI = false; + @Rule(categories = {OPTIMIZATION, VULPEUS}) public static boolean optimizedDragonRespawn = false; + } diff --git a/src/main/java/com/vulpeus/vulpeus_carpet/mixins/fixedTickMemoriesEntityAI/MixinMemory.java b/src/main/java/com/vulpeus/vulpeus_carpet/mixins/fixedTickMemoriesEntityAI/MixinMemory.java new file mode 100644 index 0000000..21ba4b7 --- /dev/null +++ b/src/main/java/com/vulpeus/vulpeus_carpet/mixins/fixedTickMemoriesEntityAI/MixinMemory.java @@ -0,0 +1,61 @@ +/* + * This file is part of the VulpeusCarpet project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 VulpeusServer and contributors + * + * VulpeusCarpet is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * VulpeusCarpet is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with VulpeusCarpet. If not, see . + */ + +package com.vulpeus.vulpeus_carpet.mixins.fixedTickMemoriesEntityAI; + +import com.vulpeus.vulpeus_carpet.VulpeusCarpetSettings; +import me.fallenbreath.conditionalmixin.api.annotation.Condition; +import me.fallenbreath.conditionalmixin.api.annotation.Restriction; +import net.minecraft.entity.ai.brain.Memory; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Restriction(require = @Condition(value = "minecraft", versionPredicates = "<=1.20.1")) +@Mixin(Memory.class) +public abstract class MixinMemory { + + @Unique + private boolean tickFlag = false; + + @Shadow + public abstract void tick(); + + @Inject(method = "isExpired", at = @At(value = "HEAD", target = "Lnet/minecraft/entity/ai/brain/Brain;tickMemories()V")) + public void isExpired(CallbackInfoReturnable cir) { + if (VulpeusCarpetSettings.fixedTickMemoriesEntityAI) { + this.tickFlag = true; + tick(); + } + } + + @Inject(method = "tick", at = @At(value = "HEAD", target = "Lnet/minecraft/entity/ai/brain/Brain;tickMemories()V"), cancellable = true) + public void tick(CallbackInfo ci) { + if (VulpeusCarpetSettings.fixedTickMemoriesEntityAI && this.tickFlag) { + this.tickFlag = false; + ci.cancel(); + } + } + +} diff --git a/src/main/java/com/vulpeus/vulpeus_carpet/utils/DummyClass.java b/src/main/java/com/vulpeus/vulpeus_carpet/utils/DummyClass.java new file mode 100644 index 0000000..9ad2e2d --- /dev/null +++ b/src/main/java/com/vulpeus/vulpeus_carpet/utils/DummyClass.java @@ -0,0 +1,24 @@ +/* + * This file is part of the VulpeusCarpet project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 VulpeusServer and contributors + * + * VulpeusCarpet is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * VulpeusCarpet is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with VulpeusCarpet. If not, see . + */ + +package com.vulpeus.vulpeus_carpet.utils; + +public class DummyClass { +} diff --git a/src/main/resources/assets/vulpeus_carpet/lang/en_us.yml b/src/main/resources/assets/vulpeus_carpet/lang/en_us.yml index 43ce8ac..3220dd4 100644 --- a/src/main/resources/assets/vulpeus_carpet/lang/en_us.yml +++ b/src/main/resources/assets/vulpeus_carpet/lang/en_us.yml @@ -21,5 +21,8 @@ carpet: disableSOECrash: desc: yeet the server crash caused by StackOverflowError. + fixedTickMemoriesEntityAI: + desc: fixed MC-254100 + optimizedDragonRespawn: desc: Optimize dragon respawn method. Ported from carpet AMS addition. \ No newline at end of file diff --git a/src/main/resources/vulpeus_carpet.mixins.json b/src/main/resources/vulpeus_carpet.mixins.json index 53087bd..a9fab2c 100644 --- a/src/main/resources/vulpeus_carpet.mixins.json +++ b/src/main/resources/vulpeus_carpet.mixins.json @@ -6,6 +6,7 @@ "mixins": [ "commandSit.MixinArmorStandEntity", "disableCrash.MixinMinecraftServer", + "fixedTickMemoriesEntityAI.MixinMemory", "optimizedDragonRespawn.IMixinBlockPatternTestTransform", "optimizedDragonRespawn.MixinEnderDragonFight", "playerActions.PlayerCommandMixin", diff --git a/versions/1.20.1/gradle.properties b/versions/1.20.1/gradle.properties index af3e41c..bb3512b 100644 --- a/versions/1.20.1/gradle.properties +++ b/versions/1.20.1/gradle.properties @@ -1,10 +1,10 @@ # Fabric Properties # check these on https://fallen-breath.github.io/fabric-versions/?&version=1.20.1 minecraft_version=1.20.1 - yarn_mappings=1.20.1+build.10 + yarn_mappings=1.20.1+build.2 # Fabric Mod Metadata - minecraft_dependency=>=1.20.1 + minecraft_dependency=>=1.20 # Build Information # The target mc versions for the mod during mod publishing, separated with \n @@ -12,4 +12,4 @@ # Dependencies fabric_api_version=0.92.2+1.20.1 - carpet_version=1.20.2-1.4.118+v230921 \ No newline at end of file + carpet_version=1.20-1.4.112+v230608 \ No newline at end of file From 9aeed294bc6d96855a1910f9351f19106d406d1f Mon Sep 17 00:00:00 2001 From: topi-banana Date: Mon, 9 Sep 2024 08:19:14 +0900 Subject: [PATCH 03/15] added rule "fixedFallingBlockCantUseNetherPortal" --- gradle.properties | 2 +- .../vulpeus_carpet/VulpeusCarpetSettings.java | 5 ++++ .../MixinFallingBlockEntity.java | 29 +++++++++++++++++++ .../assets/vulpeus_carpet/lang/en_us.yml | 3 ++ src/main/resources/vulpeus_carpet.mixins.json | 1 + 5 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/vulpeus/vulpeus_carpet/mixins/fixedFallingBlockCantUseNetherPortal/MixinFallingBlockEntity.java diff --git a/gradle.properties b/gradle.properties index 99c8443..3a8e7e2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ # Mod Properties mod_id=vulpeus_carpet mod_name=VulpeusCarpet - mod_version=2.0.0 + mod_version=2.0.1 maven_group=com.vulpeus archives_base_name=vulpeus_carpet diff --git a/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetSettings.java b/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetSettings.java index 6d0f4d0..7bea211 100644 --- a/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetSettings.java +++ b/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetSettings.java @@ -51,6 +51,11 @@ public class VulpeusCarpetSettings { //#endif public static boolean fixedTickMemoriesEntityAI = false; + //#if MC<=12006 + //$$ @Rule(categories = {BUGFIX, VULPEUS}) + //#endif + public static boolean fixedFallingBlockCantUseNetherPortal = false; + @Rule(categories = {OPTIMIZATION, VULPEUS}) public static boolean optimizedDragonRespawn = false; diff --git a/src/main/java/com/vulpeus/vulpeus_carpet/mixins/fixedFallingBlockCantUseNetherPortal/MixinFallingBlockEntity.java b/src/main/java/com/vulpeus/vulpeus_carpet/mixins/fixedFallingBlockCantUseNetherPortal/MixinFallingBlockEntity.java new file mode 100644 index 0000000..bdc02db --- /dev/null +++ b/src/main/java/com/vulpeus/vulpeus_carpet/mixins/fixedFallingBlockCantUseNetherPortal/MixinFallingBlockEntity.java @@ -0,0 +1,29 @@ +package com.vulpeus.vulpeus_carpet.mixins.fixedFallingBlockCantUseNetherPortal; + +import com.vulpeus.vulpeus_carpet.VulpeusCarpetSettings; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.FallingBlockEntity; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(FallingBlockEntity.class) +public abstract class MixinFallingBlockEntity extends Entity { + + public MixinFallingBlockEntity(EntityType type, World world) { + super(type, world); + } + + @Inject(method = "tick", at = @At("HEAD")) + private void tick(CallbackInfo ci) { + if (VulpeusCarpetSettings.fixedFallingBlockCantUseNetherPortal) { + //#if MC<=12006 + //$$ this.tickPortal(); + //#endif + } + } + +} diff --git a/src/main/resources/assets/vulpeus_carpet/lang/en_us.yml b/src/main/resources/assets/vulpeus_carpet/lang/en_us.yml index 3220dd4..822d579 100644 --- a/src/main/resources/assets/vulpeus_carpet/lang/en_us.yml +++ b/src/main/resources/assets/vulpeus_carpet/lang/en_us.yml @@ -21,6 +21,9 @@ carpet: disableSOECrash: desc: yeet the server crash caused by StackOverflowError. + fixedFallingBlockCantUseNetherPortal: + desc: fixed MC-9644 + fixedTickMemoriesEntityAI: desc: fixed MC-254100 diff --git a/src/main/resources/vulpeus_carpet.mixins.json b/src/main/resources/vulpeus_carpet.mixins.json index a9fab2c..620d21d 100644 --- a/src/main/resources/vulpeus_carpet.mixins.json +++ b/src/main/resources/vulpeus_carpet.mixins.json @@ -6,6 +6,7 @@ "mixins": [ "commandSit.MixinArmorStandEntity", "disableCrash.MixinMinecraftServer", + "fixedFallingBlockCantUseNetherPortal.MixinFallingBlockEntity", "fixedTickMemoriesEntityAI.MixinMemory", "optimizedDragonRespawn.IMixinBlockPatternTestTransform", "optimizedDragonRespawn.MixinEnderDragonFight", From 976fb8d11d207b7309aaeb7ca64b4f863623880b Mon Sep 17 00:00:00 2001 From: topi-banana Date: Mon, 9 Sep 2024 08:22:02 +0900 Subject: [PATCH 04/15] change order --- .../com/vulpeus/vulpeus_carpet/VulpeusCarpetSettings.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetSettings.java b/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetSettings.java index 7bea211..017e063 100644 --- a/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetSettings.java +++ b/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetSettings.java @@ -46,15 +46,15 @@ public class VulpeusCarpetSettings { @Rule(categories = {VULPEUS}) public static boolean disableSOECrash = false; - //#if MC<=12001 + //#if MC<=12006 //$$ @Rule(categories = {BUGFIX, VULPEUS}) //#endif - public static boolean fixedTickMemoriesEntityAI = false; + public static boolean fixedFallingBlockCantUseNetherPortal = false; - //#if MC<=12006 + //#if MC<=12001 //$$ @Rule(categories = {BUGFIX, VULPEUS}) //#endif - public static boolean fixedFallingBlockCantUseNetherPortal = false; + public static boolean fixedTickMemoriesEntityAI = false; @Rule(categories = {OPTIMIZATION, VULPEUS}) public static boolean optimizedDragonRespawn = false; From 243812d4d10e0bf8a4341b83827accdbb3873df1 Mon Sep 17 00:00:00 2001 From: topi-banana Date: Mon, 9 Sep 2024 08:36:09 +0900 Subject: [PATCH 05/15] added documents fixedFallingBlockCantUseNetherPortal, fixedTickMemoriesEntityAI --- docs/en_us.md | 16 ++++++++++++++++ docs/ja_jp.md | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/docs/en_us.md b/docs/en_us.md index 00590ee..3d47299 100644 --- a/docs/en_us.md +++ b/docs/en_us.md @@ -52,6 +52,22 @@ yeet the server crash caused by StackOverflowError. - Default value: `false` - Categories: `VULPEUS` +### fixedFallingBlockCantUseNetherPortal (<=1.20.6) + +fixed MC-9644. + +- Type: `boolean` +- Default value: `false` +- Categories: `BUGFIX`, `VULPEUS` + +### fixedTickMemoriesEntityAI (<=1.20.1) + +fixed MC-254100. + +- Type: `boolean` +- Default value: `false` +- Categories: `BUGFIX`, `VULPEUS` + ### optmizedDragonRespawn Optimize dragon respawn method. Ported from carpet AMS addition. diff --git a/docs/ja_jp.md b/docs/ja_jp.md index d34b345..fad20fa 100644 --- a/docs/ja_jp.md +++ b/docs/ja_jp.md @@ -53,6 +53,22 @@ StackOverflowError によるサーバーのクラッシュの無効化。 - デフォルト: `false` - カテゴリー: `VULPEUS` +### fixedFallingBlockCantUseNetherPortal (<=1.20.6) + +MC-9644 の修正。 + +- タイプ: `boolean` +- デフォルト: `false` +- カテゴリー: `BUGFIX`, `VULPEUS` + +### fixedTickMemoriesEntityAI (<=1.20.1) + +MC-254100 の修正 + +- タイプ: `boolean` +- デフォルト: `false` +- カテゴリー: `BUGFIX`, `VULPEUS` + ### optmizedDragonRespawn エンダードラゴンのリスポーン処理の最適化。carpet AMS addition からの移植。 From a08a10949e246e6c094d54c49e34596456c85f03 Mon Sep 17 00:00:00 2001 From: topi-banana Date: Mon, 9 Sep 2024 10:20:18 +0900 Subject: [PATCH 06/15] added rule "fixedBeeNotLeavingHive" --- docs/en_us.md | 8 +++ docs/ja_jp.md | 8 +++ .../vulpeus_carpet/VulpeusCarpetSettings.java | 5 ++ .../MixinBeehiveBlockEntity.java | 49 +++++++++++++++++++ .../assets/vulpeus_carpet/lang/en_us.yml | 3 ++ src/main/resources/vulpeus_carpet.mixins.json | 1 + 6 files changed, 74 insertions(+) create mode 100644 src/main/java/com/vulpeus/vulpeus_carpet/mixins/fixedBeeNotLeavingHive/MixinBeehiveBlockEntity.java diff --git a/docs/en_us.md b/docs/en_us.md index 3d47299..6ca7ce2 100644 --- a/docs/en_us.md +++ b/docs/en_us.md @@ -52,6 +52,14 @@ yeet the server crash caused by StackOverflowError. - Default value: `false` - Categories: `VULPEUS` +### fixedBeeNotLeavingHive (<=1.21.1) + +fixed MC-168329. + +- Type: `boolean` +- Default value: `false` +- Categories: `BUGFIX`, `VULPEUS` + ### fixedFallingBlockCantUseNetherPortal (<=1.20.6) fixed MC-9644. diff --git a/docs/ja_jp.md b/docs/ja_jp.md index fad20fa..5d9bbe4 100644 --- a/docs/ja_jp.md +++ b/docs/ja_jp.md @@ -53,6 +53,14 @@ StackOverflowError によるサーバーのクラッシュの無効化。 - デフォルト: `false` - カテゴリー: `VULPEUS` +### fixedBeeNotLeavingHive (<=1.21.1) + +MC-168329 の修正。 + +- タイプ: `boolean` +- デフォルト: `false` +- カテゴリー: `BUGFIX`, `VULPEUS` + ### fixedFallingBlockCantUseNetherPortal (<=1.20.6) MC-9644 の修正。 diff --git a/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetSettings.java b/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetSettings.java index 017e063..19745ac 100644 --- a/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetSettings.java +++ b/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetSettings.java @@ -46,6 +46,11 @@ public class VulpeusCarpetSettings { @Rule(categories = {VULPEUS}) public static boolean disableSOECrash = false; + //#if MC<=12101 + //$$ @Rule(categories = {BUGFIX, VULPEUS}) + //#endif + public static boolean fixedBeeNotLeavingHive = false; + //#if MC<=12006 //$$ @Rule(categories = {BUGFIX, VULPEUS}) //#endif diff --git a/src/main/java/com/vulpeus/vulpeus_carpet/mixins/fixedBeeNotLeavingHive/MixinBeehiveBlockEntity.java b/src/main/java/com/vulpeus/vulpeus_carpet/mixins/fixedBeeNotLeavingHive/MixinBeehiveBlockEntity.java new file mode 100644 index 0000000..7119574 --- /dev/null +++ b/src/main/java/com/vulpeus/vulpeus_carpet/mixins/fixedBeeNotLeavingHive/MixinBeehiveBlockEntity.java @@ -0,0 +1,49 @@ +/* + * This file is part of the VulpeusCarpet project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 VulpeusServer and contributors + * + * VulpeusCarpet is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * VulpeusCarpet is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with VulpeusCarpet. If not, see . + */ + +package com.vulpeus.vulpeus_carpet.mixins.fixedBeeNotLeavingHive; + +import com.vulpeus.vulpeus_carpet.VulpeusCarpetSettings; +import me.fallenbreath.conditionalmixin.api.annotation.Condition; +import me.fallenbreath.conditionalmixin.api.annotation.Restriction; +import net.minecraft.block.entity.BeehiveBlockEntity; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Restriction(require = @Condition(value = "minecraft", versionPredicates = "<=1.21.1")) +@Mixin(BeehiveBlockEntity.class) +public class MixinBeehiveBlockEntity { + @Redirect( + method = "releaseBee", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/World;isRaining()Z" + ) + ) + private static boolean releaseBee(World world) { + if (VulpeusCarpetSettings.fixedBeeNotLeavingHive) { + return !world.getDimension().hasFixedTime() && world.getDimension().hasSkyLight() && world.isRaining(); + } else { + return world.isRaining(); + } + } +} diff --git a/src/main/resources/assets/vulpeus_carpet/lang/en_us.yml b/src/main/resources/assets/vulpeus_carpet/lang/en_us.yml index 822d579..2358ca2 100644 --- a/src/main/resources/assets/vulpeus_carpet/lang/en_us.yml +++ b/src/main/resources/assets/vulpeus_carpet/lang/en_us.yml @@ -21,6 +21,9 @@ carpet: disableSOECrash: desc: yeet the server crash caused by StackOverflowError. + fixedBeeNotLeavingHive: + desc: fixed MC-168329 + fixedFallingBlockCantUseNetherPortal: desc: fixed MC-9644 diff --git a/src/main/resources/vulpeus_carpet.mixins.json b/src/main/resources/vulpeus_carpet.mixins.json index 620d21d..7627833 100644 --- a/src/main/resources/vulpeus_carpet.mixins.json +++ b/src/main/resources/vulpeus_carpet.mixins.json @@ -6,6 +6,7 @@ "mixins": [ "commandSit.MixinArmorStandEntity", "disableCrash.MixinMinecraftServer", + "fixedBeeNotLeavingHive.MixinBeehiveBlockEntity", "fixedFallingBlockCantUseNetherPortal.MixinFallingBlockEntity", "fixedTickMemoriesEntityAI.MixinMemory", "optimizedDragonRespawn.IMixinBlockPatternTestTransform", From d311af87c935e400b02656ac8990c0f129b93476 Mon Sep 17 00:00:00 2001 From: topi-banana Date: Mon, 9 Sep 2024 22:45:21 +0900 Subject: [PATCH 07/15] support prepro --- .../MixinFallingBlockEntity.java | 50 ++++++++++--------- .../MixinFallingBlockEntity.java | 49 ++++++++++++++++++ 2 files changed, 75 insertions(+), 24 deletions(-) create mode 100644 versions/1.20.6/src/main/java/com/vulpeus/vulpeus_carpet/mixins/fixedFallingBlockCantUseNetherPortal/MixinFallingBlockEntity.java diff --git a/src/main/java/com/vulpeus/vulpeus_carpet/mixins/fixedFallingBlockCantUseNetherPortal/MixinFallingBlockEntity.java b/src/main/java/com/vulpeus/vulpeus_carpet/mixins/fixedFallingBlockCantUseNetherPortal/MixinFallingBlockEntity.java index bdc02db..1ec7439 100644 --- a/src/main/java/com/vulpeus/vulpeus_carpet/mixins/fixedFallingBlockCantUseNetherPortal/MixinFallingBlockEntity.java +++ b/src/main/java/com/vulpeus/vulpeus_carpet/mixins/fixedFallingBlockCantUseNetherPortal/MixinFallingBlockEntity.java @@ -1,29 +1,31 @@ +/* + * This file is part of the VulpeusCarpet project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 VulpeusServer and contributors + * + * VulpeusCarpet is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * VulpeusCarpet is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with VulpeusCarpet. If not, see . + */ + package com.vulpeus.vulpeus_carpet.mixins.fixedFallingBlockCantUseNetherPortal; -import com.vulpeus.vulpeus_carpet.VulpeusCarpetSettings; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.FallingBlockEntity; -import net.minecraft.world.World; +import com.vulpeus.vulpeus_carpet.utils.DummyClass; +import me.fallenbreath.conditionalmixin.api.annotation.Condition; +import me.fallenbreath.conditionalmixin.api.annotation.Restriction; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(FallingBlockEntity.class) -public abstract class MixinFallingBlockEntity extends Entity { - - public MixinFallingBlockEntity(EntityType type, World world) { - super(type, world); - } - - @Inject(method = "tick", at = @At("HEAD")) - private void tick(CallbackInfo ci) { - if (VulpeusCarpetSettings.fixedFallingBlockCantUseNetherPortal) { - //#if MC<=12006 - //$$ this.tickPortal(); - //#endif - } - } +@Restriction(require = @Condition(value = "minecraft", versionPredicates = "<=1.20.6")) +@Mixin(DummyClass.class) +public class MixinFallingBlockEntity { } diff --git a/versions/1.20.6/src/main/java/com/vulpeus/vulpeus_carpet/mixins/fixedFallingBlockCantUseNetherPortal/MixinFallingBlockEntity.java b/versions/1.20.6/src/main/java/com/vulpeus/vulpeus_carpet/mixins/fixedFallingBlockCantUseNetherPortal/MixinFallingBlockEntity.java new file mode 100644 index 0000000..459d15a --- /dev/null +++ b/versions/1.20.6/src/main/java/com/vulpeus/vulpeus_carpet/mixins/fixedFallingBlockCantUseNetherPortal/MixinFallingBlockEntity.java @@ -0,0 +1,49 @@ +/* + * This file is part of the VulpeusCarpet project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 VulpeusServer and contributors + * + * VulpeusCarpet is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * VulpeusCarpet is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with VulpeusCarpet. If not, see . + */ + +package com.vulpeus.vulpeus_carpet.mixins.fixedFallingBlockCantUseNetherPortal; + +import com.vulpeus.vulpeus_carpet.VulpeusCarpetSettings; +import me.fallenbreath.conditionalmixin.api.annotation.Condition; +import me.fallenbreath.conditionalmixin.api.annotation.Restriction; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.FallingBlockEntity; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Restriction(require = @Condition(value = "minecraft", versionPredicates = "<=1.20.6")) +@Mixin(FallingBlockEntity.class) +public abstract class MixinFallingBlockEntity extends Entity { + + public MixinFallingBlockEntity(EntityType type, World world) { + super(type, world); + } + + @Inject(method = "tick", at = @At("HEAD")) + private void tick(CallbackInfo ci) { + if (VulpeusCarpetSettings.fixedFallingBlockCantUseNetherPortal) { + this.tickPortal(); + } + } +} From af91ce450b7581c28ba3c764dac401447712b26e Mon Sep 17 00:00:00 2001 From: topi-banana Date: Tue, 10 Sep 2024 23:58:56 +0900 Subject: [PATCH 08/15] Script Collection Utils --- .../VulpeusCarpetExtension.java | 18 ++++++- .../utils/ScriptCollection.java | 51 +++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/vulpeus/vulpeus_carpet/utils/ScriptCollection.java diff --git a/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetExtension.java b/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetExtension.java index 1e29311..0327dbd 100644 --- a/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetExtension.java +++ b/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetExtension.java @@ -22,12 +22,20 @@ import carpet.CarpetExtension; import carpet.CarpetServer; +import carpet.script.CarpetScriptServer; +import carpet.script.Module; import carpet.utils.Translations; import com.mojang.brigadier.CommandDispatcher; import com.vulpeus.vulpeus_carpet.commands.hatCommand; import com.vulpeus.vulpeus_carpet.commands.sitCommand; import com.vulpeus.vulpeus_carpet.commands.viewCommand; +import com.vulpeus.vulpeus_carpet.utils.ScriptCollection; import com.vulpeus.vulpeus_carpet.utils.rule.defaultOpLevel.PlayerUtil; +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; import java.util.Map; import net.fabricmc.api.ModInitializer; import net.fabricmc.loader.api.FabricLoader; @@ -45,6 +53,8 @@ public class VulpeusCarpetExtension implements CarpetExtension, ModInitializer { public static final String MOD_NAME; public static final Version MOD_VERSION; public static final GameVersion GAME_VERSION; + public static final String ASSETS_PATH; + public static final ClassLoader CLASS_LOADER; static { ModMetadata metadata = @@ -55,6 +65,10 @@ public class VulpeusCarpetExtension implements CarpetExtension, ModInitializer { MOD_NAME = metadata.getName(); MOD_VERSION = metadata.getVersion(); GAME_VERSION = MinecraftVersion.CURRENT; + + ASSETS_PATH = String.format("assets/%s", MOD_ID); + + CLASS_LOADER = VulpeusCarpetExtension.class.getClassLoader(); } public static void loadExtension() { @@ -74,6 +88,7 @@ public void onInitialize() { @Override public void onGameStarted() { CarpetServer.settingsManager.parseSettingsClass(VulpeusCarpetSettings.class); + ScriptCollection.load(); } @Override @@ -93,6 +108,7 @@ public void onPlayerLoggedIn(ServerPlayerEntity player) { @Override public Map canHasTranslations(String lang) { return Translations.getTranslationFromResourcePath( - String.format("assets/%s/lang/%s.json", MOD_ID, lang)); + String.format("%s/lang/%s.json", ASSETS_PATH, lang) + ); } } \ No newline at end of file diff --git a/src/main/java/com/vulpeus/vulpeus_carpet/utils/ScriptCollection.java b/src/main/java/com/vulpeus/vulpeus_carpet/utils/ScriptCollection.java new file mode 100644 index 0000000..490aa5b --- /dev/null +++ b/src/main/java/com/vulpeus/vulpeus_carpet/utils/ScriptCollection.java @@ -0,0 +1,51 @@ +package com.vulpeus.vulpeus_carpet.utils; + +import static com.vulpeus.vulpeus_carpet.VulpeusCarpetExtension.*; + +import carpet.script.CarpetScriptServer; +import carpet.script.Module; +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import org.apache.commons.io.IOUtils; + +public class ScriptCollection { + + public static void load() { + URL scripts = CLASS_LOADER.getResource(String.format("%s/scripts/", ASSETS_PATH)); + File scriptDir = new File(scripts.getPath()); + File[] scriptFiles = scriptDir.listFiles(); + for (File scriptFile : scriptFiles) { + Module module = fromScriptFilename(scriptFile.getName()); + CarpetScriptServer.registerBuiltInApp(module); + } + } + + private static Module fromScriptFilename(String filename) { + int index = filename.lastIndexOf("."); + + String ext = filename.substring(index); + String scriptName = filename.substring(0, index); + + if (ext.equals(".sc") || ext.equals(".scl")) { + return nativeScript( + filename, + scriptName, + ext.equals(".scl") + ); + } + return null; + } + public static Module nativeScript(String filename, String scriptName, boolean isLibrary) { + try { + String code = IOUtils.toString( + CLASS_LOADER.getResourceAsStream(String.format("%s/scripts/%s", ASSETS_PATH, filename)), + StandardCharsets.UTF_8 + ); + return new Module(scriptName, code, isLibrary); + } catch (IOException e) { + throw new IllegalArgumentException("Failed to load bundled module", e); + } + } +} From 7ee639355888622396a6a856c0ffbd7749f24323 Mon Sep 17 00:00:00 2001 From: topi-banana Date: Thu, 12 Sep 2024 22:25:06 +0900 Subject: [PATCH 09/15] coding style and header --- .../VulpeusCarpetExtension.java | 7 ------- .../utils/ScriptCollection.java | 20 +++++++++++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetExtension.java b/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetExtension.java index 0327dbd..e56397a 100644 --- a/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetExtension.java +++ b/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetExtension.java @@ -22,8 +22,6 @@ import carpet.CarpetExtension; import carpet.CarpetServer; -import carpet.script.CarpetScriptServer; -import carpet.script.Module; import carpet.utils.Translations; import com.mojang.brigadier.CommandDispatcher; import com.vulpeus.vulpeus_carpet.commands.hatCommand; @@ -31,11 +29,6 @@ import com.vulpeus.vulpeus_carpet.commands.viewCommand; import com.vulpeus.vulpeus_carpet.utils.ScriptCollection; import com.vulpeus.vulpeus_carpet.utils.rule.defaultOpLevel.PlayerUtil; -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.nio.file.Path; import java.util.Map; import net.fabricmc.api.ModInitializer; import net.fabricmc.loader.api.FabricLoader; diff --git a/src/main/java/com/vulpeus/vulpeus_carpet/utils/ScriptCollection.java b/src/main/java/com/vulpeus/vulpeus_carpet/utils/ScriptCollection.java index 490aa5b..5a3fe70 100644 --- a/src/main/java/com/vulpeus/vulpeus_carpet/utils/ScriptCollection.java +++ b/src/main/java/com/vulpeus/vulpeus_carpet/utils/ScriptCollection.java @@ -1,3 +1,23 @@ +/* + * This file is part of the VulpeusCarpet project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 VulpeusServer and contributors + * + * VulpeusCarpet is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * VulpeusCarpet is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with VulpeusCarpet. If not, see . + */ + package com.vulpeus.vulpeus_carpet.utils; import static com.vulpeus.vulpeus_carpet.VulpeusCarpetExtension.*; From b933c28a374c533003a374471b12344669b6f99f Mon Sep 17 00:00:00 2001 From: topi-banana Date: Sat, 21 Sep 2024 06:52:24 +0900 Subject: [PATCH 10/15] changed icon --- .../resources/assets/vulpeus_carpet/icon.png | Bin 453 -> 3370 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/vulpeus_carpet/icon.png b/src/main/resources/assets/vulpeus_carpet/icon.png index 047b91f2347de5cf95f23284476fddbe21ba23fe..7a2d07a348ecab01bfef6e9d412729c72d027352 100644 GIT binary patch literal 3370 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 E9~@mZ1poj5 delta 439 zcmV;o0Z9I;8pQ*U7=Hl+0002_@bicO000J1OjJbx00960|E1ZV-2eaqdPzhn%o5BQHNuK}!002ovPDHLkV1g@}vu^+Z From 9d51d64e6db0cfdd8ab5d06acbeabff92a3a1d15 Mon Sep 17 00:00:00 2001 From: topi-banana Date: Sun, 22 Sep 2024 12:19:11 +0900 Subject: [PATCH 11/15] Added "commandCustomLoad" custom loading chunks. inspired by AMS blockChunkLoader. --- docs/en_us.md | 15 ++ .../VulpeusCarpetExtension.java | 27 +++ .../vulpeus_carpet/VulpeusCarpetSettings.java | 3 + .../commands/customLoadCommand.java | 178 ++++++++++++++++++ .../CustomLoadingChunks.java | 137 ++++++++++++++ .../assets/vulpeus_carpet/lang/en_us.yml | 3 + 6 files changed, 363 insertions(+) create mode 100644 src/main/java/com/vulpeus/vulpeus_carpet/commands/customLoadCommand.java create mode 100644 src/main/java/com/vulpeus/vulpeus_carpet/utils/rule/commandCustomLoad/CustomLoadingChunks.java diff --git a/docs/en_us.md b/docs/en_us.md index 6ca7ce2..6aaeb12 100644 --- a/docs/en_us.md +++ b/docs/en_us.md @@ -1,5 +1,14 @@ ## Rules +### commandCustomLoad + +Enable `/custom-load` command. Inspired by AMS blockChunkLoader. + +- Type: `String` +- Default value: `ops` +- Allowed options: `true`, `false`, `ops`, `0`, `1`, `2`, `3`, `4` +- Categories: `SURVIVAL`, `COMMAND`, `VULPEUS` + ### commandHat Enable `/hat` command. Ported from essential addons. @@ -94,6 +103,12 @@ Optimize dragon respawn method. Ported from carpet AMS addition. be equipped.Also you cannot use this command if you already equip the item enchanted curse of binding. +### hat + +`/hat` : Equip the item you have on your own head. Totem of undying or non-empty shulker box cannot +be equipped.Also you cannot use this command if you already equip the item enchanted curse of +binding. + ### sit `/sit` : sit on the spot. diff --git a/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetExtension.java b/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetExtension.java index e56397a..b56023f 100644 --- a/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetExtension.java +++ b/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetExtension.java @@ -24,11 +24,14 @@ import carpet.CarpetServer; import carpet.utils.Translations; import com.mojang.brigadier.CommandDispatcher; +import com.vulpeus.vulpeus_carpet.commands.customLoadCommand; import com.vulpeus.vulpeus_carpet.commands.hatCommand; import com.vulpeus.vulpeus_carpet.commands.sitCommand; import com.vulpeus.vulpeus_carpet.commands.viewCommand; +import com.vulpeus.vulpeus_carpet.utils.rule.commandCustomLoad.CustomLoadingChunks; import com.vulpeus.vulpeus_carpet.utils.ScriptCollection; import com.vulpeus.vulpeus_carpet.utils.rule.defaultOpLevel.PlayerUtil; +import java.io.IOException; import java.util.Map; import net.fabricmc.api.ModInitializer; import net.fabricmc.loader.api.FabricLoader; @@ -37,6 +40,7 @@ import net.minecraft.GameVersion; import net.minecraft.MinecraftVersion; import net.minecraft.command.CommandRegistryAccess; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; @@ -84,8 +88,27 @@ public void onGameStarted() { ScriptCollection.load(); } + @Override + public void onServerLoadedWorlds(MinecraftServer server) { + try { + System.out.println(server); + CustomLoadingChunks.importConfig(server); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + @Override + public void onServerClosed(MinecraftServer server) { + try { + CustomLoadingChunks.exportConfig(server); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + @Override public void registerCommands(CommandDispatcher dispatcher, CommandRegistryAccess commandRegistryAccess) { + customLoadCommand.register(dispatcher); viewCommand.register(dispatcher); hatCommand.register(dispatcher); sitCommand.register(dispatcher); @@ -98,6 +121,10 @@ public void onPlayerLoggedIn(ServerPlayerEntity player) { } } + @Override + public void onTick(MinecraftServer server){ + } + @Override public Map canHasTranslations(String lang) { return Translations.getTranslationFromResourcePath( diff --git a/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetSettings.java b/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetSettings.java index 19745ac..b1b4764 100644 --- a/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetSettings.java +++ b/src/main/java/com/vulpeus/vulpeus_carpet/VulpeusCarpetSettings.java @@ -28,6 +28,9 @@ public class VulpeusCarpetSettings { private static final String VULPEUS = "vulpeus"; + @Rule(categories = {OPTIMIZATION, COMMAND, VULPEUS}) + public static String commandCustomLoad = "ops"; + @Rule(categories = {SURVIVAL, COMMAND, VULPEUS}) public static String commandHat = "ops"; diff --git a/src/main/java/com/vulpeus/vulpeus_carpet/commands/customLoadCommand.java b/src/main/java/com/vulpeus/vulpeus_carpet/commands/customLoadCommand.java new file mode 100644 index 0000000..c7b03fa --- /dev/null +++ b/src/main/java/com/vulpeus/vulpeus_carpet/commands/customLoadCommand.java @@ -0,0 +1,178 @@ +/* + * This file is part of the VulpeusCarpet project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 Fallen_Breath and contributors + * + * VulpeusCarpet is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * VulpeusCarpet is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with VulpeusCarpet. If not, see . + */ + +package com.vulpeus.vulpeus_carpet.commands; + +import carpet.utils.CommandHelper; +import carpet.utils.Messenger; +import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.arguments.IntegerArgumentType; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.vulpeus.vulpeus_carpet.VulpeusCarpetSettings; +import com.vulpeus.vulpeus_carpet.utils.rule.commandCustomLoad.CustomLoadingChunks; +import com.vulpeus.vulpeus_carpet.utils.rule.commandCustomLoad.CustomLoadingChunks.VulpeusTicket; +import net.minecraft.command.argument.DimensionArgumentType; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.server.command.CommandManager; +import net.minecraft.server.command.ServerCommandSource; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.dimension.DimensionType; +import net.minecraft.world.dimension.DimensionTypes; + +public class customLoadCommand { + + public static void register(CommandDispatcher dispatcher) { + dispatcher.register( + CommandManager.literal("custom-load") + .requires(player -> CommandHelper.canUseCommand(player, VulpeusCarpetSettings.commandCustomLoad)) + .then( + CommandManager.literal("add") + .then( + CommandManager.argument("dim", DimensionArgumentType.dimension()) + .then( + CommandManager.argument("cx", IntegerArgumentType.integer()) + .then( + CommandManager.argument("cz", IntegerArgumentType.integer()) + .then( + CommandManager.argument("size", IntegerArgumentType.integer(0, 33)) + .executes( + customLoadCommand::add + ) + ) + ) + ) + ) + ) + .then( + CommandManager.literal("remove") + .then( + CommandManager.argument("index", IntegerArgumentType.integer(1)) + .executes( + customLoadCommand::remove + ) + ) + ) + .executes( + customLoadCommand::status + ) + ); + } + + private static int add(CommandContext context) throws CommandSyntaxException { + ServerWorld world = DimensionArgumentType.getDimensionArgument(context, "dim").toServerWorld(); + int cx = IntegerArgumentType.getInteger(context, "cx"); + int cz = IntegerArgumentType.getInteger(context, "cz"); + int size = IntegerArgumentType.getInteger(context, "size"); + + ChunkPos chunk = new ChunkPos(cx, cz); + + int index = CustomLoadingChunks.add(world, chunk, size); + + ServerCommandSource source = context.getSource(); + + source.sendMessage(Messenger.c("lb Success to add custom-loading chunk ticket:")); + source.sendMessage(Messenger.c("w Index: " + index+1)); + source.sendMessage(Messenger.c( + "w Pos: ", + "g ["+cx+","+cz+"]" + )); + source.sendMessage(Messenger.c( + "w Radius: " + size + )); + source.sendMessage(Messenger.c()); + status(context); + + return 0; + } + + private static int remove(CommandContext context) { + int index = IntegerArgumentType.getInteger(context, "index") -1; + + VulpeusTicket ticket = CustomLoadingChunks.remove(index); + + ServerCommandSource source = context.getSource(); + source.sendMessage(Messenger.c("lb Success to remove custom-loading chunk ticket:")); + source.sendMessage(Messenger.c("w Index: " + index+1)); + source.sendMessage(Messenger.c( + "w Pos: ", + "g ["+ticket.chunkPos.x+","+ticket.chunkPos.z+"]" + )); + source.sendMessage(Messenger.c( + "w Radius: " + ticket.size + )); + source.sendMessage(Messenger.c()); + status(context); + + return 0; + } + + private static int status(CommandContext context) { + + int index = 0; + + context.getSource().sendMessage( + Messenger.c( + "nb "+CustomLoadingChunks.Tickets.size()+" ", + "w custom-load Tickets." + ) + ); + for (VulpeusTicket ticket : CustomLoadingChunks.Tickets) { + index++; + /* + * Dimension + */ + String coloredDim; + RegistryEntry dim = ticket.serverWorld.getDimensionEntry(); + if (dim.matchesKey(DimensionTypes.OVERWORLD)) { + coloredDim = "#8fce00 Overworld"; + } else if (dim.matchesKey(DimensionTypes.THE_NETHER)) { + coloredDim = "#f44336 Nether"; + } else if (dim.matchesKey(DimensionTypes.THE_END)) { + coloredDim = "#6a329f End"; + } else { + coloredDim = dim.getKey().get().getValue().toString(); + } + + /* + * Chunk Pos + */ + String chunkPos = ticket.chunkPos.x + "," + ticket.chunkPos.z; + + /* + * Size + */ + String size = ticket.size + ""; + + context.getSource().sendMessage( + Messenger.c( + "w|- ", + "w "+index+": ", + "w "+chunkPos+" ", + "w "+size+" ", + coloredDim + ) + ); + } + + return 0; + } +} diff --git a/src/main/java/com/vulpeus/vulpeus_carpet/utils/rule/commandCustomLoad/CustomLoadingChunks.java b/src/main/java/com/vulpeus/vulpeus_carpet/utils/rule/commandCustomLoad/CustomLoadingChunks.java new file mode 100644 index 0000000..d9e3375 --- /dev/null +++ b/src/main/java/com/vulpeus/vulpeus_carpet/utils/rule/commandCustomLoad/CustomLoadingChunks.java @@ -0,0 +1,137 @@ +/* + * This file is part of the VulpeusCarpet project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 VulpeusServer and contributors + * + * VulpeusCarpet is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * VulpeusCarpet is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with VulpeusCarpet. If not, see . + */ + +package com.vulpeus.vulpeus_carpet.utils.rule.commandCustomLoad; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.world.ChunkTicketType; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.Identifier; +import net.minecraft.util.Unit; +import net.minecraft.util.WorldSavePath; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.World; + +public class CustomLoadingChunks { + + private static final ChunkTicketType VULPEUS = ChunkTicketType.create("vulpeus", (unit, unit2) -> 0); + public static List Tickets = new ArrayList<>(); + + public static class VulpeusTicket { + public ServerWorld serverWorld; + public ChunkPos chunkPos; + public int size; + + VulpeusTicket(ServerWorld serverWorld, ChunkPos chunkPos, int size) { + this.serverWorld = serverWorld; + this.chunkPos = chunkPos; + this.size = size; + } + } + + public static int add(ServerWorld world, ChunkPos chunkPos, int size) { + return add(new VulpeusTicket(world, chunkPos, size)); + } + public static int add(VulpeusTicket ticket) { + ticket.serverWorld.getChunkManager().addTicket(VULPEUS, ticket.chunkPos, ticket.size, Unit.INSTANCE); + Tickets.add(ticket); + return Tickets.size()-1; + } + + public static VulpeusTicket remove(int index) { + VulpeusTicket ticket = Tickets.get(index); + ticket.serverWorld.getChunkManager().removeTicket(VULPEUS, ticket.chunkPos, ticket.size, Unit.INSTANCE); + Tickets.remove(index); + return ticket; + } + + public static void importConfig(MinecraftServer server) throws IOException { + for (VulpeusTicket ticket: load(server)) { + add(ticket); + } + } + public static void exportConfig(MinecraftServer server) throws IOException { + write(server, Tickets); + } + + public static List load(MinecraftServer server) throws IOException { + List lines = Files.readAllLines(getPath(server), StandardCharsets.UTF_8); + + List tickets = new ArrayList<>(); + + for (String line: lines) { + String[] args = line.split(" "); + + RegistryKey registryKey = RegistryKey.of( + RegistryKeys.WORLD, + //#if MC>=12100 + Identifier.of(args[0]) + //#else + //$$ new Identifier(args[0]) + //#endif + ); + ServerWorld serverWorld = server.getWorld(registryKey); + + long packedPos = Long.parseLong(args[1]); + ChunkPos chunkPos = new ChunkPos( + ChunkPos.getPackedX(packedPos), + ChunkPos.getPackedZ(packedPos) + ); + + int size = Integer.parseInt(args[2]); + + tickets.add( + new VulpeusTicket(serverWorld, chunkPos, size) + ); + } + + return tickets; + } + + public static void write(MinecraftServer server, List tickets) throws IOException { + StringBuilder raw = new StringBuilder(); + + for (VulpeusTicket ticket: tickets) { + String dim = ticket.serverWorld.getDimensionEntry().getKey().get().getValue().toString(); + long pos = ticket.chunkPos.toLong(); + int size = ticket.size; + + raw.append( + String.format("%s %d %d\n", dim, pos, size) + ); + } + + Files.writeString(getPath(server), raw.toString()); + } + + private static Path getPath(MinecraftServer server) throws IOException { + Path path = server.getSavePath(WorldSavePath.ROOT).resolve("custom_load.conf"); + path.toFile().createNewFile(); + return path; + } +} diff --git a/src/main/resources/assets/vulpeus_carpet/lang/en_us.yml b/src/main/resources/assets/vulpeus_carpet/lang/en_us.yml index 2358ca2..2bfecce 100644 --- a/src/main/resources/assets/vulpeus_carpet/lang/en_us.yml +++ b/src/main/resources/assets/vulpeus_carpet/lang/en_us.yml @@ -3,6 +3,9 @@ carpet: vulpeus: vulpeus rule: + commandCustomLoad: + desc: Enable `/custom-load` command. Inspired by AMS blockChunkLoader. + commandHat: desc: Enable `/hat` command. Ported from essential addons. From 8cc9c4e8358057237d22e86108b309e5da88fdf0 Mon Sep 17 00:00:00 2001 From: topi-banana Date: Sun, 22 Sep 2024 12:21:15 +0900 Subject: [PATCH 12/15] added maven modrinth repo for future. --- common.gradle | 6 ++++-- gradle.properties | 4 ++-- versions/1.20.1/gradle.properties | 2 +- versions/1.20.2/gradle.properties | 2 +- versions/1.20.6/gradle.properties | 2 +- versions/1.21.1/gradle.properties | 2 +- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/common.gradle b/common.gradle index 322b14c..8f53d4b 100644 --- a/common.gradle +++ b/common.gradle @@ -20,6 +20,9 @@ repositories { maven { url 'https://masa.dy.fi/maven' } + maven { + url 'https://api.modrinth.com/maven' + } } // https://github.com/FabricMC/fabric-loader/issues/783 @@ -33,9 +36,8 @@ dependencies { mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - modImplementation "carpet:fabric-carpet:${project.carpet_version}" - // dependencies + modImplementation "carpet:fabric-carpet:${project.carpet_version}" // library mods // include(modImplementation(fabricApi.module("fabric-resource-loader-v0", project.fabric_api_version))) diff --git a/gradle.properties b/gradle.properties index 3a8e7e2..0ae6342 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,12 +3,12 @@ # Fabric Basic Properties # https://fabricmc.net/versions.html - loader_version=0.16.2 + loader_version=0.16.3 # Mod Properties mod_id=vulpeus_carpet mod_name=VulpeusCarpet - mod_version=2.0.1 + mod_version=2.0.2 maven_group=com.vulpeus archives_base_name=vulpeus_carpet diff --git a/versions/1.20.1/gradle.properties b/versions/1.20.1/gradle.properties index bb3512b..6b0bf6e 100644 --- a/versions/1.20.1/gradle.properties +++ b/versions/1.20.1/gradle.properties @@ -12,4 +12,4 @@ # Dependencies fabric_api_version=0.92.2+1.20.1 - carpet_version=1.20-1.4.112+v230608 \ No newline at end of file + carpet_version=1.20-1.4.112+v230608 diff --git a/versions/1.20.2/gradle.properties b/versions/1.20.2/gradle.properties index 3f49755..d780d13 100644 --- a/versions/1.20.2/gradle.properties +++ b/versions/1.20.2/gradle.properties @@ -12,4 +12,4 @@ # Dependencies fabric_api_version=0.91.6+1.20.2 - carpet_version=1.20.6-1.4.141+v240429 \ No newline at end of file + carpet_version=1.20.6-1.4.141+v240429 diff --git a/versions/1.20.6/gradle.properties b/versions/1.20.6/gradle.properties index 6c15f47..1c718ff 100644 --- a/versions/1.20.6/gradle.properties +++ b/versions/1.20.6/gradle.properties @@ -12,4 +12,4 @@ # Dependencies fabric_api_version=0.100.4+1.20.6 - carpet_version=1.20.6-1.4.141+v240429 \ No newline at end of file + carpet_version=1.20.6-1.4.141+v240429 diff --git a/versions/1.21.1/gradle.properties b/versions/1.21.1/gradle.properties index d2b54c7..f7bacc6 100644 --- a/versions/1.21.1/gradle.properties +++ b/versions/1.21.1/gradle.properties @@ -12,4 +12,4 @@ # Dependencies fabric_api_version=0.102.1+1.21.1 - carpet_version=1.21-1.4.147+v240613 \ No newline at end of file + carpet_version=1.21-1.4.147+v240613 From 9d6e08fadc88c032ce2713a3b02aa3e961d5fdc0 Mon Sep 17 00:00:00 2001 From: topi-banana Date: Sun, 22 Sep 2024 12:22:18 +0900 Subject: [PATCH 13/15] fixed ScriptCollection crash when script dir not found. --- .../com/vulpeus/vulpeus_carpet/utils/ScriptCollection.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/vulpeus/vulpeus_carpet/utils/ScriptCollection.java b/src/main/java/com/vulpeus/vulpeus_carpet/utils/ScriptCollection.java index 5a3fe70..2dab344 100644 --- a/src/main/java/com/vulpeus/vulpeus_carpet/utils/ScriptCollection.java +++ b/src/main/java/com/vulpeus/vulpeus_carpet/utils/ScriptCollection.java @@ -34,6 +34,9 @@ public class ScriptCollection { public static void load() { URL scripts = CLASS_LOADER.getResource(String.format("%s/scripts/", ASSETS_PATH)); + if (scripts == null) { + return; + } File scriptDir = new File(scripts.getPath()); File[] scriptFiles = scriptDir.listFiles(); for (File scriptFile : scriptFiles) { From 7a5bc9ba4b932cabb29b355aea9326d51754950e Mon Sep 17 00:00:00 2001 From: topi-banana Date: Sun, 22 Sep 2024 12:42:57 +0900 Subject: [PATCH 14/15] added command document --- docs/en_us.md | 18 ++++++++++++++++++ docs/ja_jp.md | 28 +++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/docs/en_us.md b/docs/en_us.md index 6aaeb12..d86b18c 100644 --- a/docs/en_us.md +++ b/docs/en_us.md @@ -97,6 +97,24 @@ Optimize dragon respawn method. Ported from carpet AMS addition. ## Command +### custom-load + +`/custom-load` : Show current custom loading chunk list. + +`/custom-load add [] [] [] []` : add to list. + +`/custom-load remove [] []` : remove from list. + +`[]` : dimension id + +`[]` : x of the chunk at the center of the loading range. + +`[]` : z of the chunk at the center of the loading range. + +`[]` : radius + +`[]` : index of the list. you can check it with `/custom-load`. + ### hat `/hat` : Equip the item you have on your own head. Totem of undying or non-empty shulker box cannot diff --git a/docs/ja_jp.md b/docs/ja_jp.md index 5d9bbe4..27c34c6 100644 --- a/docs/ja_jp.md +++ b/docs/ja_jp.md @@ -1,5 +1,14 @@ ## ルール +### commandCustomLoad + +`/custom-load`コマンドの有効化。AMS の blockChunkLoader から発想を得ました。 + +- Type: `String` +- Default value: `ops` +- Allowed options: `true`, `false`, `ops`, `0`, `1`, `2`, `3`, `4` +- Categories: `SURVIVAL`, `COMMAND`, `VULPEUS` + ### commandHat `/hat`コマンドの有効化。essential addons からの移植。 @@ -89,8 +98,25 @@ MC-254100 の修正 ## コマンド -### hat +### custom-load + +`/custom-load` : 現在の CustomLoadingChunk のリストを表示。 + +`/custom-load add [] [] [] []` : リストに追加 + +`/custom-load remove [] []` : リストから削除 +`[]` : ディメンションID + +`[]` : ロード範囲の中心チャンクの ChunkX + +`[]` : ロード範囲の中心チャンクの ChunkZ + +`[]` : 半径 + +`[]` : 要素のインデックス。`/custom-load`で確認できます。 + +### hat `/hat` : 頭に所持しているアイテムを装備します。不死のトーテムや空でないシュルカーボックスは装備できません。また、束縛の呪いが付いた装備すでにしている場合も同様です。 From bf60337fa7f84f577ad3cc11a56f55d2c62fe5ef Mon Sep 17 00:00:00 2001 From: topi-banana Date: Sun, 22 Sep 2024 13:37:14 +0900 Subject: [PATCH 15/15] size -> radius --- docs/en_us.md | 4 ++-- docs/ja_jp.md | 4 ++-- .../commands/customLoadCommand.java | 16 +++++++------- .../CustomLoadingChunks.java | 22 +++++++++---------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/docs/en_us.md b/docs/en_us.md index d86b18c..6c2efbc 100644 --- a/docs/en_us.md +++ b/docs/en_us.md @@ -101,7 +101,7 @@ Optimize dragon respawn method. Ported from carpet AMS addition. `/custom-load` : Show current custom loading chunk list. -`/custom-load add [] [] [] []` : add to list. +`/custom-load add [] [] [] []` : add to list. `/custom-load remove [] []` : remove from list. @@ -111,7 +111,7 @@ Optimize dragon respawn method. Ported from carpet AMS addition. `[]` : z of the chunk at the center of the loading range. -`[]` : radius +`[]` : radius `[]` : index of the list. you can check it with `/custom-load`. diff --git a/docs/ja_jp.md b/docs/ja_jp.md index 27c34c6..6a063c9 100644 --- a/docs/ja_jp.md +++ b/docs/ja_jp.md @@ -102,7 +102,7 @@ MC-254100 の修正 `/custom-load` : 現在の CustomLoadingChunk のリストを表示。 -`/custom-load add [] [] [] []` : リストに追加 +`/custom-load add [] [] [] []` : リストに追加 `/custom-load remove [] []` : リストから削除 @@ -112,7 +112,7 @@ MC-254100 の修正 `[]` : ロード範囲の中心チャンクの ChunkZ -`[]` : 半径 +`[]` : 半径 `[]` : 要素のインデックス。`/custom-load`で確認できます。 diff --git a/src/main/java/com/vulpeus/vulpeus_carpet/commands/customLoadCommand.java b/src/main/java/com/vulpeus/vulpeus_carpet/commands/customLoadCommand.java index c7b03fa..e49bec5 100644 --- a/src/main/java/com/vulpeus/vulpeus_carpet/commands/customLoadCommand.java +++ b/src/main/java/com/vulpeus/vulpeus_carpet/commands/customLoadCommand.java @@ -53,7 +53,7 @@ public static void register(CommandDispatcher dispatcher) { .then( CommandManager.argument("cz", IntegerArgumentType.integer()) .then( - CommandManager.argument("size", IntegerArgumentType.integer(0, 33)) + CommandManager.argument("radius", IntegerArgumentType.integer(0, 33)) .executes( customLoadCommand::add ) @@ -81,11 +81,11 @@ private static int add(CommandContext context) throws Comma ServerWorld world = DimensionArgumentType.getDimensionArgument(context, "dim").toServerWorld(); int cx = IntegerArgumentType.getInteger(context, "cx"); int cz = IntegerArgumentType.getInteger(context, "cz"); - int size = IntegerArgumentType.getInteger(context, "size"); + int radius = IntegerArgumentType.getInteger(context, "radius"); ChunkPos chunk = new ChunkPos(cx, cz); - int index = CustomLoadingChunks.add(world, chunk, size); + int index = CustomLoadingChunks.add(world, chunk, radius); ServerCommandSource source = context.getSource(); @@ -96,7 +96,7 @@ private static int add(CommandContext context) throws Comma "g ["+cx+","+cz+"]" )); source.sendMessage(Messenger.c( - "w Radius: " + size + "w Radius: " + radius )); source.sendMessage(Messenger.c()); status(context); @@ -117,7 +117,7 @@ private static int remove(CommandContext context) { "g ["+ticket.chunkPos.x+","+ticket.chunkPos.z+"]" )); source.sendMessage(Messenger.c( - "w Radius: " + ticket.size + "w Radius: " + ticket.radius )); source.sendMessage(Messenger.c()); status(context); @@ -158,16 +158,16 @@ private static int status(CommandContext context) { String chunkPos = ticket.chunkPos.x + "," + ticket.chunkPos.z; /* - * Size + * Radius */ - String size = ticket.size + ""; + String radius = ticket.radius + ""; context.getSource().sendMessage( Messenger.c( "w|- ", "w "+index+": ", "w "+chunkPos+" ", - "w "+size+" ", + "w "+radius+" ", coloredDim ) ); diff --git a/src/main/java/com/vulpeus/vulpeus_carpet/utils/rule/commandCustomLoad/CustomLoadingChunks.java b/src/main/java/com/vulpeus/vulpeus_carpet/utils/rule/commandCustomLoad/CustomLoadingChunks.java index d9e3375..f43c4ba 100644 --- a/src/main/java/com/vulpeus/vulpeus_carpet/utils/rule/commandCustomLoad/CustomLoadingChunks.java +++ b/src/main/java/com/vulpeus/vulpeus_carpet/utils/rule/commandCustomLoad/CustomLoadingChunks.java @@ -45,27 +45,27 @@ public class CustomLoadingChunks { public static class VulpeusTicket { public ServerWorld serverWorld; public ChunkPos chunkPos; - public int size; + public int radius; - VulpeusTicket(ServerWorld serverWorld, ChunkPos chunkPos, int size) { + VulpeusTicket(ServerWorld serverWorld, ChunkPos chunkPos, int radius) { this.serverWorld = serverWorld; this.chunkPos = chunkPos; - this.size = size; + this.radius = radius; } } - public static int add(ServerWorld world, ChunkPos chunkPos, int size) { - return add(new VulpeusTicket(world, chunkPos, size)); + public static int add(ServerWorld world, ChunkPos chunkPos, int radius) { + return add(new VulpeusTicket(world, chunkPos, radius)); } public static int add(VulpeusTicket ticket) { - ticket.serverWorld.getChunkManager().addTicket(VULPEUS, ticket.chunkPos, ticket.size, Unit.INSTANCE); + ticket.serverWorld.getChunkManager().addTicket(VULPEUS, ticket.chunkPos, ticket.radius, Unit.INSTANCE); Tickets.add(ticket); return Tickets.size()-1; } public static VulpeusTicket remove(int index) { VulpeusTicket ticket = Tickets.get(index); - ticket.serverWorld.getChunkManager().removeTicket(VULPEUS, ticket.chunkPos, ticket.size, Unit.INSTANCE); + ticket.serverWorld.getChunkManager().removeTicket(VULPEUS, ticket.chunkPos, ticket.radius, Unit.INSTANCE); Tickets.remove(index); return ticket; } @@ -103,10 +103,10 @@ public static List load(MinecraftServer server) throws IOExceptio ChunkPos.getPackedZ(packedPos) ); - int size = Integer.parseInt(args[2]); + int radius = Integer.parseInt(args[2]); tickets.add( - new VulpeusTicket(serverWorld, chunkPos, size) + new VulpeusTicket(serverWorld, chunkPos, radius) ); } @@ -119,10 +119,10 @@ public static void write(MinecraftServer server, List tickets) th for (VulpeusTicket ticket: tickets) { String dim = ticket.serverWorld.getDimensionEntry().getKey().get().getValue().toString(); long pos = ticket.chunkPos.toLong(); - int size = ticket.size; + int radius = ticket.radius; raw.append( - String.format("%s %d %d\n", dim, pos, size) + String.format("%s %d %d\n", dim, pos, radius) ); }