backport1.20.1 #6

Zusammengeführt
YoyoNow hat 54 Commits von backport1.20.1 nach master 2024-02-01 19:58:32 +01:00 zusammengeführt
3 geänderte Dateien mit 14 neuen und 10 gelöschten Zeilen
Nur Änderungen aus Commit 8c6fd853ab werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -7,6 +7,7 @@ import com.moulberry.axiom.world_properties.server.ServerWorldProperty;
import net.kyori.adventure.text.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Unit;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -21,28 +22,28 @@ public class WorldPropertiesExample implements Listener {
World world = event.getWorld();
ServerWorldProperty<Boolean> checkbox = new ServerWorldProperty<>(new ResourceLocation("axiom:checkbox"),
ServerWorldProperty<Boolean> checkbox = new ServerWorldProperty<>(new NamespacedKey("axiom", "checkbox"),
"Checkbox",
false, WorldPropertyWidgetType.CHECKBOX, false, bool -> {
world.sendMessage(Component.text("Checkbox: " + bool)); // Do something with input
return true; // true to sync with client
});
ServerWorldProperty<Integer> slider = new ServerWorldProperty<>(new ResourceLocation("axiom:slider"),
ServerWorldProperty<Integer> slider = new ServerWorldProperty<>(new NamespacedKey("axiom", "slider"),
"Slider",
false, new WorldPropertyWidgetType.Slider(0, 8), 4, integer -> {
world.sendMessage(Component.text("Slider: " + integer)); // Do something with input
return true; // true to sync with client
});
ServerWorldProperty<String> textbox = new ServerWorldProperty<>(new ResourceLocation("axiom:textbox"),
ServerWorldProperty<String> textbox = new ServerWorldProperty<>(new NamespacedKey("axiom", "textbox"),
"Textbox",
false, WorldPropertyWidgetType.TEXTBOX, "Hello", string -> {
world.sendMessage(Component.text("Textbox: " + string)); // Do something with input
return true; // true to sync with client
});
ServerWorldProperty<Unit> button = new ServerWorldProperty<>(new ResourceLocation("axiom:button"),
ServerWorldProperty<Unit> button = new ServerWorldProperty<>(new NamespacedKey("axiom", "button"),
"Button",
false, WorldPropertyWidgetType.BUTTON, Unit.INSTANCE, unit -> {
world.sendMessage(Component.text("Button pressed")); // Do something with input

Datei anzeigen

@ -8,6 +8,7 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.GameRules;
import org.bukkit.GameRule;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_20_R2.CraftWorld;
import org.bukkit.entity.Player;
@ -64,7 +65,7 @@ public class ServerWorldPropertiesRegistry {
// Time
WorldPropertyCategory timeCategory = new WorldPropertyCategory("axiom.editorui.window.world_properties.time", true);
ServerWorldProperty<Integer> time = new ServerWorldProperty<>(new ResourceLocation("axiom:time"),
ServerWorldProperty<Integer> time = new ServerWorldProperty<>(new NamespacedKey("axiom", "time"),
"axiom.editorui.window.world_properties.time",
true, WorldPropertyWidgetType.TIME, 0, integer -> false
);
@ -75,14 +76,14 @@ public class ServerWorldPropertiesRegistry {
WorldPropertyCategory weatherCategory = new WorldPropertyCategory("axiom.editorui.window.world_properties.weather",
true);
ServerWorldProperty<Boolean> pauseWeather = new ServerWorldProperty<>(new ResourceLocation("axiom:pause_weather"),
ServerWorldProperty<Boolean> pauseWeather = new ServerWorldProperty<>(new NamespacedKey("axiom", "pause_weather"),
"axiom.editorui.window.world_properties.pause_weather",
true, WorldPropertyWidgetType.CHECKBOX, !world.getGameRuleValue(GameRule.DO_WEATHER_CYCLE), bool -> {
world.setGameRule(GameRule.DO_WEATHER_CYCLE, !bool);
return false;
});
ServerWorldProperty<Integer> weatherType = new ServerWorldProperty<>(new ResourceLocation("axiom:weather_type"),
ServerWorldProperty<Integer> weatherType = new ServerWorldProperty<>(new NamespacedKey("axiom", "weather_type"),
"axiom.editorui.window.world_properties.clear_weather",
true, new WorldPropertyWidgetType.ButtonArray(
List.of("axiom.editorui.window.world_properties.rain_weather", "axiom.editorui.window.world_properties.thunder_weather")

Datei anzeigen

@ -6,7 +6,9 @@ import com.moulberry.axiom.world_properties.WorldPropertyWidgetType;
import io.netty.buffer.Unpooled;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_20_R2.util.CraftNamespacedKey;
import org.bukkit.entity.Player;
import java.util.function.Predicate;
@ -20,9 +22,9 @@ public class ServerWorldProperty<T> {
private T value;
private Predicate<T> handler;
public ServerWorldProperty(ResourceLocation id, String name, boolean localizeName, WorldPropertyWidgetType<T> widget,
public ServerWorldProperty(NamespacedKey id, String name, boolean localizeName, WorldPropertyWidgetType<T> widget,
T value, Predicate<T> handler) {
this.id = id;
this.id = CraftNamespacedKey.toMinecraft(id);
this.name = name;
this.localizeName = localizeName;
this.widget = widget;