Update to 1.20.2

This commit is contained in:
Exopandora
2023-09-23 13:10:41 +02:00
parent d49beb42f6
commit 392ce3bdb4
54 changed files with 288 additions and 478 deletions

View File

@@ -2,14 +2,14 @@
mod_id = worldhandler
mod_name = WorldHandler
mod_version = 3.5
minecraft_version = 1.20.1
minecraft_version = 1.20.2
group = exopandora.worldhandler
main_class = exopandora.worldhandler.Main
author = Exopandora
# Forge
forge_version = 47.0.35
forge_compatible_minecraft_versions = 1.20,1.20.1
forge_version = 48.0.0
forge_compatible_minecraft_versions = 1.20.2
# Publishing
curse_project_id = 228970

View File

@@ -11,8 +11,8 @@ public class Main
{
public static final String NAME = "World Handler";
public static final String MODID = "worldhandler";
public static final String MC_VERSION = "1.20.1";
public static final String MOD_VERSION = "3.4.4";
public static final String MC_VERSION = "1.20.2";
public static final String MOD_VERSION = "3.5";
public static final String URL = "https://minecraft.curseforge.com/projects/world-handler-command-gui";
public static void main(String[] args)

View File

@@ -1,5 +1,6 @@
package exopandora.worldhandler.builder.argument;
import java.util.Optional;
import java.util.function.Function;
import javax.annotation.Nullable;
@@ -10,8 +11,8 @@ import net.minecraft.advancements.critereon.MinMaxBounds;
public class RangeArgument<T extends Number> implements IDeserializableArgument
{
private final Function<String, MinMaxBounds<T>> parser;
private T min;
private T max;
private Optional<T> min;
private Optional<T> max;
protected RangeArgument(Function<String, MinMaxBounds<T>> parser)
{
@@ -20,34 +21,34 @@ public class RangeArgument<T extends Number> implements IDeserializableArgument
public void setExact(@Nullable T value)
{
this.min = value;
this.max = value;
this.min = Optional.of(value);
this.max = Optional.of(value);
}
public void setRange(@Nullable T min, @Nullable T max)
{
this.min = min;
this.max = max;
this.min = Optional.of(min);
this.max = Optional.of(max);
}
public void setMin(@Nullable T min)
{
this.min = min;
this.min = Optional.of(min);
}
public void setMax(@Nullable T max)
{
this.max = max;
this.max = Optional.of(max);
}
public T getMin()
{
return this.min;
return this.min.orElse(null);
}
public T getMax()
{
return this.max;
return this.max.orElse(null);
}
@Override
@@ -56,22 +57,13 @@ public class RangeArgument<T extends Number> implements IDeserializableArgument
if(string != null)
{
MinMaxBounds<T> bounds = this.parser.apply(string);
if(bounds != null)
{
this.min = bounds.getMin();
this.max = bounds.getMax();
}
else
{
this.min = null;
this.max = null;
}
this.min = bounds.min();
this.max = bounds.max();
}
else
{
this.min = null;
this.max = null;
this.min = Optional.empty();
this.max = Optional.empty();
}
}

View File

@@ -86,22 +86,26 @@ public class TargetArgument implements IArgument
public void setDistance(@Nullable Double distance)
{
this.distance = new MinMaxBounds.Doubles(distance, distance);
this.distance = MinMaxBounds.Doubles.exactly(distance);
}
public void setDistance(@Nullable Double min, @Nullable Double max)
{
this.distance = new MinMaxBounds.Doubles(min, max);
this.distance = MinMaxBounds.Doubles.between(min, max);
}
public void setDistanceMin(@Nullable Double min)
{
this.distance = new MinMaxBounds.Doubles(min, this.distance.getMax());
this.distance = this.distance.max()
.map(max -> MinMaxBounds.Doubles.between(min, max))
.orElseGet(() -> MinMaxBounds.Doubles.exactly(min));
}
public void setDistanceMax(@Nullable Double max)
{
this.distance = new MinMaxBounds.Doubles(this.distance.getMin(), max);
this.distance = this.distance.min()
.map(min -> MinMaxBounds.Doubles.between(min, max))
.orElseGet(() -> MinMaxBounds.Doubles.exactly(max));
}
public void setX(@Nullable Double x)
@@ -146,12 +150,12 @@ public class TargetArgument implements IArgument
public void setRotationXMin(@Nullable Float min)
{
this.rotX = WrappedMinMaxBounds.between(min, this.rotX.getMax());
this.rotX = WrappedMinMaxBounds.between(min, this.rotX.max());
}
public void setRotationXMax(@Nullable Float max)
{
this.rotX = WrappedMinMaxBounds.between(this.rotX.getMin(), max);
this.rotX = WrappedMinMaxBounds.between(this.rotX.min(), max);
}
public void setRotationY(@Nullable Float rotY)
@@ -166,12 +170,12 @@ public class TargetArgument implements IArgument
public void setRotationYMin(@Nullable Float min)
{
this.rotY = WrappedMinMaxBounds.between(min, this.rotY.getMax());
this.rotY = WrappedMinMaxBounds.between(min, this.rotY.max());
}
public void setRotationYMax(@Nullable Float max)
{
this.rotY = WrappedMinMaxBounds.between(this.rotY.getMin(), max);
this.rotY = WrappedMinMaxBounds.between(this.rotY.min(), max);
}
public void setLevel(@Nullable Double level)
@@ -301,7 +305,11 @@ public class TargetArgument implements IArgument
this.scores = new HashMap<String, MinMaxBounds.Ints>();
}
this.scores.put(score, MinMaxBounds.Ints.between(min, this.scores.getOrDefault(score, MinMaxBounds.Ints.ANY).getMax()));
MinMaxBounds.Ints bounds = this.scores.getOrDefault(score, MinMaxBounds.Ints.ANY).max()
.map(max -> MinMaxBounds.Ints.between(min, max))
.orElseGet(() -> MinMaxBounds.Ints.exactly(min));
this.scores.put(score, bounds);
}
public void setScoreMax(String score, @Nullable Integer max)
@@ -311,7 +319,11 @@ public class TargetArgument implements IArgument
this.scores = new HashMap<String, MinMaxBounds.Ints>();
}
this.scores.put(score, MinMaxBounds.Ints.between(this.scores.getOrDefault(score, MinMaxBounds.Ints.ANY).getMin(), max));
MinMaxBounds.Ints bounds = this.scores.getOrDefault(score, MinMaxBounds.Ints.ANY).min()
.map(min -> MinMaxBounds.Ints.between(min, max))
.orElseGet(() -> MinMaxBounds.Ints.exactly(max));
this.scores.put(score, bounds);
}
public void setGamemode(@Nullable Gamemode gamemode)
@@ -551,13 +563,13 @@ public class TargetArgument implements IArgument
@Nullable
private static String serializeMinMaxBounds(MinMaxBounds<?> bounds)
{
return Util.serializeBounds(bounds.getMin(), bounds.getMax());
return Util.serializeBounds(bounds.min(), bounds.max());
}
@Nullable
private static String serializeWrappedMinMaxBounds(WrappedMinMaxBounds bounds)
{
return Util.serializeBounds(bounds.getMin(), bounds.getMax());
return Util.serializeBounds(bounds.min(), bounds.max());
}
@Nullable

View File

@@ -12,6 +12,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.world.effect.MobEffect;
import net.minecraftforge.registries.ForgeRegistries;
public abstract class AbstractEffectTag implements ITagProvider
{
@@ -32,11 +33,11 @@ public abstract class AbstractEffectTag implements ITagProvider
CompoundTag compound = new CompoundTag();
int ticks = instance.toTicks();
compound.putByte("Id", (byte) MobEffect.getId(entry.getKey()));
compound.putByte("Amplifier", (byte) (instance.getAmplifier() - 1));
compound.putInt("Duration", ticks > 0 ? ticks : 1000000);
compound.putBoolean("Ambient", instance.isAmbient());
compound.putBoolean("ShowParticles", instance.doShowParticles());
compound.putString("id", ForgeRegistries.MOB_EFFECTS.getKey(entry.getKey()).toString());
compound.putByte("amplifier", (byte) (instance.getAmplifier() - 1));
compound.putInt("duration", ticks > 0 ? ticks : 1000000);
compound.putBoolean("ambient", instance.isAmbient());
compound.putBoolean("show_particles", instance.doShowParticles());
list.add(compound);
}

View File

@@ -5,6 +5,6 @@ public class ActiveEffectsTag extends AbstractEffectTag
@Override
public String key()
{
return "ActiveEffects";
return "active_effects";
}
}

View File

@@ -5,6 +5,6 @@ public class CustomPotionEffectsTag extends AbstractEffectTag
@Override
public String key()
{
return "CustomPotionEffects";
return "custom_potion_effects";
}
}

View File

@@ -24,75 +24,75 @@ public class ScoreboardCommandBuilder extends CommandBuilder
private final PrimitiveArgument<String> sourceObjective = Arguments.word();
private final CommandNodeLiteral root = CommandNode.literal("scoreboard")
.then(CommandNode.literal("objectives")
.label(Label.OBJECTIVES)
.then(CommandNode.literal("add")
.then(CommandNode.argument("objective", this.objective)
.then(CommandNode.argument("criteria", this.criteria)
.label(Label.OBJECTIVES_ADD)
.then(CommandNode.argument("displayName", this.displayName)
.label(Label.OBJECTIVES_ADD_DISPLAYNAME)))))
.then(CommandNode.literal("modify")
.then(CommandNode.argument("objective", this.objective)
.then(CommandNode.literal("displayname")
.then(CommandNode.argument("displayName", this.displayName)
.label(Label.OBJECTIVES_MODIFY_DISPLAYNAME)))
.then(CommandNode.literal("rendertype")
.then(CommandNode.argument("renderType", this.renderType)
.label(Label.OBJECTIVES_MODIFY_RENDERTYPE)))))
.then(CommandNode.literal("remove")
.then(CommandNode.argument("objective", this.objective)
.label(Label.OBJECTIVES_REMOVE)))
.then(CommandNode.literal("setdisplay")
.then(CommandNode.argument("slot", this.slot)
.label(Label.OBJECTIVES_SETDISPLAY_SLOT)
.then(CommandNode.argument("objective", this.objective)
.label(Label.OBJECTIVES_SETDISPLAY_SLOT_OBJECTIVE)))))
.then(CommandNode.literal("players")
.label(Label.PLAYERS)
.then(CommandNode.literal("list")
.label(Label.PLAYERS_LIST)
.then(CommandNode.argument("target", this.target)
.label(Label.PLAYERS_LIST_TARGET)))
.then(CommandNode.literal("set")
.then(CommandNode.argument("targets", this.targets)
.then(CommandNode.argument("objective", this.objective)
.then(CommandNode.argument("score", this.score)
.label(Label.PLAYERS_SET_SCORE)))))
.then(CommandNode.literal("get")
.then(CommandNode.argument("target", this.target)
.then(CommandNode.argument("objective", this.objective)
.label(Label.PLAYERS_GET_SCORE))))
.then(CommandNode.literal("set")
.then(CommandNode.argument("targets", this.targets)
.then(CommandNode.argument("objective", this.objective)
.then(CommandNode.argument("score", this.score)
.label(Label.PLAYERS_SET_SCORE)))))
.then(CommandNode.literal("add")
.then(CommandNode.argument("targets", this.targets)
.then(CommandNode.argument("objective", this.objective)
.then(CommandNode.argument("score", this.score)
.label(Label.PLAYERS_ADD_SCORE)))))
.then(CommandNode.literal("remove")
.then(CommandNode.argument("targets", this.targets)
.then(CommandNode.argument("objective", this.objective)
.then(CommandNode.argument("score", this.score)
.label(Label.PLAYERS_REMOVE_SCORE)))))
.then(CommandNode.literal("reset")
.then(CommandNode.argument("targets", this.targets)
.then(CommandNode.argument("objective", this.objective)
.label(Label.PLAYERS_RESET_SCORE))))
.then(CommandNode.literal("enable")
.then(CommandNode.argument("targets", this.targets)
.label(Label.PLAYERS_ENABLE)
.then(CommandNode.argument("objective", this.objective)
.label(Label.PLAYERS_ENABLE_OBJECTIVE))))
.then(CommandNode.literal("operation")
.then(CommandNode.argument("targetObjective", this.objective)
.then(CommandNode.argument("operation", this.operation)
.then(CommandNode.argument("source", this.targets)
.then(CommandNode.argument("sourceObjective", this.sourceObjective)
.label(Label.PLAYERS_OPERATION)))))));
.then(CommandNode.literal("objectives")
.label(Label.OBJECTIVES)
.then(CommandNode.literal("add")
.then(CommandNode.argument("objective", this.objective)
.then(CommandNode.argument("criteria", this.criteria)
.label(Label.OBJECTIVES_ADD)
.then(CommandNode.argument("displayName", this.displayName)
.label(Label.OBJECTIVES_ADD_DISPLAYNAME)))))
.then(CommandNode.literal("modify")
.then(CommandNode.argument("objective", this.objective)
.then(CommandNode.literal("displayname")
.then(CommandNode.argument("displayName", this.displayName)
.label(Label.OBJECTIVES_MODIFY_DISPLAYNAME)))
.then(CommandNode.literal("rendertype")
.then(CommandNode.argument("renderType", this.renderType)
.label(Label.OBJECTIVES_MODIFY_RENDERTYPE)))))
.then(CommandNode.literal("remove")
.then(CommandNode.argument("objective", this.objective)
.label(Label.OBJECTIVES_REMOVE)))
.then(CommandNode.literal("setdisplay")
.then(CommandNode.argument("slot", this.slot)
.label(Label.OBJECTIVES_SETDISPLAY_SLOT)
.then(CommandNode.argument("objective", this.objective)
.label(Label.OBJECTIVES_SETDISPLAY_SLOT_OBJECTIVE)))))
.then(CommandNode.literal("players")
.label(Label.PLAYERS)
.then(CommandNode.literal("list")
.label(Label.PLAYERS_LIST)
.then(CommandNode.argument("target", this.target)
.label(Label.PLAYERS_LIST_TARGET)))
.then(CommandNode.literal("set")
.then(CommandNode.argument("targets", this.targets)
.then(CommandNode.argument("objective", this.objective)
.then(CommandNode.argument("score", this.score)
.label(Label.PLAYERS_SET_SCORE)))))
.then(CommandNode.literal("get")
.then(CommandNode.argument("target", this.target)
.then(CommandNode.argument("objective", this.objective)
.label(Label.PLAYERS_GET_SCORE))))
.then(CommandNode.literal("set")
.then(CommandNode.argument("targets", this.targets)
.then(CommandNode.argument("objective", this.objective)
.then(CommandNode.argument("score", this.score)
.label(Label.PLAYERS_SET_SCORE)))))
.then(CommandNode.literal("add")
.then(CommandNode.argument("targets", this.targets)
.then(CommandNode.argument("objective", this.objective)
.then(CommandNode.argument("score", this.score)
.label(Label.PLAYERS_ADD_SCORE)))))
.then(CommandNode.literal("remove")
.then(CommandNode.argument("targets", this.targets)
.then(CommandNode.argument("objective", this.objective)
.then(CommandNode.argument("score", this.score)
.label(Label.PLAYERS_REMOVE_SCORE)))))
.then(CommandNode.literal("reset")
.then(CommandNode.argument("targets", this.targets)
.then(CommandNode.argument("objective", this.objective)
.label(Label.PLAYERS_RESET_SCORE))))
.then(CommandNode.literal("enable")
.then(CommandNode.argument("targets", this.targets)
.label(Label.PLAYERS_ENABLE)
.then(CommandNode.argument("objective", this.objective)
.label(Label.PLAYERS_ENABLE_OBJECTIVE))))
.then(CommandNode.literal("operation")
.then(CommandNode.argument("targetObjective", this.objective)
.then(CommandNode.argument("operation", this.operation)
.then(CommandNode.argument("source", this.targets)
.then(CommandNode.argument("sourceObjective", this.sourceObjective)
.label(Label.PLAYERS_OPERATION)))))));
public PrimitiveArgument<String> objective()
{

View File

@@ -1,7 +1,5 @@
package exopandora.worldhandler.config;
import java.util.Arrays;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
@@ -20,7 +18,6 @@ public class ConfigCategorySkin
private final IntValue buttonGreen;
private final IntValue buttonBlue;
private final IntValue buttonAlpha;
private final ConfigValue<String> type;
private final BooleanValue sharpEdges;
private final BooleanValue drawBackground;
@@ -75,11 +72,6 @@ public class ConfigCategorySkin
.comment("Button alpha")
.defineInRange("button_alpha", 255, 0, 255);
this.type = builder
.translation("gui.worldhandler.config.skin.textures")
.comment("Background texture (resourcepack, vanilla)")
.defineInList("textures", "resourcepack", Arrays.asList("resourcepack", "vanilla"));
this.sharpEdges = builder
.translation("gui.worldhandler.config.skin.sharp_tab_edges")
.comment("Whether or not the gui has sharp or smooth tab edges")
@@ -212,16 +204,6 @@ public class ConfigCategorySkin
Config.set(this.buttonBlue, blue);
}
public String getTextureType()
{
return this.type.get();
}
public void setTextureType(String type)
{
Config.set(this.type, type);
}
public boolean sharpEdges()
{
return this.sharpEdges.get();

View File

@@ -88,9 +88,9 @@ public class Category
public static void createRegistry(NewRegistryEvent event)
{
event.create(new RegistryBuilder<Category>()
.setName(REGISTRY_KEY.location())
.disableSaving()
.disableSync(), registry -> REGISTRY = registry);
.setName(REGISTRY_KEY.location())
.disableSaving()
.disableSync(), registry -> REGISTRY = registry);
}
@SubscribeEvent

View File

@@ -22,7 +22,6 @@ import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
import exopandora.worldhandler.gui.widget.menu.IMenu;
import exopandora.worldhandler.util.ActionHelper;
import exopandora.worldhandler.util.RenderUtils;
import exopandora.worldhandler.util.ResourceHelper;
import exopandora.worldhandler.util.TextUtils;
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
@@ -30,6 +29,7 @@ import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Renderable;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
public class GuiWorldHandler extends Container
{
@@ -42,6 +42,7 @@ public class GuiWorldHandler extends Container
widgets.add(new WidgetCommandSyntax());
widgets.add(new WidgetShortcuts());
});
private static final ResourceLocation BACKGROUND_TEXTURE = new ResourceLocation("textures/gui/demo_background.png");
private final Content content;
@@ -153,19 +154,21 @@ public class GuiWorldHandler extends Container
if(Config.getSkin().drawBackground())
{
super.renderBackground(guiGraphics);
super.renderBackground(guiGraphics, mouseX, mouseY, partialTicks);
}
RenderSystem.enableBlend();
RenderUtils.colorDefaultBackground();
RenderUtils.colorDefaultBackground(guiGraphics);
guiGraphics.blit(ResourceHelper.backgroundTexture(), backgroundX, backgroundY, 0, 0, this.getBackgroundWidth(), this.getBackgroundHeight());
guiGraphics.blit(BACKGROUND_TEXTURE, backgroundX, backgroundY, 0, 0, this.getBackgroundWidth(), this.getBackgroundHeight());
final String label = Main.MC_VERSION + "-" + Main.MOD_VERSION;
final int versionWidth = this.width - this.font.width(label) - 2;
final int versionHeight = this.height - 10;
guiGraphics.drawString(this.font, label, versionWidth, versionHeight, Config.getSkin().getLabelColor() + 0x33000000, false);
RenderUtils.resetColor(guiGraphics);
int x = this.getContentX();
int y = this.getContentY();
@@ -298,22 +301,22 @@ public class GuiWorldHandler extends Container
}
@Override
public boolean mouseScrolled(double mouseX, double mouseY, double distance)
public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY)
{
for(IContainerWidget widget : WIDGETS)
{
if(widget.isEnabled() && widget.mouseScrolled(mouseX, mouseY, distance))
if(widget.isEnabled() && widget.mouseScrolled(mouseX, mouseY, scrollX, scrollY))
{
return true;
}
}
if(this.content.mouseScrolled(mouseX, mouseY, distance))
if(this.content.mouseScrolled(mouseX, mouseY, scrollX, scrollY))
{
return true;
}
return super.mouseScrolled(mouseX, mouseY, distance);
return super.mouseScrolled(mouseX, mouseY, scrollX, scrollY);
}
@Override

View File

@@ -53,9 +53,9 @@ public abstract class Content implements IContent
public static void createRegistry(NewRegistryEvent event)
{
event.create(new RegistryBuilder<Content>()
.setName(REGISTRY_KEY.location())
.disableSaving()
.disableSync(), registry -> REGISTRY = registry);
.setName(REGISTRY_KEY.location())
.disableSaving()
.disableSync(), registry -> REGISTRY = registry);
}
@SubscribeEvent

View File

@@ -22,7 +22,7 @@ import exopandora.worldhandler.util.ActionHelper;
import exopandora.worldhandler.util.AdvancementHelper;
import exopandora.worldhandler.util.CommandHelper;
import net.minecraft.ChatFormatting;
import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.AdvancementHolder;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
@@ -43,33 +43,33 @@ public class ContentAdvancements extends Content
@Override
public void initGui(Container container, int x, int y)
{
List<Advancement> advancements = AdvancementHelper.getInstance().getAdvancements().stream()
.filter(advancement -> advancement.getDisplay() != null)
List<AdvancementHolder> advancements = AdvancementHelper.getInstance().getAdvancements().stream()
.filter(advancement -> advancement.value().display().isPresent())
.collect(Collectors.toList());
MenuPageList<Advancement> list = new MenuPageList<Advancement>(x, y, advancements, 114, 20, 3, container, new ILogicPageList<Advancement>()
MenuPageList<AdvancementHolder> list = new MenuPageList<AdvancementHolder>(x, y, advancements, 114, 20, 3, container, new ILogicPageList<AdvancementHolder>()
{
@Override
public MutableComponent translate(Advancement item)
public MutableComponent translate(AdvancementHolder item)
{
return (MutableComponent) item.getDisplay().getTitle();
return (MutableComponent) item.value().display().get().getTitle();
}
@Override
public MutableComponent toTooltip(Advancement item)
public MutableComponent toTooltip(AdvancementHolder item)
{
return Component.literal(item.getId().toString());
return Component.literal(item.id().toString());
}
@Override
public void onClick(Advancement item)
public void onClick(AdvancementHolder item)
{
ContentAdvancements.this.builderAdvancement.advancement().set(item.getId());
ContentAdvancements.this.builderAdvancement.advancement().set(item.id());
container.initButtons();
}
@Override
public GuiButtonBase onRegister(int x, int y, int width, int height, MutableComponent text, Advancement item, ActionHandler actionHandler)
public GuiButtonBase onRegister(int x, int y, int width, int height, MutableComponent text, AdvancementHolder item, ActionHandler actionHandler)
{
return new GuiButtonTooltip(x, y, width, height, text, this.toTooltip(item), actionHandler);
}

View File

@@ -140,12 +140,6 @@ public class ContentButcher extends Content
}
}
@Override
public void tick(Container container)
{
this.radiusField.tick();
}
@Override
public Category getCategory()
{

View File

@@ -53,31 +53,29 @@ public class ContentChangeWorld extends ContentChild
private static IConnection disconnect()
{
boolean isIntegrated = Minecraft.getInstance().isLocalServer();
boolean isRealms = Minecraft.getInstance().isConnectedToRealms();
ServerData data = Minecraft.getInstance().getCurrentServer();
Minecraft minecraft = Minecraft.getInstance();
boolean isIntegrated = minecraft.isLocalServer();
ServerData serverData = minecraft.getCurrentServer();
minecraft.level.disconnect();
if(isIntegrated)
{
String folder = Minecraft.getInstance().getSingleplayerServer().storageSource.getLevelId();
Minecraft.getInstance().level.disconnect();
Minecraft.getInstance().clearLevel(new GenericDirtMessageScreen(Component.translatable("menu.savingLevel")));
String folder = minecraft.getSingleplayerServer().storageSource.getLevelId();
minecraft.disconnect(new GenericDirtMessageScreen(Component.translatable("menu.savingLevel")));
return new IntegratedConnection(folder);
}
if(Minecraft.getInstance().level != null)
else
{
Minecraft.getInstance().level.disconnect();
Minecraft.getInstance().clearLevel();
minecraft.disconnect();
}
if(isRealms)
if(serverData.isRealm())
{
return null;
}
return new DedicatedConnection(data);
return new DedicatedConnection(serverData);
}
private static void reconnect(IConnection connection)

View File

@@ -199,15 +199,6 @@ public class ContentCommandStack extends ContentChild
buttonScrollDown.active = this.scroll < this.getCommandCount() - 3;
}
@Override
public void tick(Container container)
{
this.iterate(index ->
{
this.textfields.get(index).tick();
});
}
private void iterate(Consumer<Integer> consumer)
{
for(int x = 0; x < this.textfields.size() && x + this.scroll < this.getCommandCount(); x++)

View File

@@ -41,7 +41,7 @@ public class ContentContinue extends ContentChild
this.commandField = new GuiHintTextField(x + 116 / 2, y + 12, 116, 20);
this.commandField.setFocused(false);
this.commandField.setValue(this.builder.toCommand(this.label, false));
this.commandField.moveCursorToStart();
this.commandField.moveCursorToStart(false);
this.commandField.setFilter(text -> text.equals(this.commandField.getValue()));
}

View File

@@ -16,8 +16,8 @@ import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.gui.content.Content;
import exopandora.worldhandler.gui.content.Contents;
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
import exopandora.worldhandler.gui.widget.button.GuiSlider;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
import exopandora.worldhandler.gui.widget.button.GuiSlider;
import exopandora.worldhandler.gui.widget.button.LogicSliderAttribute;
import exopandora.worldhandler.gui.widget.button.LogicSliderSimple;
import exopandora.worldhandler.gui.widget.menu.impl.ILogicPageList;
@@ -304,17 +304,6 @@ public class ContentCustomItem extends Content
CommandHelper.sendCommand(player, this.builderCutomItem, GiveCommandBuilder.Label.GIVE, this.display.getName().isStyled());
}
@Override
public void tick(Container container)
{
if(Page.START.equals(this.page) && this.startPage == 0)
{
this.itemField.tick();
this.itemLore1Field.tick();
this.itemLore2Field.tick();
}
}
@Override
public Category getCategory()
{

View File

@@ -307,33 +307,9 @@ public class ContentEditBlocks extends Content
@Override
public void tick(Container container)
{
if(Page.COORDINATES.equals(this.page))
{
this.x1Field.tick();
this.y1Field.tick();
this.z1Field.tick();
this.x2Field.tick();
this.y2Field.tick();
this.z2Field.tick();
}
else if(Page.FILL.equals(this.page))
{
this.block1Field.tick();
}
else if(Page.REPLACE.equals(this.page))
{
this.block1Field.tick();
this.block2Field.tick();
}
else if(Page.CLONE.equals(this.page))
if(Page.CLONE.equals(this.page))
{
this.builderClone.destination().set(Minecraft.getInstance().player.blockPosition());
if(Mask.FILTERED.equals(this.mask))
{
this.filterField.tick();
}
}
}

View File

@@ -49,7 +49,7 @@ public class ContentGamerules extends Content
this.valueField = new GuiHintTextField(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.generic.value"));
this.valueField.setFilter(Predicates.notNull());
this.valueField.setValue(this.value);
this.valueField.moveCursorToEnd();
this.valueField.moveCursorToEnd(false);
this.valueField.setResponder(text ->
{
this.value = text;
@@ -150,15 +150,6 @@ public class ContentGamerules extends Content
CommandHelper.sendCommand(player, builder, GameRuleCommandBuilder.Label.GAMERULE_VALUE);
}
@Override
public void tick(Container container)
{
if(!this.booleanValue)
{
this.valueField.tick();
}
}
@Override
public Category getCategory()
{

View File

@@ -265,20 +265,6 @@ public class ContentMultiplayer extends Content
}
}
@Override
public void tick(Container container)
{
if(Page.KICK_AND_BAN.equals(this.page))
{
this.reasonField.tick();
}
if(!Page.RUNTIME.equals(this.page))
{
this.playerField.tick();
}
}
private void setPlayer(String player)
{
this.builderBan.targets().setTarget(player);

View File

@@ -188,7 +188,7 @@ public class ContentPlayer extends Content
guiGraphics.drawString(minecraft.font, minecraft.player.getName(), container.width / 2 - playerNameWidth + 59, yPos - 73, 0xE0E0E0);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
InventoryScreen.renderEntityInInventoryFollowsMouse(guiGraphics, xPos, yPos, 30, xPos - mouseX, yPos - mouseY - 44, minecraft.player);
InventoryScreen.renderEntityInInventoryFollowsMouse(guiGraphics, xPos, yPos, 30, xPos - mouseX, yPos - mouseY - 44, 0.0625F, (float) mouseX, (float) mouseY, minecraft.player);
RenderSystem.defaultBlendFunc();
}
}

View File

@@ -21,7 +21,7 @@ import net.minecraft.core.RegistryAccess;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeHolder;
public class ContentRecipes extends Content
{
@@ -37,41 +37,41 @@ public class ContentRecipes extends Content
@Override
public void initGui(Container container, int x, int y)
{
List<Recipe<?>> recipes = Minecraft.getInstance().player.getRecipeBook().getCollections().stream()
List<RecipeHolder<?>> recipes = Minecraft.getInstance().player.getRecipeBook().getCollections().stream()
.flatMap(recipe -> recipe.getRecipes().stream())
.filter(recipe -> !recipe.isSpecial())
.filter(recipe -> !recipe.value().isSpecial())
.collect(Collectors.toList());
MenuPageList<Recipe<?>> list = new MenuPageList<Recipe<?>>(x, y, recipes, 114, 20, 3, container, new ILogicPageList<Recipe<?>>()
MenuPageList<RecipeHolder<?>> list = new MenuPageList<RecipeHolder<?>>(x, y, recipes, 114, 20, 3, container, new ILogicPageList<RecipeHolder<?>>()
{
@Override
public MutableComponent translate(Recipe<?> recipe)
public MutableComponent translate(RecipeHolder<?> recipe)
{
RegistryAccess registryAccess = Minecraft.getInstance().level.registryAccess();
if(!ItemStack.EMPTY.equals(recipe.getResultItem(registryAccess)))
if(!ItemStack.EMPTY.equals(recipe.value().getResultItem(registryAccess)))
{
return (MutableComponent) recipe.getResultItem(registryAccess).getHoverName();
return (MutableComponent) recipe.value().getResultItem(registryAccess).getHoverName();
}
return Component.literal(recipe.getId().toString());
return Component.literal(recipe.id().toString());
}
@Override
public MutableComponent toTooltip(Recipe<?> recipe)
public MutableComponent toTooltip(RecipeHolder<?> recipe)
{
return Component.literal(recipe.getId().toString());
return Component.literal(recipe.id().toString());
}
@Override
public void onClick(Recipe<?> recipe)
public void onClick(RecipeHolder<?> recipe)
{
ContentRecipes.this.builderRecipe.recipe().set(recipe.getId());
ContentRecipes.this.builderRecipe.recipe().set(recipe.id());
container.initButtons();
}
@Override
public GuiButtonBase onRegister(int x, int y, int width, int height, MutableComponent text, Recipe<?> recipe, ActionHandler actionHandler)
public GuiButtonBase onRegister(int x, int y, int width, int height, MutableComponent text, RecipeHolder<?> recipe, ActionHandler actionHandler)
{
return new GuiButtonTooltip(x, y, width, height, text, this.toTooltip(recipe), actionHandler);
}

View File

@@ -80,7 +80,7 @@ public class ContentScoreboardObjectives extends ContentScoreboard
return Component.translatable("gui.worldhandler.scoreboard.objectives.stat.killed_by");
}
return Component.translatable(type.getTranslationKey());
return (MutableComponent) type.getDisplayName();
}
String translation = TranslationHelper.translate(resource);
@@ -246,15 +246,6 @@ public class ContentScoreboardObjectives extends ContentScoreboard
button1.active = Page.UNDISPLAY.equals(this.page) || BUILDER.objective().get() != null && !BUILDER.objective().get().isEmpty();
}
@Override
public void tick(Container container)
{
if(!Page.UNDISPLAY.equals(this.page))
{
this.objectField.tick();
}
}
@Override
public MutableComponent getTabTitle()
{

View File

@@ -11,8 +11,8 @@ import exopandora.worldhandler.gui.content.Content;
import exopandora.worldhandler.gui.content.Contents;
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
import exopandora.worldhandler.gui.widget.button.GuiSlider;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
import exopandora.worldhandler.gui.widget.button.GuiSlider;
import exopandora.worldhandler.gui.widget.button.LogicSliderSimple;
import exopandora.worldhandler.util.ActionHelper;
import exopandora.worldhandler.util.CommandHelper;
@@ -213,11 +213,7 @@ public class ContentScoreboardPlayers extends ContentScoreboard
@Override
public void tick(Container container)
{
if(Page.TAG.equals(this.page))
{
this.tagField.tick();
}
else
if(!Page.TAG.equals(this.page))
{
boolean enabled = BUILDER.objective().get() != null && !BUILDER.objective().get().isEmpty();
@@ -233,8 +229,6 @@ public class ContentScoreboardPlayers extends ContentScoreboard
this.addButton.active = enabled && this.builderTrigger.value().get() > 0;
this.removeButton.active = enabled;
}
this.objectField.tick();
}
}

View File

@@ -211,12 +211,6 @@ public class ContentScoreboardTeams extends ContentScoreboard
container.addRenderableWidget(this.teamField);
}
@Override
public void tick(Container container)
{
this.teamField.tick();
}
@Override
public MutableComponent getTabTitle()
{

View File

@@ -159,15 +159,6 @@ public class ContentSettings extends ContentChild
}
}
@Override
public void tick(Container container)
{
if(this.setting instanceof IntegerSetting)
{
this.valueField.tick();
}
}
@Override
public MutableComponent getTitle()
{

View File

@@ -83,7 +83,7 @@ public class ContentSignEditor extends Content
this.commandField = new GuiHintTextField(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.blocks.sign_editor.commmand"));
this.commandField.setFilter(Predicates.notNull());
this.commandField.setValue(this.texts.getLine(this.selectedLine).getCommand());
this.commandField.moveCursorToEnd();
this.commandField.moveCursorToEnd(false);
this.commandField.setResponder(text ->
{
this.texts.getLine(this.selectedLine).setCommand(text);
@@ -170,15 +170,6 @@ public class ContentSignEditor extends Content
}
}
@Override
public void tick(Container container)
{
if(this.isActive && !this.editColor)
{
this.commandField.tick();
}
}
private void toggleEditColor(Container container)
{
this.editColor = !this.editColor;

View File

@@ -28,8 +28,8 @@ import exopandora.worldhandler.gui.widget.button.EnumIcon;
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
import exopandora.worldhandler.gui.widget.button.GuiButtonIcon;
import exopandora.worldhandler.gui.widget.button.GuiButtonItem;
import exopandora.worldhandler.gui.widget.button.GuiSlider;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
import exopandora.worldhandler.gui.widget.button.GuiSlider;
import exopandora.worldhandler.gui.widget.button.LogicSliderAttribute;
import exopandora.worldhandler.gui.widget.button.LogicSliderSimple;
import exopandora.worldhandler.gui.widget.menu.impl.ILogicColorMenu;
@@ -498,19 +498,6 @@ public class ContentSummon extends Content
}
}
@Override
public void tick(Container container)
{
if(Page.START.equals(this.page))
{
if(!this.editColor)
{
this.mobField.tick();
this.nbtField.tick();
}
}
}
@Override
public void drawScreen(GuiGraphics guiGraphics, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
{

View File

@@ -123,14 +123,6 @@ public class ContentUsercontent extends Content
@Override
public void tick(Container container)
{
for(VisibleObject<EditBox> textfield : this.textfields.values())
{
if(textfield.isVisible(this.engineAdapter))
{
textfield.get().tick();
}
}
this.updateButtons();
this.updateTextfields();
}

View File

@@ -53,7 +53,7 @@ public class ContentWorldInfo extends Content
this.seedField = new GuiHintTextField(x + 118, y + 36, 114, 20);
this.seedField.setValue(I18n.get("gui.worldhandler.world_info.world.seed") + ": " + ContentWorldInfo.format(server, object -> object.overworld().getSeed()));
this.seedField.setFilter(string -> string.equals(this.seedField.getValue()));
this.seedField.moveCursorToStart();
this.seedField.moveCursorToStart(false);
this.currentTimeField = new GuiHintTextField(x + 118, y + 24, 114, 20);
this.updateCurrentTime();
@@ -125,7 +125,6 @@ public class ContentWorldInfo extends Content
{
this.updateCurrentTime();
this.updateTotalTime();
this.seedField.tick();
}
private void updateCurrentTime()

View File

@@ -30,11 +30,6 @@ public class WidgetCommandSyntax implements IContainerWidget
public void tick(Container container)
{
this.updateSyntax(container);
if(this.syntaxField != null)
{
this.syntaxField.tick();
}
}
private void updateSyntax(Container container)
@@ -53,7 +48,7 @@ public class WidgetCommandSyntax implements IContainerWidget
}
this.syntaxField.setFilter(string -> string.equals(this.syntaxField.getValue()));
this.syntaxField.moveCursorToStart();
this.syntaxField.moveCursorToStart(false);
}
}

View File

@@ -48,7 +48,7 @@ public class WidgetNameField implements IContainerWidget
{
if(this.nameField.isFocused())
{
this.nameField.moveCursorToEnd();
this.nameField.moveCursorToEnd(false);
}
return false;
@@ -59,7 +59,7 @@ public class WidgetNameField implements IContainerWidget
{
if(this.nameField.isFocused())
{
this.nameField.moveCursorToEnd();
this.nameField.moveCursorToEnd(false);
}
return false;

View File

@@ -9,7 +9,6 @@ import exopandora.worldhandler.gui.content.Content;
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
import exopandora.worldhandler.util.ActionHelper;
import exopandora.worldhandler.util.RenderUtils;
import exopandora.worldhandler.util.ResourceHelper;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
@@ -21,6 +20,7 @@ import net.minecraft.util.Mth;
public class WidgetTabRenderer implements IContainerWidget
{
private static final ResourceLocation TAB_TEXTURE = new ResourceLocation("textures/gui/demo_background.png");
private static final int SPACING = 2;
private static final int WEDGE_HEIGHT = 10;
@@ -54,7 +54,6 @@ public class WidgetTabRenderer implements IContainerWidget
{
Content content = container.getContent();
Category category = content.getCategory();
ResourceLocation texture = ResourceHelper.backgroundTexture();
int xPos = container.getBackgroundX();
int yPos = container.getBackgroundY();
@@ -72,20 +71,20 @@ public class WidgetTabRenderer implements IContainerWidget
if(content.getActiveContent().equals(tab))
{
int height = Config.getSkin().getBackgroundAlphaInt() == 255 ? 25 : 22;
this.drawActiveTab(guiGraphics, container, texture, index, size, xPos + offset, yPos - 22, width, height, title);
this.drawActiveTab(guiGraphics, container, TAB_TEXTURE, index, size, xPos + offset, yPos - 22, width, height, title);
}
else
{
this.drawInactiveTab(guiGraphics, container, texture, index, size, xPos + offset, yPos - 20, width, 20, title);
this.drawInactiveTab(guiGraphics, container, TAB_TEXTURE, index, size, xPos + offset, yPos - 20, width, 20, title);
}
}
RenderUtils.colorDefaultBackground();
RenderUtils.resetColor(guiGraphics);
}
private void drawActiveTab(GuiGraphics guiGraphics, Container container, ResourceLocation texture, int index, int size, int x, int y, int width, int height, Component title)
{
RenderUtils.colorDefaultBackground();
RenderUtils.colorDefaultBackground(guiGraphics);
this.drawTabBackground(guiGraphics, container, texture, x, y, width, height);
if(!Config.getSkin().sharpEdges())
@@ -127,7 +126,7 @@ public class WidgetTabRenderer implements IContainerWidget
private void drawInactiveTab(GuiGraphics guiGraphics, Container container, ResourceLocation texture, int index, int size, int x, int y, int width, int height, Component title)
{
RenderUtils.colorDarkBackground();
RenderUtils.colorDarkBackground(guiGraphics);
this.drawTabBackground(guiGraphics, container, texture, x, y, width, 20);
if(!Config.getSkin().sharpEdges())

View File

@@ -2,14 +2,14 @@ package exopandora.worldhandler.gui.widget.button;
import com.mojang.blaze3d.systems.RenderSystem;
import exopandora.worldhandler.config.Config;
import exopandora.worldhandler.Main;
import exopandora.worldhandler.util.ActionHandler;
import exopandora.worldhandler.util.ActionHelper;
import exopandora.worldhandler.util.RenderUtils;
import exopandora.worldhandler.util.ResourceHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractButton;
import net.minecraft.client.gui.components.WidgetSprites;
import net.minecraft.client.gui.narration.NarrationElementOutput;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
@@ -17,6 +17,13 @@ import net.minecraft.util.Mth;
public class GuiButtonBase extends AbstractButton
{
protected static final WidgetSprites VANILLA_BUTTON_SPRITES = new WidgetSprites
(
new ResourceLocation(Main.MODID, "textures/skins/vanilla/button.png"),
new ResourceLocation(Main.MODID, "textures/skins/vanilla/button_disabled.png"),
new ResourceLocation(Main.MODID, "textures/skins/vanilla/button_highlighted.png")
);
private final ActionHandler actionHandler;
public GuiButtonBase(int x, int y, int width, int height, String translationKey, ActionHandler actionHandler)
@@ -40,51 +47,10 @@ public class GuiButtonBase extends AbstractButton
protected void renderBackground(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks)
{
RenderSystem.enableBlend();
RenderUtils.colorDefaultButton();
int textureY = this.getTextureY();
ResourceLocation texture = ResourceHelper.buttonTexture();
int hWidth = this.width / 2;
int hHeight = this.height / 2;
if(Config.getSkin().getTextureType().equals("resourcepack"))
{
int textureOffset = 46 + textureY * 20;
guiGraphics.blit(texture, this.getX(), this.getY(), 0, textureOffset, hWidth, hHeight);
guiGraphics.blit(texture, this.getX(), this.getY() + hHeight, 0, textureOffset + 20 - hHeight, hWidth, hHeight);
guiGraphics.blit(texture, this.getX() + hWidth, this.getY(), 200 - hWidth, textureOffset, hWidth, hHeight);
guiGraphics.blit(texture, this.getX() + hWidth, this.getY() + hHeight, 200 - hWidth, textureOffset + 20 - hHeight, hWidth, hHeight);
}
else
{
int textureOffset = textureY * 20;
guiGraphics.blit(texture, this.getX(), this.getY(), 0, textureOffset, hWidth, hHeight);
guiGraphics.blit(texture, this.getX(), this.getY() + hHeight, 0, textureOffset + 20 - hHeight, hWidth, hHeight);
guiGraphics.blit(texture, this.getX() + hWidth, this.getY(), 200 - hWidth, textureOffset, this.width / 2, hHeight);
guiGraphics.blit(texture, this.getX() + hWidth, this.getY() + hHeight, 200 - hWidth, textureOffset + 20 - hHeight, hWidth, hHeight);
}
RenderUtils.colorDefaultButton(guiGraphics);
guiGraphics.blitSprite(SPRITES.get(this.active, this.isHoveredOrFocused()), this.getX(), this.getY(), this.getWidth(), this.getHeight());
RenderUtils.resetColor(guiGraphics);
RenderSystem.disableBlend();
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
}
protected int getTextureY()
{
int i = 1;
if(!this.active)
{
i = 0;
}
else if(this.isHoveredOrFocused())
{
i = 2;
}
return i;
}
@Override

View File

@@ -69,6 +69,22 @@ public class GuiButtonPiano extends GuiButtonBase
}
}
protected int getTextureY()
{
int i = 1;
if(!this.active)
{
i = 0;
}
else if(this.isHoveredOrFocused())
{
i = 2;
}
return i;
}
protected void drawWhiteKey(GuiGraphics guiGraphics, int hoverstate)
{
int textColor = this.getFGColor();

View File

@@ -4,11 +4,9 @@ import java.util.Objects;
import com.mojang.blaze3d.systems.RenderSystem;
import exopandora.worldhandler.config.Config;
import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.util.ILogic;
import exopandora.worldhandler.util.RenderUtils;
import exopandora.worldhandler.util.ResourceHelper;
import exopandora.worldhandler.util.TextUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
@@ -19,6 +17,9 @@ import net.minecraft.resources.ResourceLocation;
public class GuiSlider extends GuiButtonBase
{
private static final ResourceLocation SLIDER_SPRITE = new ResourceLocation("widget/slider");
private static final ResourceLocation SLIDER_HANDLE_SPRITE = new ResourceLocation("widget/slider_handle");
private static final ResourceLocation SLIDER_HANDLE_HIGHLIGHTED_SPRITE = new ResourceLocation("widget/slider_handle_highlighted");
private final Persistence persistence;
private final ILogicSlider logic;
private final Container container;
@@ -38,28 +39,22 @@ public class GuiSlider extends GuiButtonBase
public void renderBackground(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks)
{
super.renderBackground(guiGraphics, mouseX, mouseY, partialTicks);
int textureOffset = (Config.getSkin().getTextureType().equals("resourcepack") ? 66 : 20);
if(this.isHoveredOrFocused())
{
textureOffset += 20;
}
RenderSystem.enableBlend();
RenderUtils.colorDefaultButton();
ResourceLocation texture = ResourceHelper.buttonTexture();
guiGraphics.blit(texture, this.getX() + (int) (this.persistence.getValue() * (float) (this.width - 8)), this.getY(), 0, textureOffset, 4, 20);
guiGraphics.blit(texture, this.getX() + (int) (this.persistence.getValue() * (float) (this.width - 8)) + 4, this.getY(), 196, textureOffset, 4, 20);
RenderUtils.colorDefaultButton(guiGraphics);
guiGraphics.blitSprite(this.getSprite(), this.getX(), this.getY(), this.getWidth(), this.getHeight());
guiGraphics.blitSprite(this.getHandleSprite(), this.getX() + (int) (this.persistence.getValue() * (float) (this.width - 8)), this.getY(), 8, this.getHeight());
RenderUtils.resetColor(guiGraphics);
RenderSystem.disableBlend();
}
@Override
protected int getTextureY()
protected ResourceLocation getSprite()
{
return 0;
return SLIDER_SPRITE;
}
protected ResourceLocation getHandleSprite()
{
return this.isHoveredOrFocused() ? SLIDER_HANDLE_HIGHLIGHTED_SPRITE : SLIDER_HANDLE_SPRITE;
}
@Override

View File

@@ -143,10 +143,7 @@ public class MenuColorField extends Menu
@Override
public void tick()
{
if(this.logic.doDrawTextField())
{
this.textField.tick();
}
}
@Override

View File

@@ -63,14 +63,14 @@ public class UsercontentLoader
}
final Gson gson = new GsonBuilder()
.registerTypeAdapter(ArgumentType.class, new EnumTypeAdapter<ArgumentType>(ArgumentType.class))
.registerTypeAdapter(EnumIcon.class, new EnumTypeAdapter<EnumIcon>(EnumIcon.class))
.registerTypeAdapter(BooleanExpression.Type.class, new EnumTypeAdapter<BooleanExpression.Type>(BooleanExpression.Type.class))
.registerTypeAdapter(JsonWidget.Type.class, new EnumTypeAdapter<JsonWidget.Type>(JsonWidget.Type.class))
.registerTypeAdapter(Action.Type.class, new EnumTypeAdapter<Action.Type>(Action.Type.class))
.registerTypeAdapter(JsonMenu.Type.class, new EnumTypeAdapter<JsonMenu.Type>(JsonMenu.Type.class))
.setPrettyPrinting()
.create();
.registerTypeAdapter(ArgumentType.class, new EnumTypeAdapter<ArgumentType>(ArgumentType.class))
.registerTypeAdapter(EnumIcon.class, new EnumTypeAdapter<EnumIcon>(EnumIcon.class))
.registerTypeAdapter(BooleanExpression.Type.class, new EnumTypeAdapter<BooleanExpression.Type>(BooleanExpression.Type.class))
.registerTypeAdapter(JsonWidget.Type.class, new EnumTypeAdapter<JsonWidget.Type>(JsonWidget.Type.class))
.registerTypeAdapter(Action.Type.class, new EnumTypeAdapter<Action.Type>(Action.Type.class))
.registerTypeAdapter(JsonMenu.Type.class, new EnumTypeAdapter<JsonMenu.Type>(JsonMenu.Type.class))
.setPrettyPrinting()
.create();
final Path categories = path.resolve("categories.json");
if(Files.exists(categories) && Files.isRegularFile(categories) && Files.isReadable(categories))
@@ -85,10 +85,10 @@ public class UsercontentLoader
}
final List<Path> folders = Files.list(path)
.filter(Files::isDirectory)
.filter(Files::isReadable)
.filter(UsercontentLoader::isValidPathName)
.collect(Collectors.toList());
.filter(Files::isDirectory)
.filter(Files::isReadable)
.filter(UsercontentLoader::isValidPathName)
.collect(Collectors.toList());
for(Path folder : folders)
{

View File

@@ -6,7 +6,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.stream.Collectors;
import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.AdvancementHolder;
import net.minecraft.client.Minecraft;
import net.minecraft.server.ServerAdvancementManager;
import net.minecraft.server.packs.PackResources;
@@ -40,7 +40,7 @@ public class AdvancementHelper implements PreparableReloadListener
});
}
public Collection<Advancement> getAdvancements()
public Collection<AdvancementHolder> getAdvancements()
{
return this.manager.getAllAdvancements();
}

View File

@@ -41,9 +41,9 @@ public class RenderUtils
poseStack.popPose();
RenderUtils.colorDefaultButton();
colorDefaultButton(guiGraphics);
guiGraphics.blit(ResourceHelper.iconTexture(), width + 0, height, 48, 0, 10, 10);
guiGraphics.setColor(1.0F, 1.0F, 1.0F, 1.0F);
poseStack.pushPose();
poseStack.scale(0.5F, 0.5F, 0.5F);
@@ -51,39 +51,44 @@ public class RenderUtils
poseStack.popPose();
}
public static void colorDefaultButton()
public static void colorDefaultButton(GuiGraphics guiGraphics)
{
float r = Config.getSkin().getButtonRed();
float g = Config.getSkin().getButtonGreen();
float b = Config.getSkin().getButtonBlue();
float a = Config.getSkin().getButtonAlpha();
RenderSystem.setShaderColor(r, g, b, a);
guiGraphics.setColor(r, g, b, a);
}
public static void colorDefaultBackground()
public static void colorDefaultBackground(GuiGraphics guiGraphics)
{
RenderUtils.colorDefaultBackground(1.0F);
colorDefaultBackground(guiGraphics, 1.0F);
}
public static void colorDefaultBackground(double alpha)
public static void colorDefaultBackground(GuiGraphics guiGraphics, double alpha)
{
float r = Config.getSkin().getBackgroundRed();
float g = Config.getSkin().getBackgroundGreen();
float b = Config.getSkin().getBackgroundBlue();
float a = (float) alpha * Config.getSkin().getBackgroundAlpha();
RenderSystem.setShaderColor(r, g, b, a);
guiGraphics.setColor(r, g, b, a);
}
public static void colorDarkBackground()
public static void colorDarkBackground(GuiGraphics guiGraphics)
{
float r = Config.getSkin().getBackgroundRed();
float g = Config.getSkin().getBackgroundGreen();
float b = Config.getSkin().getBackgroundBlue();
float a = Config.getSkin().getBackgroundAlpha();
RenderSystem.setShaderColor(Math.max(0, r - 0.3F), Math.max(0, g - 0.3F), Math.max(0, b - 0.3F), a);
guiGraphics.setColor(Math.max(0, r - 0.3F), Math.max(0, g - 0.3F), Math.max(0, b - 0.3F), a);
}
public static void resetColor(GuiGraphics guiGraphics)
{
guiGraphics.setColor(1.0F, 1.0F, 1.0F, 1.0F);
}
public static void drawTexturedTriangleBL(GuiGraphics guiGraphics, ResourceLocation texture, int x, int y, int textureX, int textureY, int size)
@@ -127,7 +132,7 @@ public class RenderUtils
double w = (height - i) / (double) (height + 1);
int z = width - (int) (w * width);
RenderUtils.colorDefaultBackground(w);
colorDefaultBackground(guiGraphics, w);
guiGraphics.blit(texture, x + z, y + i, textureX + z, textureY + i, width - z, 1);
}
@@ -143,7 +148,7 @@ public class RenderUtils
double w = (height - i) / (double) (height + 1);
int z = (int) (w * width);
RenderUtils.colorDefaultBackground(w);
colorDefaultBackground(guiGraphics, w);
guiGraphics.blit(texture, x, y + i, textureX, textureY + i, z, 1);
}

View File

@@ -9,10 +9,6 @@ import net.minecraftforge.registries.IForgeRegistry;
public class ResourceHelper
{
private static final ResourceLocation BACKGROUND = new ResourceLocation("textures/gui/demo_background.png");
private static final ResourceLocation BACKGROUND_VANILLA = new ResourceLocation(Main.MODID, "textures/skins/vanilla/vanilla.png");
private static final ResourceLocation BUTTON = new ResourceLocation("textures/gui/widgets.png");
@Nullable
public static ResourceLocation stringToResourceLocation(@Nullable String resource)
{
@@ -40,28 +36,8 @@ public class ResourceHelper
return null;
}
public static ResourceLocation backgroundTexture()
{
if(Config.getSkin().getTextureType().equals("resourcepack"))
{
return BACKGROUND;
}
return BACKGROUND_VANILLA;
}
public static ResourceLocation iconTexture()
{
return new ResourceLocation(Main.MODID, "textures/icons/icons_" + Config.getSkin().getIconSize().name() + ".png");
}
public static ResourceLocation buttonTexture()
{
if(Config.getSkin().getTextureType().equals("resourcepack"))
{
return BUTTON;
}
return new ResourceLocation(Main.MODID, "textures/skins/" + Config.getSkin().getTextureType() + "/" + Config.getSkin().getTextureType() + "_buttons.png");
}
}

View File

@@ -63,7 +63,7 @@ public class ScoreboardHelper
//Slots
this.slots.addNode("belowName");
this.slots.addNode("below_name");
this.slots.addNode("list");
this.slots.addNode("sidebar");
this.slots.addNode("sidebar.team", colors);

View File

@@ -1,9 +1,17 @@
package exopandora.worldhandler.util;
import java.util.Optional;
import javax.annotation.Nullable;
public class Util
{
@Nullable
public static <T extends Number, S extends Number> String serializeBounds(Optional<T> minBound, Optional<S> maxBound)
{
return serializeBounds(minBound.orElse(null), maxBound.orElse(null));
}
@Nullable
public static String serializeBounds(@Nullable Number minBound, @Nullable Number maxBound)
{

View File

@@ -3,7 +3,6 @@ public net.minecraft.server.MinecraftServer f_129744_ # storageSource
public net.minecraft.client.gui.screens.OptionsScreen m_96244_(Lnet/minecraft/server/packs/repository/PackRepository;)V # updatePackList
public net.minecraft.commands.arguments.EntityAnchorArgument$Anchor f_90367_ # name
public net.minecraft.commands.arguments.coordinates.LocalCoordinates m_119908_(Lcom/mojang/brigadier/StringReader;I)D # readDouble
public net.minecraft.advancements.critereon.MinMaxBounds$Doubles <init>(Ljava/lang/Double;Ljava/lang/Double;)V # constructor
public net.minecraft.network.chat.MutableComponent <init>(Lnet/minecraft/network/chat/ComponentContents;Ljava/util/List;Lnet/minecraft/network/chat/Style;)V # constructor
public net.minecraft.commands.arguments.item.ItemParser f_120991_ # ERROR_NO_TAGS_ALLOWED
public net.minecraft.world.level.storage.PrimaryLevelData f_78443_ # settings

View File

@@ -1,5 +1,5 @@
modLoader="javafml"
loaderVersion="[46,)"
loaderVersion="[48,)"
updateJSONURL="https://raw.githubusercontent.com/Exopandora/worldhandler/master/version.json"
issueTrackerURL="https://github.com/Exopandora/WorldHandler/issues"
displayURL="https://minecraft.curseforge.com/projects/world-handler-command-gui"
@@ -11,13 +11,13 @@ license="GPL v3.0"
[[mods]]
modId="worldhandler"
version="1.20.1-${version}"
version="1.20.2-${version}"
displayName="World Handler"
description="The World Handler provides a simple and easy to use graphical user interface for commands. It lets you create powerful and complex sub-commands alongside NBT-structures within seconds."
[[dependencies.worldhandler]]
modId="minecraft"
mandatory=true
versionRange="[1.20,)"
versionRange="[1.20.2,)"
ordering="NONE"
side="BOTH"

View File

@@ -253,7 +253,7 @@
"gui.worldhandler.recipes.take": "Nehmen",
"gui.worldhandler.scoreboard.slot.list": "Liste",
"gui.worldhandler.scoreboard.slot.belowName": "Unter Name",
"gui.worldhandler.scoreboard.slot.below_name": "Unter Name",
"gui.worldhandler.scoreboard.slot.sidebar": "Seitentafel",
"gui.worldhandler.scoreboard.slot.sidebar.team": "Seitentafel Team",

View File

@@ -253,7 +253,7 @@
"gui.worldhandler.recipes.take": "Take",
"gui.worldhandler.scoreboard.slot.list": "List",
"gui.worldhandler.scoreboard.slot.belowName": "Below Name",
"gui.worldhandler.scoreboard.slot.below_name": "Below Name",
"gui.worldhandler.scoreboard.slot.sidebar": "Sidebar",
"gui.worldhandler.scoreboard.slot.sidebar.team": "Sidebar Team",

View File

@@ -254,7 +254,7 @@
"gui.worldhandler.recipes.take": "Retirer",
"gui.worldhandler.scoreboard.slot.list": "Liste",
"gui.worldhandler.scoreboard.slot.belowName": "Sous le nom",
"gui.worldhandler.scoreboard.slot.below_name": "Sous le nom",
"gui.worldhandler.scoreboard.slot.sidebar": "Barre latérale",
"gui.worldhandler.scoreboard.slot.sidebar.team": "Sidebar Team",

View File

@@ -253,7 +253,7 @@
"gui.worldhandler.recipes.take": "Забрать",
"gui.worldhandler.scoreboard.slot.list": "Список",
"gui.worldhandler.scoreboard.slot.belowName": "Под именем",
"gui.worldhandler.scoreboard.slot.below_name": "Под именем",
"gui.worldhandler.scoreboard.slot.sidebar": "Боковая панель",
"gui.worldhandler.scoreboard.slot.sidebar.team": "Боковая панель отряда",

View File

@@ -254,7 +254,7 @@
"gui.worldhandler.recipes.take": "拿取",
"gui.worldhandler.scoreboard.slot.list": "列表",
"gui.worldhandler.scoreboard.slot.belowName": "名称下方",
"gui.worldhandler.scoreboard.slot.below_name": "名称下方",
"gui.worldhandler.scoreboard.slot.sidebar": "侧边栏",
"gui.worldhandler.scoreboard.slot.sidebar.team": "侧边栏队伍",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

View File

@@ -1,6 +1,6 @@
{
"pack": {
"description": "World Handler",
"pack_format": 15
}
"pack": {
"description": "World Handler",
"pack_format": 18
}
}