Update to 1.20

This commit is contained in:
Exopandora
2023-06-11 13:52:10 +02:00
parent 8907ebb683
commit de11a006d5
60 changed files with 564 additions and 546 deletions

View File

@@ -1,6 +1,5 @@
package exopandora.worldhandler;
import java.io.File;
import java.nio.file.Path;
import org.apache.logging.log4j.LogManager;
@@ -51,7 +50,7 @@ public class WorldHandler
public void run()
{
Config.setupDirectories(WorldHandler.USERCONTENT_PATH);
modLoadingContext.registerConfig(Type.CLIENT, Config.CLIENT_SPEC, Main.MODID + File.pathSeparator + Main.MODID + ".toml");
modLoadingContext.registerConfig(Type.CLIENT, Config.CLIENT_SPEC, Main.MODID + "/" + Main.MODID + ".toml");
UsercontentLoader.load(WorldHandler.USERCONTENT_PATH);
modEventBus.addListener(WorldHandler.this::registerKeyMappingsEvent);
modEventBus.addListener(WorldHandler.this::registerClientReloadListeners);

View File

@@ -0,0 +1,61 @@
package exopandora.worldhandler.builder.argument.tag;
import java.util.Arrays;
import javax.annotation.Nonnull;
import exopandora.worldhandler.util.UserStylableComponent;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.StringTag;
import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component;
public class SidedSignTextTag implements ITagProvider
{
private boolean isFront;
private final UserStylableComponent[] lines = new UserStylableComponent[]
{
new UserStylableComponent(),
new UserStylableComponent(),
new UserStylableComponent(),
new UserStylableComponent()
};
@Override
public String key()
{
return this.isFront ? "front_text" : "back_text";
}
@Nonnull
@Override
public Tag value()
{
ListTag messages = new ListTag();
for(UserStylableComponent text : this.lines)
{
messages.add(StringTag.valueOf(Component.Serializer.toJson(text)));
}
CompoundTag tag = new CompoundTag();
tag.put("messages", messages);
return tag;
}
public UserStylableComponent getLine(int index)
{
return this.lines[index];
}
public boolean isStyled()
{
return Arrays.stream(this.lines).anyMatch(UserStylableComponent::isStyled);
}
public void setIsFront(boolean isFront)
{
this.isFront = isFront;
}
}

View File

@@ -1,37 +0,0 @@
package exopandora.worldhandler.builder.argument.tag;
import javax.annotation.Nonnull;
import exopandora.worldhandler.util.UserStylableComponent;
import net.minecraft.nbt.StringTag;
import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component;
public class TextTag implements ITagProvider
{
private final int id;
private final UserStylableComponent component = new UserStylableComponent();
public TextTag(int id)
{
this.id = id;
}
public UserStylableComponent getComponent()
{
return this.component;
}
@Override
public String key()
{
return "Text" + this.id;
}
@Nonnull
@Override
public Tag value()
{
return StringTag.valueOf(Component.Serializer.toJson(this.component));
}
}

View File

@@ -28,14 +28,14 @@ public class CommandWorldHandler
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
{
dispatcher.register(Commands.literal("worldhandler")
.then(Commands.literal("help")
.executes(context -> help(context.getSource())))
.then(Commands.literal("display")
.executes(context -> display(context.getSource())))
.then(Commands.literal("version")
.executes(context -> version(context.getSource())))
.then(Commands.literal("allow_commands")
.executes(context -> allowCommands(context.getSource()))));
.then(Commands.literal("help")
.executes(context -> help(context.getSource())))
.then(Commands.literal("display")
.executes(context -> display(context.getSource())))
.then(Commands.literal("version")
.executes(context -> version(context.getSource())))
.then(Commands.literal("allow_commands")
.executes(context -> allowCommands(context.getSource()))));
}
private static int help(CommandSourceStack source) throws CommandSyntaxException
@@ -86,7 +86,7 @@ public class CommandWorldHandler
server.getCommands().sendCommands(player);
}
source.sendSuccess(Component.translatable("commands.worldhandler.allow_commands.success"), false);
source.sendSuccess(() -> Component.translatable("commands.worldhandler.allow_commands.success"), false);
return operatorPermissionLevel;
}
}

View File

@@ -5,17 +5,17 @@ import net.minecraft.network.chat.Component;
public class DummyScreen extends Screen
{
private final Runnable runnable;
private final Runnable onInit;
public DummyScreen(Runnable runnable)
public DummyScreen(Runnable onInit)
{
super(Component.empty());
this.runnable = runnable;
this.onInit = onInit;
}
@Override
protected void init()
{
this.runnable.run();
this.onInit.run();
}
}

View File

@@ -25,6 +25,4 @@ public interface IContainer
int getBackgroundWidth();
int getBackgroundHeight();
void bindBackground();
}

View File

@@ -26,7 +26,7 @@ import exopandora.worldhandler.util.ResourceHelper;
import exopandora.worldhandler.util.TextUtils;
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiComponent;
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;
@@ -144,7 +144,7 @@ public class GuiWorldHandler extends Container
}
@Override
public void render(PoseStack stack, int mouseX, int mouseY, float partialTicks)
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks)
{
ActionHelper.tryRun(() ->
{
@@ -153,19 +153,18 @@ public class GuiWorldHandler extends Container
if(Config.getSkin().drawBackground())
{
super.renderBackground(stack);
super.renderBackground(guiGraphics);
}
RenderSystem.enableBlend();
RenderUtils.colorDefaultBackground();
this.bindBackground();
GuiComponent.blit(stack, backgroundX, backgroundY, 0, 0, this.getBackgroundWidth(), this.getBackgroundHeight());
guiGraphics.blit(ResourceHelper.backgroundTexture(), 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;
this.font.draw(stack, label, versionWidth, versionHeight, Config.getSkin().getLabelColor() + 0x33000000);
guiGraphics.drawString(this.font, label, versionWidth, versionHeight, Config.getSkin().getLabelColor() + 0x33000000, false);
int x = this.getContentX();
int y = this.getContentY();
@@ -174,30 +173,30 @@ public class GuiWorldHandler extends Container
{
if(widget.isEnabled() && EnumLayer.BACKGROUND == widget.getLayer())
{
widget.drawScreen(stack, this, x, y, mouseX, mouseY, partialTicks);
widget.drawScreen(guiGraphics, this, x, y, mouseX, mouseY, partialTicks);
}
}
final int maxWidth = this.getBackgroundWidth() - 18 - this.font.width(this.getPlayer()) - (Config.getSettings().watch() ? 9 : 0);
this.font.draw(stack, TextUtils.stripText(this.content.getTitle(), maxWidth, this.font), backgroundX + 7, backgroundY + 7, Config.getSkin().getLabelColor());
guiGraphics.drawString(this.font, TextUtils.stripText(this.content.getTitle(), maxWidth, this.font), backgroundX + 7, backgroundY + 7, Config.getSkin().getLabelColor(), false);
for(Renderable renderable : this.renderables)
{
renderable.render(stack, mouseX, mouseY, partialTicks);
renderable.render(guiGraphics, mouseX, mouseY, partialTicks);
}
this.content.drawScreen(stack, this, x, y, mouseX, mouseY, partialTicks);
this.content.drawScreen(guiGraphics, this, x, y, mouseX, mouseY, partialTicks);
for(IMenu menu : this.menus)
{
menu.draw(stack, mouseX, mouseY, partialTicks);
menu.draw(guiGraphics, mouseX, mouseY, partialTicks);
}
for(IContainerWidget widget : WIDGETS)
{
if(widget.isEnabled() && EnumLayer.FOREGROUND == widget.getLayer())
{
widget.drawScreen(stack, this, x, y, mouseX, mouseY, partialTicks);
widget.drawScreen(guiGraphics, this, x, y, mouseX, mouseY, partialTicks);
}
}
@@ -207,19 +206,20 @@ public class GuiWorldHandler extends Container
{
if(renderable instanceof GuiButtonTooltip)
{
((GuiButtonTooltip) renderable).renderTooltip(this, stack, mouseX, mouseY);
((GuiButtonTooltip) renderable).renderTooltip(guiGraphics, this.font, mouseX, mouseY);
}
}
}
if(mouseX >= versionWidth && mouseY >= versionHeight)
{
stack.pushPose();
stack.translate(versionWidth - 12, versionHeight + 12, 0);
PoseStack poseStack = guiGraphics.pose();
poseStack.pushPose();
poseStack.translate(versionWidth - 12, versionHeight + 12, 0);
this.renderTooltip(stack, Component.literal(label), 0, 0);
guiGraphics.renderTooltip(this.font, Component.literal(label), 0, 0);
stack.popPose();
poseStack.popPose();
}
RenderSystem.disableBlend();
@@ -456,10 +456,4 @@ public class GuiWorldHandler extends Container
{
return 166;
}
@Override
public void bindBackground()
{
RenderSystem.setShaderTexture(0, ResourceHelper.backgroundTexture());
}
}

View File

@@ -15,7 +15,7 @@ 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.GuiTextFieldTooltip;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
import exopandora.worldhandler.util.ActionHelper;
import exopandora.worldhandler.util.CommandHelper;
import net.minecraft.client.Minecraft;
@@ -30,7 +30,7 @@ import net.minecraftforge.registries.ForgeRegistries;
public class ContentButcher extends Content
{
private GuiTextFieldTooltip radiusField;
private GuiHintTextField radiusField;
private String radius;
private final KillCommandBuilder builderKill = new KillCommandBuilder();
private final CommandPreview preview = new CommandPreview(this.builderKill, KillCommandBuilder.Label.KILL_TARGETS);
@@ -44,7 +44,7 @@ public class ContentButcher extends Content
@Override
public void initGui(Container container, int x, int y)
{
this.radiusField = new GuiTextFieldTooltip(x + 58, y, 114, 20, Component.translatable("gui.worldhandler.butcher.radius"));
this.radiusField = new GuiHintTextField(x + 58, y, 114, 20, Component.translatable("gui.worldhandler.butcher.radius"));
this.radiusField.setFilter(string ->
{
if(string == null)

View File

@@ -94,7 +94,7 @@ public class ContentChangeWorld extends ContentChild
else if(connection instanceof DedicatedConnection dedicated)
{
ServerData data = dedicated.getData();
ConnectScreen.startConnecting(new TitleScreen(), Minecraft.getInstance(), ServerAddress.parseString(data.ip), data);
ConnectScreen.startConnecting(new TitleScreen(), Minecraft.getInstance(), ServerAddress.parseString(data.ip), data, false);
}
}

View File

@@ -21,7 +21,7 @@ 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.GuiButtonTooltip;
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
import exopandora.worldhandler.util.ActionHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
@@ -39,7 +39,7 @@ public class ContentCommandStack extends ContentChild
private static final Component PLUS = Component.literal("+");
private static final Component MINUS = Component.literal("-");
private final List<GuiTextFieldTooltip> textfields = new ArrayList<GuiTextFieldTooltip>();
private final List<GuiHintTextField> textfields = new ArrayList<GuiHintTextField>();
private int scroll;
private GuiButtonBase buttonCopy;
@@ -111,7 +111,7 @@ public class ContentCommandStack extends ContentChild
{
int command = index + this.scroll;
GuiTextFieldTooltip textfield = new GuiTextFieldTooltip(x, y + 24 * index, 232 - 48, 20, Component.translatable("gui.worldhandler.command_stack.command_n", command + 1));
GuiHintTextField textfield = new GuiHintTextField(x, y + 24 * index, 232 - 48, 20, Component.translatable("gui.worldhandler.command_stack.command_n", command + 1));
textfield.setFilter(Predicates.notNull());
textfield.setValue(command < this.getCommandCount() ? this.getCommand(command) : null);
textfield.setResponder(text ->

View File

@@ -3,7 +3,7 @@ package exopandora.worldhandler.gui.content.impl;
import exopandora.worldhandler.builder.ICommandBuilder;
import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
import exopandora.worldhandler.util.ActionHelper;
import exopandora.worldhandler.util.CommandHelper;
import net.minecraft.ChatFormatting;
@@ -12,7 +12,7 @@ import net.minecraft.network.chat.Component;
public class ContentContinue extends ContentChild
{
private ICommandBuilder builder;
private GuiTextFieldTooltip commandField;
private GuiHintTextField commandField;
private Object label;
private boolean special;
@@ -38,7 +38,7 @@ public class ContentContinue extends ContentChild
@Override
public void initGui(Container container, int x, int y)
{
this.commandField = new GuiTextFieldTooltip(x + 116 / 2, y + 12, 116, 20);
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();

View File

@@ -17,7 +17,7 @@ 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.GuiTextFieldTooltip;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
import exopandora.worldhandler.gui.widget.button.LogicSliderAttribute;
import exopandora.worldhandler.gui.widget.button.LogicSliderSimple;
import exopandora.worldhandler.gui.widget.menu.impl.ILogicPageList;
@@ -35,9 +35,9 @@ import net.minecraftforge.registries.ForgeRegistries;
public class ContentCustomItem extends Content
{
private GuiTextFieldTooltip itemField;
private GuiTextFieldTooltip itemLore1Field;
private GuiTextFieldTooltip itemLore2Field;
private GuiHintTextField itemField;
private GuiHintTextField itemLore1Field;
private GuiHintTextField itemLore2Field;
private final GiveCommandBuilder builderCutomItem = new GiveCommandBuilder();
private final AttributeModifiersTag attributes = new AttributeModifiersTag();
@@ -94,7 +94,7 @@ public class ContentCustomItem extends Content
@Override
public void initGui(Container container, int x, int y)
{
this.itemField = new GuiTextFieldTooltip(x + 118, y, 114, 20, Component.translatable("gui.worldhandler.items.custom_item.start.item_id"));
this.itemField = new GuiHintTextField(x + 118, y, 114, 20, Component.translatable("gui.worldhandler.items.custom_item.start.item_id"));
this.itemField.setFilter(Predicates.<String>notNull());
this.itemField.setValue(this.item);
this.itemField.setResponder(text ->
@@ -104,7 +104,7 @@ public class ContentCustomItem extends Content
container.initButtons();
});
this.itemLore1Field = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.items.custom_item.start.lore_1"));
this.itemLore1Field = new GuiHintTextField(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.items.custom_item.start.lore_1"));
this.itemLore1Field.setFilter(Predicates.<String>notNull());
this.itemLore1Field.setText(this.display.getLore1());
this.itemLore1Field.setResponder(text ->
@@ -113,7 +113,7 @@ public class ContentCustomItem extends Content
container.initButtons();
});
this.itemLore2Field = new GuiTextFieldTooltip(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.items.custom_item.start.lore_2"));
this.itemLore2Field = new GuiHintTextField(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.items.custom_item.start.lore_2"));
this.itemLore2Field.setFilter(Predicates.<String>notNull());
this.itemLore2Field.setText(this.display.getLore2());
this.itemLore2Field.setResponder(text ->

View File

@@ -16,7 +16,7 @@ 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.GuiButtonList;
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
import exopandora.worldhandler.gui.widget.menu.impl.ILogicMapped;
import exopandora.worldhandler.util.ActionHelper;
import exopandora.worldhandler.util.BlockHelper;
@@ -27,15 +27,15 @@ import net.minecraft.network.chat.MutableComponent;
public class ContentEditBlocks extends Content
{
private GuiTextFieldTooltip x1Field;
private GuiTextFieldTooltip y1Field;
private GuiTextFieldTooltip z1Field;
private GuiTextFieldTooltip x2Field;
private GuiTextFieldTooltip y2Field;
private GuiTextFieldTooltip z2Field;
private GuiTextFieldTooltip block1Field;
private GuiTextFieldTooltip block2Field;
private GuiTextFieldTooltip filterField;
private GuiHintTextField x1Field;
private GuiHintTextField y1Field;
private GuiHintTextField z1Field;
private GuiHintTextField x2Field;
private GuiHintTextField y2Field;
private GuiHintTextField z2Field;
private GuiHintTextField block1Field;
private GuiHintTextField block2Field;
private GuiHintTextField filterField;
private final FillCommandBuilder builderFill = new FillCommandBuilder();
private final CloneCommandBuilder builderClone = new CloneCommandBuilder();
@@ -71,37 +71,37 @@ public class ContentEditBlocks extends Content
{
this.updatePositions();
this.x1Field = new GuiTextFieldTooltip(x + 118, y, 55, 20);
this.x1Field = new GuiHintTextField(x + 118, y, 55, 20);
this.x1Field.setFilter(this.coordinatePredicate("X1"));
this.x1Field.setValue("X1: " + BlockHelper.pos1().getX());
this.x1Field.setResponder(text -> BlockHelper.pos1().setX(this.parseCoordinate(text)));
this.y1Field = new GuiTextFieldTooltip(x + 118, y + 24, 55, 20);
this.y1Field = new GuiHintTextField(x + 118, y + 24, 55, 20);
this.y1Field.setFilter(this.coordinatePredicate("Y1"));
this.y1Field.setValue("Y1: " + BlockHelper.pos1().getY());
this.y1Field.setResponder(text -> BlockHelper.pos1().setY(this.parseCoordinate(text)));
this.z1Field = new GuiTextFieldTooltip(x + 118, y + 48, 55, 20);
this.z1Field = new GuiHintTextField(x + 118, y + 48, 55, 20);
this.z1Field.setFilter(this.coordinatePredicate("Z1"));
this.z1Field.setValue("Z1: " + BlockHelper.pos1().getZ());
this.z1Field.setResponder(text -> BlockHelper.pos1().setZ(this.parseCoordinate(text)));
this.x2Field = new GuiTextFieldTooltip(x + 118 + 59, y, 55, 20);
this.x2Field = new GuiHintTextField(x + 118 + 59, y, 55, 20);
this.x2Field.setFilter(this.coordinatePredicate("X2"));
this.x2Field.setValue("X2: " + BlockHelper.pos2().getX());
this.x2Field.setResponder(text -> BlockHelper.pos2().setX(this.parseCoordinate(text)));
this.y2Field = new GuiTextFieldTooltip(x + 118 + 59, y + 24, 55, 20);
this.y2Field = new GuiHintTextField(x + 118 + 59, y + 24, 55, 20);
this.y2Field.setFilter(this.coordinatePredicate("Y2"));
this.y2Field.setValue("Y2: " + BlockHelper.pos2().getY());
this.y2Field.setResponder(text -> BlockHelper.pos2().setY(this.parseCoordinate(text)));
this.z2Field = new GuiTextFieldTooltip(x + 118 + 59, y + 48, 55, 20);
this.z2Field = new GuiHintTextField(x + 118 + 59, y + 48, 55, 20);
this.z2Field.setFilter(this.coordinatePredicate("Z2"));
this.z2Field.setValue("Z2: " + BlockHelper.pos2().getZ());
this.z2Field.setResponder(text -> BlockHelper.pos2().setZ(this.parseCoordinate(text)));
this.block1Field = new GuiTextFieldTooltip(x + 118, y, 114, 20, Page.FILL.equals(this.page) ? Component.translatable("gui.worldhandler.edit_blocks.fill.block_id_to_fill") : Component.translatable("gui.worldhandler.edit_blocks.replace.block_id_replace"));
this.block1Field = new GuiHintTextField(x + 118, y, 114, 20, Page.FILL.equals(this.page) ? Component.translatable("gui.worldhandler.edit_blocks.fill.block_id_to_fill") : Component.translatable("gui.worldhandler.edit_blocks.replace.block_id_replace"));
this.block1Field.setFilter(Predicates.notNull());
this.block1Field.setValue(this.block1);
this.block1Field.setResponder(text ->
@@ -111,7 +111,7 @@ public class ContentEditBlocks extends Content
container.initButtons();
});
this.block2Field = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.edit_blocks.replace.block_id_place"));
this.block2Field = new GuiHintTextField(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.edit_blocks.replace.block_id_place"));
this.block2Field.setFilter(Predicates.notNull());
this.block2Field.setValue(this.block2);
this.block2Field.setResponder(text ->
@@ -121,7 +121,7 @@ public class ContentEditBlocks extends Content
container.initButtons();
});
this.filterField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.edit_blocks.clone.filter"));
this.filterField = new GuiHintTextField(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.edit_blocks.clone.filter"));
this.filterField.setFilter(Predicates.notNull());
this.filterField.setValue(this.filter);
this.filterField.setResponder(text ->

View File

@@ -16,7 +16,7 @@ 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.GuiTextFieldTooltip;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
import exopandora.worldhandler.gui.widget.menu.impl.ILogicPageList;
import exopandora.worldhandler.gui.widget.menu.impl.MenuPageList;
import exopandora.worldhandler.util.ActionHandler;
@@ -29,7 +29,7 @@ import net.minecraft.world.level.GameRules.GameRuleTypeVisitor;
public class ContentGamerules extends Content
{
private GuiTextFieldTooltip valueField;
private GuiHintTextField valueField;
private boolean booleanValue;
private String value;
@@ -46,7 +46,7 @@ public class ContentGamerules extends Content
@Override
public void initGui(Container container, int x, int y)
{
this.valueField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.generic.value"));
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();

View File

@@ -58,7 +58,13 @@ public class ContentLocate extends Content
{
if(Page.BIOME.equals(this.page))
{
List<ResourceLocation> biomes = RegistryHelper.getLookupProvider().lookup(Registries.BIOME).get().listElementIds().map(ResourceKey::location).collect(Collectors.toList());
List<ResourceLocation> biomes = RegistryHelper.getLookupProvider()
.lookup(Registries.BIOME)
.get()
.listElementIds()
.map(ResourceKey::location)
.collect(Collectors.toList());
MenuPageList<ResourceLocation> list = new MenuPageList<ResourceLocation>(x + 118, y, biomes, 114, 20, 3, container, new ILogicPageList<ResourceLocation>()
{
@Override
@@ -96,7 +102,12 @@ public class ContentLocate extends Content
}
else if(Page.STRUCTURE.equals(this.page))
{
List<ResourceLocation> structures = RegistryHelper.getLookupProvider().lookup(Registries.STRUCTURE).get().listElementIds().map(ResourceKey::location).collect(Collectors.toList());
List<ResourceLocation> structures = RegistryHelper.getLookupProvider()
.lookup(Registries.STRUCTURE)
.get()
.listElementIds()
.map(ResourceKey::location)
.collect(Collectors.toList());
MenuPageList<ResourceLocation> list = new MenuPageList<ResourceLocation>(x + 118, y, structures, 114, 20, 3, container, new ILogicPageList<ResourceLocation>()
{

View File

@@ -21,7 +21,7 @@ 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.GuiButtonTooltip;
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
import exopandora.worldhandler.util.ActionHelper;
import exopandora.worldhandler.util.CommandHelper;
import net.minecraft.ChatFormatting;
@@ -31,8 +31,8 @@ import net.minecraft.network.chat.MutableComponent;
public class ContentMultiplayer extends Content
{
private GuiTextFieldTooltip playerField;
private GuiTextFieldTooltip reasonField;
private GuiHintTextField playerField;
private GuiHintTextField reasonField;
private Page page = Page.KICK_AND_BAN;
@@ -91,7 +91,7 @@ public class ContentMultiplayer extends Content
@Override
public void initGui(Container container, int x, int y)
{
this.playerField = new GuiTextFieldTooltip(x + 118, y + this.page.getShift(), 114, 20, Component.translatable("gui.worldhandler.multiplayer.username"));
this.playerField = new GuiHintTextField(x + 118, y + this.page.getShift(), 114, 20, Component.translatable("gui.worldhandler.multiplayer.username"));
this.playerField.setFilter(Predicates.notNull());
this.playerField.setFocused(false);
this.playerField.setValue(this.builderKick.targets().getTarget());
@@ -102,7 +102,7 @@ public class ContentMultiplayer extends Content
container.initButtons();
});
this.reasonField = new GuiTextFieldTooltip(x + 118, y + 24 + this.page.getShift(), 114, 20, Component.translatable("gui.worldhandler.multiplayer.kick_ban.reason"));
this.reasonField = new GuiHintTextField(x + 118, y + 24 + this.page.getShift(), 114, 20, Component.translatable("gui.worldhandler.multiplayer.kick_ban.reason"));
this.reasonField.setFilter(Predicates.notNull());
this.reasonField.setFocused(false);
this.reasonField.setValue(this.builderKick.reason().get());

View File

@@ -20,7 +20,7 @@ import exopandora.worldhandler.util.BlockHelper;
import exopandora.worldhandler.util.CommandHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
@@ -66,7 +66,7 @@ public class ContentNoteEditor extends Content
if(this.isActive)
{
BlockPos pos = this.builderNoteEditor.pos().getBlockPos();
SoundEvent sound = getSoundEvent(pos.below()).getSoundEvent().get();
SoundEvent sound = getSoundEvent(pos).getSoundEvent().get();
container.addRenderableWidget(new GuiButtonPiano(x - 3 + 15, y, 14, 92, Component.translatable("gui.worldhandler.blocks.note_block_editor.g"), sound, 0.53F, Type.NORMAL, () -> this.setNote(container.getPlayer(), 1)));
container.addRenderableWidget(new GuiButtonPiano(x - 3 + 15 * 2, y, 14, 92, Component.translatable("gui.worldhandler.blocks.note_block_editor.a"), sound, 0.6F, Type.NORMAL, () -> this.setNote(container.getPlayer(), 3)));
@@ -109,46 +109,44 @@ public class ContentNoteEditor extends Content
builder.pos().set(pos);
NoteBlockInstrument instrument = getSoundEvent(pos);
BlockState state = Blocks.NOTE_BLOCK.defaultBlockState()
.setValue(BlockStateProperties.NOTEBLOCK_INSTRUMENT, instrument)
.setValue(BlockStateProperties.NOTE, note);
.setValue(BlockStateProperties.NOTEBLOCK_INSTRUMENT, instrument)
.setValue(BlockStateProperties.NOTE, note);
builder.block().set(state);
CommandHelper.sendCommand(player, builder, SetBlockCommandBuilder.Label.REPLACE);
}
@Override
public void drawScreen(PoseStack matrix, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
public void drawScreen(GuiGraphics guiGraphics, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
{
if(this.isActive)
{
RenderSystem.setShaderTexture(0, NOTE);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
GuiComponent.blit(matrix, x - 1, y - 1, 0, 0, 8, 59);
GuiComponent.blit(matrix, x - 1, y - 1 + 59, 0, 59, 13, 35);
guiGraphics.blit(NOTE, x - 1, y - 1, 0, 0, 8, 59);
guiGraphics.blit(NOTE, x - 1, y - 1 + 59, 0, 59, 13, 35);
GuiComponent.blit(matrix, x - 1 + 232 - 5, y - 1, 18, 0, 7, 59);
GuiComponent.blit(matrix, x - 1 + 232 - 10, y - 1 + 59, 13, 59, 12, 35);
guiGraphics.blit(NOTE, x - 1 + 232 - 5, y - 1, 18, 0, 7, 59);
guiGraphics.blit(NOTE, x - 1 + 232 - 10, y - 1 + 59, 13, 59, 12, 35);
GuiComponent.blit(matrix, x - 1 + 8, y - 1, 0, 94, 219, 1);
GuiComponent.blit(matrix, x - 1 + 13, y - 1 + 93, 0, 94, 209, 1);
guiGraphics.blit(NOTE, x - 1 + 8, y - 1, 0, 94, 219, 1);
guiGraphics.blit(NOTE, x - 1 + 13, y - 1 + 93, 0, 94, 209, 1);
}
else
{
float scale = 4;
PoseStack posestack = RenderSystem.getModelViewStack();
PoseStack posestack = guiGraphics.pose();
posestack.pushPose();
posestack.translate(container.width / 2 - 8.5F * scale, container.height / 2 - 15 - 8.5F * scale, 0);
posestack.scale(scale, scale, scale);
Minecraft.getInstance().getItemRenderer().renderGuiItem(matrix, new ItemStack(Items.NOTE_BLOCK), 0, 0);
guiGraphics.renderItem(new ItemStack(Items.NOTE_BLOCK), 0, 0);
posestack.popPose();
RenderSystem.applyModelViewMatrix();
MutableComponent text = Component.translatable("gui.worldhandler.blocks.note_block_editor.look_at_note_block", KeyHandler.KEY_WORLD_HANDLER.getTranslatedKeyMessage());
Font font = Minecraft.getInstance().font;
font.draw(matrix, text, x + 116 - font.width(text) / 2, y + 70, Config.getSkin().getLabelColor());
guiGraphics.drawString(font, text, x + 116 - font.width(text) / 2, y + 70, Config.getSkin().getLabelColor(), false);
}
}
@@ -158,10 +156,18 @@ public class ContentNoteEditor extends Content
if(level != null)
{
return NoteBlockInstrument.byStateAbove(level.getBlockState(blockPos.above())).orElseGet(() ->
NoteBlockInstrument noteblockinstrument = level.getBlockState(blockPos.above()).instrument();
if(noteblockinstrument.worksAboveNoteBlock())
{
return NoteBlockInstrument.byStateBelow(level.getBlockState(blockPos.below()));
});
return noteblockinstrument;
}
else
{
NoteBlockInstrument noteblockinstrument1 = level.getBlockState(blockPos.below()).instrument();
NoteBlockInstrument noteblockinstrument2 = noteblockinstrument1.worksAboveNoteBlock() ? NoteBlockInstrument.HARP : noteblockinstrument1;
return noteblockinstrument2;
}
}
return null;

View File

@@ -1,7 +1,6 @@
package exopandora.worldhandler.gui.content.impl;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import exopandora.worldhandler.builder.impl.ClearInventoryCommandBuilder;
import exopandora.worldhandler.builder.impl.KillCommandBuilder;
@@ -13,11 +12,11 @@ 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.GuiTextFieldTooltip;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
import exopandora.worldhandler.util.ActionHelper;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.inventory.InventoryScreen;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.core.BlockPos;
@@ -29,13 +28,13 @@ public class ContentPlayer extends Content
{
private Page page = Page.START;
private GuiTextFieldTooltip posXField;
private GuiTextFieldTooltip posYField;
private GuiTextFieldTooltip posZField;
private GuiHintTextField posXField;
private GuiHintTextField posYField;
private GuiHintTextField posZField;
private GuiTextFieldTooltip scoreField;
private GuiTextFieldTooltip coinsField;
private GuiTextFieldTooltip xpField;
private GuiHintTextField scoreField;
private GuiHintTextField coinsField;
private GuiHintTextField xpField;
private final SetWorldSpawnCommandBuilder builderSetWorldSpawn = new SetWorldSpawnCommandBuilder();
private final SetSpawnCommandBuilder builderSpawnpoint = new SetSpawnCommandBuilder();
@@ -61,12 +60,12 @@ public class ContentPlayer extends Content
@Override
public void initGui(Container container, int x, int y)
{
this.posXField = new GuiTextFieldTooltip(x + 118, y, 114, 20);
this.posYField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20);
this.posZField = new GuiTextFieldTooltip(x + 118, y + 48, 114, 20);
this.scoreField = new GuiTextFieldTooltip(x + 118, y + 12, 114, 20);
this.coinsField = new GuiTextFieldTooltip(x + 118, y + 36, 114, 20);
this.xpField = new GuiTextFieldTooltip(x + 118, y + 60, 114, 20);
this.posXField = new GuiHintTextField(x + 118, y, 114, 20);
this.posYField = new GuiHintTextField(x + 118, y + 24, 114, 20);
this.posZField = new GuiHintTextField(x + 118, y + 48, 114, 20);
this.scoreField = new GuiHintTextField(x + 118, y + 12, 114, 20);
this.coinsField = new GuiHintTextField(x + 118, y + 36, 114, 20);
this.xpField = new GuiHintTextField(x + 118, y + 60, 114, 20);
this.tick(container);
}
@@ -176,19 +175,20 @@ public class ContentPlayer extends Content
}
@Override
public void drawScreen(PoseStack matrix, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
public void drawScreen(GuiGraphics guiGraphics, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
{
if(Page.START.equals(this.page) && Minecraft.getInstance().player != null)
{
Minecraft minecraft = Minecraft.getInstance();
int xPos = x + 175;
int yPos = y + 82;
int playerNameWidth = Minecraft.getInstance().font.width(Minecraft.getInstance().player.getName()) / 2;
int playerNameWidth = minecraft.font.width(minecraft.player.getName()) / 2;
GuiComponent.fill(matrix, container.width / 2 - playerNameWidth - 1 + 59, yPos - 74, container.width / 2 + playerNameWidth + 1 + 59, yPos - 65, 0x3F000000);
Minecraft.getInstance().font.draw(matrix, Minecraft.getInstance().player.getName(), container.width / 2 - playerNameWidth + 59, yPos - 73, 0xE0E0E0);
guiGraphics.fill(container.width / 2 - playerNameWidth - 1 + 59, yPos - 74, container.width / 2 + playerNameWidth + 1 + 59, yPos - 65, 0x3F000000);
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(matrix, xPos, yPos, 30, xPos - mouseX, yPos - mouseY - 44, Minecraft.getInstance().player);
InventoryScreen.renderEntityInInventoryFollowsMouse(guiGraphics, xPos, yPos, 30, xPos - mouseX, yPos - mouseY - 44, minecraft.player);
RenderSystem.defaultBlendFunc();
}
}

View File

@@ -12,7 +12,7 @@ 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.GuiTextFieldTooltip;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
import exopandora.worldhandler.gui.widget.menu.impl.ILogicButtonList;
import exopandora.worldhandler.gui.widget.menu.impl.MenuButtonList;
import exopandora.worldhandler.util.ActionHelper;
@@ -30,7 +30,7 @@ import net.minecraftforge.registries.IForgeRegistry;
public class ContentScoreboardObjectives extends ContentScoreboard
{
private GuiTextFieldTooltip objectField;
private GuiHintTextField objectField;
private Page page = Page.CREATE;
@Override
@@ -42,7 +42,7 @@ public class ContentScoreboardObjectives extends ContentScoreboard
@Override
public void initGui(Container container, int x, int y)
{
this.objectField = new GuiTextFieldTooltip(x + 118, y + this.page.getShift(), 114, 20, Component.translatable("gui.worldhandler.scoreboard.objectives.objective"));
this.objectField = new GuiHintTextField(x + 118, y + this.page.getShift(), 114, 20, Component.translatable("gui.worldhandler.scoreboard.objectives.objective"));
this.objectField.setFilter(Predicates.notNull());
this.objectField.setResponder(text ->
{

View File

@@ -12,7 +12,7 @@ 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.GuiTextFieldTooltip;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
import exopandora.worldhandler.gui.widget.button.LogicSliderSimple;
import exopandora.worldhandler.util.ActionHelper;
import exopandora.worldhandler.util.CommandHelper;
@@ -33,8 +33,8 @@ public class ContentScoreboardPlayers extends ContentScoreboard
private GuiButtonBase addButton;
private GuiButtonBase removeButton;
private GuiTextFieldTooltip objectField;
private GuiTextFieldTooltip tagField;
private GuiHintTextField objectField;
private GuiHintTextField tagField;
public ContentScoreboardPlayers()
{
@@ -74,7 +74,7 @@ public class ContentScoreboardPlayers extends ContentScoreboard
@Override
public void initGui(Container container, int x, int y)
{
this.objectField = new GuiTextFieldTooltip(x + 118, y, 114, 20, Component.translatable("gui.worldhandler.scoreboard.objectives.objective"));
this.objectField = new GuiHintTextField(x + 118, y, 114, 20, Component.translatable("gui.worldhandler.scoreboard.objectives.objective"));
this.objectField.setFilter(Predicates.notNull());
this.objectField.setResponder(text ->
{
@@ -85,7 +85,7 @@ public class ContentScoreboardPlayers extends ContentScoreboard
});
this.objectField.setValue(BUILDER.objective().get());
this.tagField = new GuiTextFieldTooltip(x + 118, y + 12, 114, 20, Component.translatable("gui.worldhandler.scoreboard.players.tag"));
this.tagField = new GuiHintTextField(x + 118, y + 12, 114, 20, Component.translatable("gui.worldhandler.scoreboard.players.tag"));
this.tagField.setFilter(string -> string != null && !string.contains(" "));
this.tagField.setValue(this.builderTag.name().get());
this.tagField.setResponder(text ->

View File

@@ -10,7 +10,7 @@ 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.GuiTextFieldTooltip;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
import exopandora.worldhandler.gui.widget.menu.impl.ILogicButtonList;
import exopandora.worldhandler.gui.widget.menu.impl.MenuButtonList;
import exopandora.worldhandler.util.ActionHelper;
@@ -32,7 +32,7 @@ public class ContentScoreboardTeams extends ContentScoreboard
.add(this.builderTeams, TeamCommandBuilder.Label.EMPTY);
private final CommandPreview previewModify = new CommandPreview(this.builderTeams, TeamCommandBuilder.Label.MODIFY);
private GuiTextFieldTooltip teamField;
private GuiHintTextField teamField;
private Page page = Page.ADD;
@Override
@@ -56,7 +56,7 @@ public class ContentScoreboardTeams extends ContentScoreboard
@Override
public void initGui(Container container, int x, int y)
{
this.teamField = new GuiTextFieldTooltip(x + 118, y + this.page.getShift(), 114, 20, Component.translatable("gui.worldhandler.scoreboard.team.team"));
this.teamField = new GuiHintTextField(x + 118, y + this.page.getShift(), 114, 20, Component.translatable("gui.worldhandler.scoreboard.team.team"));
this.teamField.setFilter(Predicates.notNull());
this.teamField.setValue(this.builderTeams.team().get());
this.teamField.setResponder(text ->

View File

@@ -11,7 +11,7 @@ import exopandora.worldhandler.gui.content.impl.ContentSettings.Setting.BooleanS
import exopandora.worldhandler.gui.content.impl.ContentSettings.Setting.IntegerSetting;
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
import exopandora.worldhandler.gui.widget.menu.impl.ILogicPageList;
import exopandora.worldhandler.gui.widget.menu.impl.MenuPageList;
import exopandora.worldhandler.util.ActionHandler;
@@ -41,7 +41,7 @@ public class ContentSettings extends ContentChild
}
private Setting<?> setting;
private GuiTextFieldTooltip valueField;
private GuiHintTextField valueField;
@Override
public void initGui(Container container, int x, int y)
@@ -82,7 +82,7 @@ public class ContentSettings extends ContentChild
container.addMenu(settings);
this.valueField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.generic.value"));
this.valueField = new GuiHintTextField(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.generic.value"));
this.valueField.setFilter(string ->
{
if(string == null)

View File

@@ -1,13 +1,10 @@
package exopandora.worldhandler.gui.content.impl;
import java.util.Arrays;
import com.google.common.base.Predicates;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import exopandora.worldhandler.builder.argument.PrimitiveArgument.Linkage;
import exopandora.worldhandler.builder.argument.tag.TextTag;
import exopandora.worldhandler.builder.argument.tag.SidedSignTextTag;
import exopandora.worldhandler.builder.impl.DataCommandBuilder;
import exopandora.worldhandler.config.Config;
import exopandora.worldhandler.event.KeyHandler;
@@ -17,7 +14,7 @@ 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.GuiTextFieldTooltip;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
import exopandora.worldhandler.gui.widget.menu.impl.ILogicColorMenu;
import exopandora.worldhandler.gui.widget.menu.impl.MenuColorField;
import exopandora.worldhandler.util.ActionHelper;
@@ -25,19 +22,23 @@ import exopandora.worldhandler.util.BlockHelper;
import exopandora.worldhandler.util.CommandHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.SignBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.SignBlockEntity;
public class ContentSignEditor extends Content
{
private final DataCommandBuilder builderSignEditor = new DataCommandBuilder();
private final TextTag[] texts = new TextTag[4];
private final SidedSignTextTag texts = new SidedSignTextTag();
private final CommandPreview preview = new CommandPreview(this.builderSignEditor, DataCommandBuilder.Label.MERGE_BLOCK);
private GuiTextFieldTooltip commandField;
private GuiHintTextField commandField;
private int selectedLine;
private boolean editColor;
@@ -46,13 +47,7 @@ public class ContentSignEditor extends Content
public ContentSignEditor()
{
this.builderSignEditor.linkage().set(Linkage.MERGE);
for(int x = 0; x < this.texts.length; x++)
{
TextTag text = new TextTag(x + 1);
this.texts[x] = text;
this.builderSignEditor.nbt().addTagProvider(text);
}
this.builderSignEditor.nbt().addTagProvider(this.texts);
}
@Override
@@ -64,8 +59,20 @@ public class ContentSignEditor extends Content
@Override
public void init(Container container)
{
Minecraft minecraft = Minecraft.getInstance();
BlockPos pos = BlockHelper.getFocusedBlockPos();
this.isActive = BlockHelper.getFocusedBlock() instanceof SignBlock;
this.builderSignEditor.targetPos().set(BlockHelper.getFocusedBlockPos());
this.builderSignEditor.targetPos().set(pos);
if(this.isActive && minecraft.level != null)
{
BlockEntity entity = minecraft.level.getBlockEntity(pos);
if(entity instanceof SignBlockEntity sign)
{
this.texts.setIsFront(sign.isFacingFrontText(minecraft.player));
}
}
}
@Override
@@ -73,17 +80,17 @@ public class ContentSignEditor extends Content
{
if(this.isActive)
{
this.commandField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20, Component.translatable("gui.worldhandler.blocks.sign_editor.commmand"));
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[this.selectedLine].getComponent().getCommand());
this.commandField.setValue(this.texts.getLine(this.selectedLine).getCommand());
this.commandField.moveCursorToEnd();
this.commandField.setResponder(text ->
{
this.texts[this.selectedLine].getComponent().setCommand(text);
this.texts.getLine(this.selectedLine).setCommand(text);
container.initButtons();
});
MenuColorField colors = new MenuColorField(x, y, "gui.worldhandler.blocks.sign_editor.text_line_" + (this.selectedLine + 1), this.texts[this.selectedLine].getComponent(), new ILogicColorMenu()
MenuColorField colors = new MenuColorField(x, y, "gui.worldhandler.blocks.sign_editor.text_line_" + (this.selectedLine + 1), this.texts.getLine(this.selectedLine), new ILogicColorMenu()
{
@Override
public boolean validate(String text)
@@ -152,7 +159,7 @@ public class ContentSignEditor extends Content
container.addRenderableWidget(new GuiButtonBase(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.blocks.sign_editor.format_text_line"), () -> this.toggleEditColor(container)));
container.addRenderableWidget(new GuiButtonBase(x + 118, y + 72, 114, 20, Component.translatable("gui.worldhandler.actions.place_command_block"), () ->
{
CommandHelper.sendCommand(container.getPlayer(), this.builderSignEditor, DataCommandBuilder.Label.MERGE_BLOCK, Arrays.stream(this.texts).anyMatch(text -> text.getComponent().isStyled()));
CommandHelper.sendCommand(container.getPlayer(), this.builderSignEditor, DataCommandBuilder.Label.MERGE_BLOCK, this.texts.isStyled());
}));
}
@@ -179,32 +186,31 @@ public class ContentSignEditor extends Content
}
@Override
public void drawScreen(PoseStack matrix, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
public void drawScreen(GuiGraphics guiGraphics, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
{
if(this.isActive)
{
if(!this.editColor)
{
this.commandField.render(matrix, mouseX, mouseY, partialTicks);
this.commandField.render(guiGraphics, mouseX, mouseY, partialTicks);
}
}
else
{
float scale = 4;
PoseStack posestack = RenderSystem.getModelViewStack();
PoseStack posestack = guiGraphics.pose();
posestack.pushPose();
posestack.translate(container.width / 2 - 8.5F * scale, container.height / 2 - 15 - 8.5F * scale, 0);
posestack.scale(scale, scale, scale);
Minecraft.getInstance().getItemRenderer().renderGuiItem(posestack, new ItemStack(Items.OAK_SIGN), 0, 0);
guiGraphics.renderItem(new ItemStack(Items.OAK_SIGN), 0, 0);
posestack.popPose();
RenderSystem.applyModelViewMatrix();
MutableComponent text = Component.translatable("gui.worldhandler.blocks.sign_editor.look_at_sign", KeyHandler.KEY_WORLD_HANDLER.getTranslatedKeyMessage());
Font font = Minecraft.getInstance().font;
font.draw(matrix, text, x + 116 - font.width(text) / 2, y + 70, Config.getSkin().getLabelColor());
guiGraphics.drawString(font, text, x + 116 - font.width(text) / 2, y + 70, Config.getSkin().getLabelColor(), false);
}
}

View File

@@ -9,7 +9,6 @@ import org.apache.commons.lang3.StringUtils;
import com.google.common.base.Predicates;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import exopandora.worldhandler.builder.argument.Coordinate;
import exopandora.worldhandler.builder.argument.tag.AbstractAttributeTag;
@@ -30,7 +29,7 @@ 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.GuiTextFieldTooltip;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
import exopandora.worldhandler.gui.widget.button.LogicSliderAttribute;
import exopandora.worldhandler.gui.widget.button.LogicSliderSimple;
import exopandora.worldhandler.gui.widget.menu.impl.ILogicColorMenu;
@@ -42,7 +41,7 @@ import exopandora.worldhandler.util.ActionHelper;
import exopandora.worldhandler.util.CommandHelper;
import exopandora.worldhandler.util.TextUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.nbt.ByteTag;
import net.minecraft.nbt.CompoundTag;
@@ -117,8 +116,8 @@ public class ContentSummon extends Content
private static final Item[][] HANDS = {SWORDS, SWORDS};
private static final Random RANDOM = new Random();
private GuiTextFieldTooltip mobField;
private GuiTextFieldTooltip nbtField;
private GuiHintTextField mobField;
private GuiHintTextField nbtField;
private int potionPage = 0;
private boolean editColor;
@@ -188,7 +187,7 @@ public class ContentSummon extends Content
@Override
public void initGui(Container container, int x, int y)
{
this.mobField = new GuiTextFieldTooltip(x + 118, y, 114, 20, Component.translatable("gui.worldhandler.entities.summon.start.mob_id"));
this.mobField = new GuiHintTextField(x + 118, y, 114, 20, Component.translatable("gui.worldhandler.entities.summon.start.mob_id"));
this.mobField.setFilter(Predicates.notNull());
this.mobField.setValue(this.mob);
this.mobField.setResponder(text ->
@@ -199,7 +198,7 @@ public class ContentSummon extends Content
container.initButtons();
});
this.nbtField = new GuiTextFieldTooltip(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.entities.summon.start.custom_nbt"));
this.nbtField = new GuiHintTextField(x + 118, y + 48, 114, 20, Component.translatable("gui.worldhandler.entities.summon.start.custom_nbt"));
this.nbtField.setFilter(Predicates.notNull());
this.nbtField.setValue(this.nbt);
this.nbtField.setResponder(text ->
@@ -513,22 +512,21 @@ public class ContentSummon extends Content
}
@Override
public void drawScreen(PoseStack matrix, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
public void drawScreen(GuiGraphics guiGraphics, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
{
if(Page.POTIONS.equals(this.page))
{
Minecraft.getInstance().font.draw(matrix, (this.potionPage + 1) + "/" + (ForgeRegistries.MOB_EFFECTS.getKeys().size() - 2), x + 118, y - 11, Config.getSkin().getHeadlineColor());
guiGraphics.drawString(Minecraft.getInstance().font, (this.potionPage + 1) + "/" + (ForgeRegistries.MOB_EFFECTS.getKeys().size() - 2), x + 118, y - 11, Config.getSkin().getHeadlineColor(), false);
}
else if(Page.EQUIPMENT.equals(this.page))
{
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, BEACON_LOCATION);
for(int i = 0; i < 4; i++)
{
if(Items.AIR.equals(this.entity.getArmorItem(3 - i)))
{
GuiComponent.blit(matrix, x + 118 + 24 + 2, y + 2 + 24 * i, 112, 221, 16, 16);
guiGraphics.blit(BEACON_LOCATION, x + 118 + 24 + 2, y + 2 + 24 * i, 112, 221, 16, 16);
}
}
@@ -536,7 +534,7 @@ public class ContentSummon extends Content
{
if(Items.AIR.equals(this.entity.getHandItem(i)))
{
GuiComponent.blit(matrix, x + 118 + 70 + 2 + 24 * i, y + 2 + 36, 112, 221, 16, 16);
guiGraphics.blit(BEACON_LOCATION, x + 118 + 70 + 2 + 24 * i, y + 2 + 36, 112, 221, 16, 16);
}
}
}

View File

@@ -9,8 +9,6 @@ import java.util.TreeMap;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.mojang.blaze3d.vertex.PoseStack;
import exopandora.worldhandler.Main;
import exopandora.worldhandler.builder.impl.UsercontentCommandBuilder;
import exopandora.worldhandler.gui.category.Categories;
@@ -35,6 +33,7 @@ import exopandora.worldhandler.usercontent.model.JsonWidget;
import exopandora.worldhandler.util.TextUtils;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.network.chat.Component;
@@ -137,7 +136,7 @@ public class ContentUsercontent extends Content
}
@Override
public void drawScreen(PoseStack matrix, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
public void drawScreen(GuiGraphics guiGraphics, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
{
if(this.content.getGui() != null && this.content.getGui().getLabels() != null)
{
@@ -145,7 +144,7 @@ public class ContentUsercontent extends Content
{
if(label.getVisible() == null || label.getVisible().eval(this.engineAdapter))
{
container.getMinecraft().font.draw(matrix, TextUtils.formatNonnull(label.getText()), label.getX() + x, label.getY() + y, label.getColor());
guiGraphics.drawString(Minecraft.getInstance().font, TextUtils.formatNonnull(label.getText()), label.getX() + x, label.getY() + y, label.getColor(), false);
}
}
}

View File

@@ -8,7 +8,7 @@ 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.GuiTextFieldTooltip;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
import exopandora.worldhandler.util.ActionHelper;
import exopandora.worldhandler.util.TextUtils;
import net.minecraft.client.Minecraft;
@@ -22,15 +22,15 @@ public class ContentWorldInfo extends Content
{
private Page page = Page.START;
private GuiTextFieldTooltip posXField;
private GuiTextFieldTooltip posYField;
private GuiTextFieldTooltip posZField;
private GuiHintTextField posXField;
private GuiHintTextField posYField;
private GuiHintTextField posZField;
private GuiTextFieldTooltip worldField;
private GuiTextFieldTooltip seedField;
private GuiHintTextField worldField;
private GuiHintTextField seedField;
private GuiTextFieldTooltip totalTimeField;
private GuiTextFieldTooltip currentTimeField;
private GuiHintTextField totalTimeField;
private GuiHintTextField currentTimeField;
@Override
public void initGui(Container container, int x, int y)
@@ -38,27 +38,27 @@ public class ContentWorldInfo extends Content
Level level = ContentWorldInfo.getSidedWorld();
IntegratedServer server = Minecraft.getInstance().getSingleplayerServer();
this.posXField = new GuiTextFieldTooltip(x + 118, y + 12, 114, 20);
this.posXField = new GuiHintTextField(x + 118, y + 12, 114, 20);
this.posXField.setValue(I18n.get("gui.worldhandler.world_info.start.spawn") + " X: " + ContentWorldInfo.format(level, object -> object.getLevelData().getXSpawn()));
this.posYField = new GuiTextFieldTooltip(x + 118, y + 36, 114, 20);
this.posYField = new GuiHintTextField(x + 118, y + 36, 114, 20);
this.posYField.setValue(I18n.get("gui.worldhandler.world_info.start.spawn") + " Y: " + ContentWorldInfo.format(level, object -> object.getLevelData().getYSpawn()));
this.posZField = new GuiTextFieldTooltip(x + 118, y + 60, 114, 20);
this.posZField = new GuiHintTextField(x + 118, y + 60, 114, 20);
this.posZField.setValue(I18n.get("gui.worldhandler.world_info.start.spawn") + " Z: " + ContentWorldInfo.format(level, object -> object.getLevelData().getZSpawn()));
this.worldField = new GuiTextFieldTooltip(x + 118, y + 12, 114, 20);
this.worldField = new GuiHintTextField(x + 118, y + 12, 114, 20);
this.worldField.setValue(I18n.get("gui.worldhandler.world_info.world.name") + ": " + ContentWorldInfo.format(server, object -> object.getWorldData().getLevelName()));
this.seedField = new GuiTextFieldTooltip(x + 118, y + 36, 114, 20);
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.currentTimeField = new GuiTextFieldTooltip(x + 118, y + 24, 114, 20);
this.currentTimeField = new GuiHintTextField(x + 118, y + 24, 114, 20);
this.updateCurrentTime();
this.totalTimeField = new GuiTextFieldTooltip(x + 118, y + 48, 114, 20);
this.totalTimeField = new GuiHintTextField(x + 118, y + 48, 114, 20);
this.updateTotalTime();
}

View File

@@ -1,8 +1,7 @@
package exopandora.worldhandler.gui.widget;
import com.mojang.blaze3d.vertex.PoseStack;
import exopandora.worldhandler.gui.container.Container;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.events.GuiEventListener;
public interface IWidget extends GuiEventListener
@@ -27,7 +26,7 @@ public interface IWidget extends GuiEventListener
}
default void drawScreen(PoseStack stack, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
default void drawScreen(GuiGraphics guiGraphics, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
{
}

View File

@@ -5,18 +5,18 @@ import com.google.common.base.Predicates;
import exopandora.worldhandler.builder.impl.WorldHandlerCommandBuilder;
import exopandora.worldhandler.config.Config;
import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
public class WidgetCommandSyntax implements IContainerWidget
{
private static final WorldHandlerCommandBuilder BUILDER_WORLD_HANDLER = new WorldHandlerCommandBuilder();
private GuiTextFieldTooltip syntaxField;
private GuiHintTextField syntaxField;
@Override
public void initGui(Container container, int x, int y)
{
this.syntaxField = new GuiTextFieldTooltip(container.width / 2 - 156, container.height - 22, 312, 20);
this.syntaxField = new GuiHintTextField(container.width / 2 - 156, container.height - 22, 312, 20);
this.updateSyntax(container);
}

View File

@@ -1,18 +1,17 @@
package exopandora.worldhandler.gui.widget;
import com.mojang.blaze3d.vertex.PoseStack;
import exopandora.worldhandler.config.Config;
import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.resources.language.I18n;
public class WidgetNameField implements IContainerWidget
{
private final GuiTextFieldTooltip nameField = Util.make(new GuiTextFieldTooltip(0, 0, 0, 11), textfield -> textfield.setMaxLength(16));
private final GuiHintTextField nameField = Util.make(new GuiHintTextField(0, 0, 0, 11), textfield -> textfield.setMaxLength(16));
@Override
public void initGui(Container container, int x, int y)
@@ -33,14 +32,15 @@ public class WidgetNameField implements IContainerWidget
}
@Override
public void drawScreen(PoseStack matrix, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
public void drawScreen(GuiGraphics guiGraphics, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
{
String username = container.getPlayer().isEmpty() && !this.nameField.isFocused() ? I18n.get("gui.worldhandler.generic.edit_username") : container.getPlayer();
Font font = Minecraft.getInstance().font;
int xPos = container.getBackgroundX() + container.getBackgroundWidth() - this.watchOffset() - 7 - Minecraft.getInstance().font.width(username);
int xPos = container.getBackgroundX() + container.getBackgroundWidth() - this.watchOffset() - 7 - font.width(username);
int yPos = container.getBackgroundY() + 7;
Minecraft.getInstance().font.draw(matrix, username, xPos, yPos, Config.getSkin().getLabelColor());
guiGraphics.drawString(font, username, xPos, yPos, Config.getSkin().getLabelColor(), false);
}
@Override

View File

@@ -1,7 +1,6 @@
package exopandora.worldhandler.gui.widget;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import exopandora.worldhandler.config.Config;
import exopandora.worldhandler.gui.category.Category;
@@ -10,12 +9,14 @@ 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;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
public class WidgetTabRenderer implements IContainerWidget
@@ -49,10 +50,11 @@ public class WidgetTabRenderer implements IContainerWidget
}
@Override
public void drawScreen(PoseStack matrix, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
public void drawScreen(GuiGraphics guiGraphics, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
{
Content content = container.getContent();
Category category = content.getCategory();
ResourceLocation texture = ResourceHelper.backgroundTexture();
int xPos = container.getBackgroundX();
int yPos = container.getBackgroundY();
@@ -70,21 +72,21 @@ public class WidgetTabRenderer implements IContainerWidget
if(content.getActiveContent().equals(tab))
{
int height = Config.getSkin().getBackgroundAlphaInt() == 255 ? 25 : 22;
this.drawActiveTab(matrix, container, index, size, xPos + offset, yPos - 22, width, height, title);
this.drawActiveTab(guiGraphics, container, texture, index, size, xPos + offset, yPos - 22, width, height, title);
}
else
{
this.drawInactiveTab(matrix, container, index, size, xPos + offset, yPos - 20, width, 20, title);
this.drawInactiveTab(guiGraphics, container, texture, index, size, xPos + offset, yPos - 20, width, 20, title);
}
}
RenderUtils.colorDefaultBackground();
}
private void drawActiveTab(PoseStack matrix, Container container, int index, int size, int x, int y, int width, int height, Component title)
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();
this.drawTabBackground(matrix, container, x, y, width, height);
this.drawTabBackground(guiGraphics, container, texture, x, y, width, height);
if(!Config.getSkin().sharpEdges())
{
@@ -94,83 +96,81 @@ public class WidgetTabRenderer implements IContainerWidget
{
if(index > 0)
{
RenderUtils.drawTexturedTriangleBL(matrix, container, x, y + height - 2, x - container.getBackgroundX(), 1, 2);
RenderUtils.drawTexturedTriangleBL(guiGraphics, texture, x, y + height - 2, x - container.getBackgroundX(), 1, 2);
}
if(index < size - 1 || size == 1)
{
RenderUtils.drawTexturedTriangleBR(matrix, container, x + width - 2, y + height - 2, x - container.getBackgroundX() + width, 1, 2);
RenderUtils.drawTexturedTriangleBR(guiGraphics, texture, x + width - 2, y + height - 2, x - container.getBackgroundX() + width, 1, 2);
}
if(index == 0)
{
RenderUtils.drawTexturedWedgeGradientTL(matrix, container, x, y + height, 0, height, width, WidgetTabRenderer.WEDGE_HEIGHT);
RenderUtils.drawTexturedWedgeGradientTL(guiGraphics, texture, x, y + height, 0, height, width, WidgetTabRenderer.WEDGE_HEIGHT);
}
if(index == size - 1 && size > 1)
{
RenderUtils.drawTexturedWedgeGradientTR(matrix, container, x, y + height, x - container.getBackgroundX(), height, width, WidgetTabRenderer.WEDGE_HEIGHT);
RenderUtils.drawTexturedWedgeGradientTR(guiGraphics, texture, x, y + height, x - container.getBackgroundX(), height, width, WidgetTabRenderer.WEDGE_HEIGHT);
}
}
else
{
this.drawTabBackgroundMerge(matrix, container, index, size, x, y, width, height);
this.drawTabBackgroundMerge(guiGraphics, container, texture, index, size, x, y, width, height);
}
RenderSystem.disableBlend();
}
this.drawTabTitle(matrix, container, title, true, x, y, width, y + height, 0xFFFFFF);
this.drawTabTitle(guiGraphics, title, true, x, y, width, y + height, 0xFFFFFF);
}
private void drawInactiveTab(PoseStack matrix, Container container, int index, int size, int x, int y, int width, int height, Component title)
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();
this.drawTabBackground(matrix, container, x, y, width, 20);
this.drawTabBackground(guiGraphics, container, texture, x, y, width, 20);
if(!Config.getSkin().sharpEdges())
{
RenderSystem.enableBlend();
this.drawTabBackgroundMerge(matrix, container, index, size, x, y, width, height);
this.drawTabBackgroundMerge(guiGraphics, container, texture, index, size, x, y, width, height);
RenderSystem.disableBlend();
}
this.drawTabTitle(matrix, container, title, false, x, y + 2, width, y + height, 0xE0E0E0);
this.drawTabTitle(guiGraphics, title, false, x, y + 2, width, y + height, 0xE0E0E0);
}
private void drawTabBackgroundMerge(PoseStack matrix, Container container, int index, int size, int x, int y, int width, int height)
private void drawTabBackgroundMerge(GuiGraphics guiGraphics, Container container, ResourceLocation texture, int index, int size, int x, int y, int width, int height)
{
if(index == 0)
{
RenderUtils.drawTexturedTriangleTL(matrix, container, x, y + height, 0, height, 2);
RenderUtils.drawTexturedTriangleTL(guiGraphics, texture, x, y + height, 0, height, 2);
}
if(index == size - 1)
{
RenderUtils.drawTexturedTriangleTR(matrix, container, x + width - 3, y + height, container.getBackgroundWidth() - 3, height, 3);
RenderUtils.drawTexturedTriangleTR(guiGraphics, texture, x + width - 3, y + height, container.getBackgroundWidth() - 3, height, 3);
}
}
private void drawTabBackground(PoseStack matrix, Container container, int x, int y, int width, int height)
private void drawTabBackground(GuiGraphics guiGraphics, Container container, ResourceLocation texture, int x, int y, int width, int height)
{
container.bindBackground();
int left = Mth.ceil(width / 2D);
int right = Mth.floor(width / 2D);
RenderSystem.enableBlend();
GuiComponent.blit(matrix, x, y, 0, 0, left, height);
GuiComponent.blit(matrix, x + left, y, container.getBackgroundWidth() - right, 0, right, height);
guiGraphics.blit(texture, x, y, 0, 0, left, height);
guiGraphics.blit(texture, x + left, y, container.getBackgroundWidth() - right, 0, right, height);
RenderSystem.disableBlend();
}
private void drawTabTitle(PoseStack matrix, GuiComponent gui, Component title, boolean isActive, int x, int y, int width, int height, int color)
private void drawTabTitle(GuiGraphics guiGraphics, Component title, boolean isActive, int x, int y, int width, int height, int color)
{
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
Font font = Minecraft.getInstance().font;
AbstractWidget.renderScrollingString(matrix, font, title, x + 5, y, x + width - 5, height, color);
AbstractWidget.renderScrollingString(guiGraphics, font, title, x + 5, y, x + width - 5, height, color);
}
@Override

View File

@@ -1,12 +1,11 @@
package exopandora.worldhandler.gui.widget;
import com.mojang.blaze3d.vertex.PoseStack;
import exopandora.worldhandler.config.Config;
import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.util.RenderUtils;
import exopandora.worldhandler.util.TextUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
public class WidgetWatch implements IContainerWidget
@@ -14,7 +13,7 @@ public class WidgetWatch implements IContainerWidget
private boolean focused = false;
@Override
public void drawScreen(PoseStack matrix, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
public void drawScreen(GuiGraphics guiGraphics, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
{
final int watchX = container.getBackgroundX() + 233;
final int watchY = container.getBackgroundY() + 5;
@@ -26,11 +25,11 @@ public class WidgetWatch implements IContainerWidget
time = Minecraft.getInstance().level.getLevelData().getDayTime();
}
RenderUtils.drawWatchIntoGui(matrix, container, watchX, watchY, time, Config.getSettings().smoothWatch());
RenderUtils.drawWatchIntoGui(guiGraphics, watchX, watchY, time, Config.getSettings().smoothWatch());
if(Config.getSettings().tooltips() && mouseX >= watchX && mouseX <= watchX + 9 && mouseY >= watchY && mouseY <= watchY + 9)
{
container.renderTooltip(matrix, Component.literal(TextUtils.formatWorldTime(time)), mouseX, mouseY + 9);
guiGraphics.renderTooltip(Minecraft.getInstance().font, Component.literal(TextUtils.formatWorldTime(time)), mouseX, mouseY + 9);
}
}

View File

@@ -1,7 +1,6 @@
package exopandora.worldhandler.gui.widget.button;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import exopandora.worldhandler.config.Config;
import exopandora.worldhandler.util.ActionHandler;
@@ -9,10 +8,11 @@ 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.GuiComponent;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractButton;
import net.minecraft.client.gui.narration.NarrationElementOutput;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
public class GuiButtonBase extends AbstractButton
@@ -31,19 +31,19 @@ public class GuiButtonBase extends AbstractButton
}
@Override
public void renderWidget(PoseStack poseStack, int mouseX, int mouseY, float partialTicks)
public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks)
{
this.renderBackground(poseStack, mouseX, mouseY, partialTicks);
this.renderString(poseStack, Minecraft.getInstance().font, this.getFGColor() | Mth.ceil(this.alpha * 255.0F) << 24);
this.renderBackground(guiGraphics, mouseX, mouseY, partialTicks);
this.renderString(guiGraphics, Minecraft.getInstance().font, this.getFGColor() | Mth.ceil(this.alpha * 255.0F) << 24);
}
protected void renderBackground(PoseStack poseStack, int mouseX, int mouseY, float partialTicks)
protected void renderBackground(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks)
{
RenderSystem.enableBlend();
RenderUtils.colorDefaultButton();
int textureY = this.getTextureY();
RenderSystem.setShaderTexture(0, ResourceHelper.buttonTexture());
ResourceLocation texture = ResourceHelper.buttonTexture();
int hWidth = this.width / 2;
int hHeight = this.height / 2;
@@ -52,19 +52,19 @@ public class GuiButtonBase extends AbstractButton
{
int textureOffset = 46 + textureY * 20;
GuiComponent.blit(poseStack, this.getX(), this.getY(), 0, textureOffset, hWidth, hHeight);
GuiComponent.blit(poseStack, this.getX(), this.getY() + hHeight, 0, textureOffset + 20 - hHeight, hWidth, hHeight);
GuiComponent.blit(poseStack, this.getX() + hWidth, this.getY(), 200 - hWidth, textureOffset, hWidth, hHeight);
GuiComponent.blit(poseStack, this.getX() + hWidth, this.getY() + hHeight, 200 - hWidth, textureOffset + 20 - hHeight, hWidth, hHeight);
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;
GuiComponent.blit(poseStack, this.getX(), this.getY(), 0, textureOffset, hWidth, hHeight);
GuiComponent.blit(poseStack, this.getX(), this.getY() + hHeight, 0, textureOffset + 20 - hHeight, hWidth, hHeight);
GuiComponent.blit(poseStack, this.getX() + hWidth, this.getY(), 200 - hWidth, textureOffset, this.width / 2, hHeight);
GuiComponent.blit(poseStack, this.getX() + hWidth, this.getY() + hHeight, 200 - hWidth, textureOffset + 20 - hHeight, hWidth, hHeight);
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);
}
RenderSystem.disableBlend();

View File

@@ -1,11 +1,10 @@
package exopandora.worldhandler.gui.widget.button;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import exopandora.worldhandler.util.ActionHandler;
import exopandora.worldhandler.util.ResourceHelper;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
public class GuiButtonIcon extends GuiButtonTooltip
@@ -19,20 +18,18 @@ public class GuiButtonIcon extends GuiButtonTooltip
}
@Override
public void renderWidget(PoseStack poseStack, int mouseX, int mouseY, float partialTicks)
public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks)
{
super.renderBackground(poseStack, mouseX, mouseY, partialTicks);
super.renderBackground(guiGraphics, mouseX, mouseY, partialTicks);
if(this.icon != null)
{
this.renderIcon(poseStack);
this.renderIcon(guiGraphics);
}
}
private void renderIcon(PoseStack poseStack)
private void renderIcon(GuiGraphics guiGraphics)
{
RenderSystem.setShaderTexture(0, ResourceHelper.iconTexture());
if(this.active)
{
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
@@ -42,6 +39,6 @@ public class GuiButtonIcon extends GuiButtonTooltip
RenderSystem.setShaderColor(0.8F, 0.8F, 0.8F, 1.0F);
}
GuiComponent.blit(poseStack, this.getX() + this.width / 2 - 4, this.getY() + this.height / 2 - 4, this.icon.getX() * 8, this.icon.getY() * 8, 8, 8);
guiGraphics.blit(ResourceHelper.iconTexture(), this.getX() + this.width / 2 - 4, this.getY() + this.height / 2 - 4, this.icon.getX() * 8, this.icon.getY() * 8, 8, 8);
}
}

View File

@@ -1,9 +1,7 @@
package exopandora.worldhandler.gui.widget.button;
import com.mojang.blaze3d.vertex.PoseStack;
import exopandora.worldhandler.util.ActionHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
@@ -23,9 +21,9 @@ public class GuiButtonItem extends GuiButtonBase
}
@Override
public void renderWidget(PoseStack matrix, int mouseX, int mouseY, float partialTicks)
public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks)
{
super.renderBackground(matrix, mouseX, mouseY, partialTicks);
Minecraft.getInstance().getItemRenderer().renderGuiItem(matrix, this.stack, this.getX() + this.width / 2 - 8, this.getY() + 2);
super.renderBackground(guiGraphics, mouseX, mouseY, partialTicks);
guiGraphics.renderItem(this.stack, this.getX() + this.width / 2 - 8, this.getY() + 2);
}
}

View File

@@ -2,14 +2,12 @@ package exopandora.worldhandler.gui.widget.button;
import java.util.List;
import com.mojang.blaze3d.vertex.PoseStack;
import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.gui.widget.menu.impl.ILogicMapped;
import exopandora.worldhandler.util.TextUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.util.Mth;
@@ -36,9 +34,9 @@ public class GuiButtonList<T> extends GuiButtonTooltip
}
@Override
public void renderWidget(PoseStack poseStack, int mouseX, int mouseY, float partialTicks)
public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks)
{
this.renderBackground(poseStack, mouseX, mouseY, partialTicks);
this.renderBackground(guiGraphics, mouseX, mouseY, partialTicks);
this.updateMessage();
Font font = Minecraft.getInstance().font;
@@ -53,18 +51,18 @@ public class GuiButtonList<T> extends GuiButtonTooltip
int spaceWidth = font.width(" ");
int yPos = this.getY() + (this.height - 8) / 2;
this.renderScrollingString(poseStack, font, combinedArrowWidth / 2 + 2, this.getFGColor() | Mth.ceil(this.alpha * 255.0F) << 24);
this.renderScrollingString(guiGraphics, font, combinedArrowWidth / 2 + 2, this.getFGColor() | Mth.ceil(this.alpha * 255.0F) << 24);
GuiComponent.drawCenteredString(poseStack, font, leftArrow, this.getX() + this.width / 2 - maxWidth / 2 - spaceWidth, yPos, this.getFGColor());
GuiComponent.drawCenteredString(poseStack, font, rightArrow, this.getX() + this.width / 2 + maxWidth / 2 + spaceWidth, yPos, this.getFGColor());
guiGraphics.drawCenteredString(font, leftArrow, this.getX() + this.width / 2 - maxWidth / 2 - spaceWidth, yPos, this.getFGColor());
guiGraphics.drawCenteredString(font, rightArrow, this.getX() + this.width / 2 + maxWidth / 2 + spaceWidth, yPos, this.getFGColor());
}
}
@Override
public void renderTooltip(Screen screen, PoseStack matrix, int mouseX, int mouseY)
public void renderTooltip(GuiGraphics guiGraphics, Font font, int mouseX, int mouseY)
{
this.tooltip = this.logic.formatTooltip(this.items.get(this.persistence.getIndex()), this.persistence.getIndex() + 1, this.items.size());
super.renderTooltip(screen, matrix, mouseX, mouseY);
super.renderTooltip(guiGraphics, font, mouseX, mouseY);
}
@Override

View File

@@ -1,14 +1,13 @@
package exopandora.worldhandler.gui.widget.button;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import exopandora.worldhandler.Main;
import exopandora.worldhandler.config.Config;
import exopandora.worldhandler.util.ActionHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.client.sounds.SoundManager;
import net.minecraft.network.chat.Component;
@@ -31,7 +30,7 @@ public class GuiButtonPiano extends GuiButtonBase
}
@Override
public void renderWidget(PoseStack poseStack, int mouseX, int mouseY, float partialTicks)
public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks)
{
switch(this.type)
{
@@ -54,35 +53,34 @@ public class GuiButtonPiano extends GuiButtonBase
int hovered = this.getTextureY();
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, Config.getSkin().getButtonAlpha());
RenderSystem.setShaderTexture(0, NOTE);
switch(this.type)
{
case LEFT:
case NORMAL:
case RIGHT:
this.drawWhiteKey(poseStack, hovered);
this.drawWhiteKey(guiGraphics, hovered);
break;
case BLACK:
this.drawBlackKey(poseStack, hovered);
this.drawBlackKey(guiGraphics, hovered);
break;
default:
break;
}
}
protected void drawWhiteKey(PoseStack poseStack, int hoverstate)
protected void drawWhiteKey(GuiGraphics guiGraphics, int hoverstate)
{
int textColor = this.getFGColor();
Font font = Minecraft.getInstance().font;
GuiComponent.blit(poseStack, this.getX(), this.getY(), 25 + hoverstate * 15 - 15, 0, 15, 92);
font.draw(poseStack, this.getMessage(), (float) (this.getX() + this.width / 2 - font.width(this.getMessage()) / 2), (float) (this.getY() + (this.height - 8) / 2 + 36), textColor);
guiGraphics.blit(NOTE, this.getX(), this.getY(), 25 + hoverstate * 15 - 15, 0, 15, 92);
guiGraphics.drawString(font, this.getMessage(), this.getX() + this.width / 2 - font.width(this.getMessage()) / 2, this.getY() + (this.height - 8) / 2 + 36, textColor, false);
}
protected void drawBlackKey(PoseStack poseStack, int hoverstate)
protected void drawBlackKey(GuiGraphics guiGraphics, int hoverstate)
{
GuiComponent.blit(poseStack, this.getX(), this.getY(), 55 - hoverstate * 9 + 18, 0, 9, 58);
guiGraphics.blit(NOTE, this.getX(), this.getY(), 55 - hoverstate * 9 + 18, 0, 9, 58);
}
@Override

View File

@@ -1,9 +1,8 @@
package exopandora.worldhandler.gui.widget.button;
import com.mojang.blaze3d.vertex.PoseStack;
import exopandora.worldhandler.util.ActionHandler;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
public class GuiButtonTooltip extends GuiButtonBase
@@ -16,11 +15,11 @@ public class GuiButtonTooltip extends GuiButtonBase
this.tooltip = tooltip;
}
public void renderTooltip(Screen screen, PoseStack poseStack, int mouseX, int mouseY)
public void renderTooltip(GuiGraphics guiGraphics, Font font, int mouseX, int mouseY)
{
if(this.isHovered() && this.tooltip != null && !this.tooltip.getString().isEmpty())
{
screen.renderTooltip(poseStack, this.tooltip, mouseX, mouseY);
guiGraphics.renderTooltip(font, this.tooltip, mouseX, mouseY);
}
}
}

View File

@@ -0,0 +1,66 @@
package exopandora.worldhandler.gui.widget.button;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.network.chat.Component;
public class GuiHintTextField extends EditBox
{
private Component hint;
public GuiHintTextField(int x, int y, int width, int height)
{
this(x, y, width, height, null);
}
public GuiHintTextField(int x, int y, int width, int height, Component hint)
{
super(Minecraft.getInstance().font, x, y, width, height, null);
this.setMaxLength(Integer.MAX_VALUE);
this.hint = hint;
}
@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks)
{
super.render(guiGraphics, mouseX, mouseY, partialTicks);
if(this.isVisible() && !this.isFocused() && this.hint != null && ChatFormatting.stripFormatting(this.getValue()).isEmpty())
{
int x = this.getX();
int y = this.getY();
if(this.getInnerWidth() != this.width)
{
x += 4;
y += (this.height - 8) / 2;
}
guiGraphics.drawString(Minecraft.getInstance().font, this.hint, x, y, 0x7F7F7F);
}
}
public void setHint(Component hint)
{
this.hint = hint;
}
public Component getHint()
{
return this.hint;
}
public void setText(Component text)
{
if(text != null)
{
this.setValue(text.getString());
}
else
{
this.setValue((String) null);
}
}
}

View File

@@ -3,18 +3,19 @@ package exopandora.worldhandler.gui.widget.button;
import java.util.Objects;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
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;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
public class GuiSlider extends GuiButtonBase
{
@@ -34,9 +35,9 @@ public class GuiSlider extends GuiButtonBase
}
@Override
public void renderBackground(PoseStack poseStack, int mouseX, int mouseY, float partialTicks)
public void renderBackground(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks)
{
super.renderBackground(poseStack, mouseX, mouseY, partialTicks);
super.renderBackground(guiGraphics, mouseX, mouseY, partialTicks);
int textureOffset = (Config.getSkin().getTextureType().equals("resourcepack") ? 66 : 20);
@@ -47,9 +48,10 @@ public class GuiSlider extends GuiButtonBase
RenderSystem.enableBlend();
RenderUtils.colorDefaultButton();
ResourceLocation texture = ResourceHelper.buttonTexture();
GuiComponent.blit(poseStack, this.getX() + (int) (this.persistence.getValue() * (float) (this.width - 8)), this.getY(), 0, textureOffset, 4, 20);
GuiComponent.blit(poseStack, this.getX() + (int) (this.persistence.getValue() * (float) (this.width - 8)) + 4, this.getY(), 196, textureOffset, 4, 20);
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);
RenderSystem.disableBlend();
}

View File

@@ -1,67 +0,0 @@
package exopandora.worldhandler.gui.widget.button;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.network.chat.Component;
public class GuiTextFieldTooltip extends EditBox
{
private Component tooltip;
public GuiTextFieldTooltip(int x, int y, int width, int height)
{
this(x, y, width, height, null);
}
public GuiTextFieldTooltip(int x, int y, int width, int height, Component tooltip)
{
super(Minecraft.getInstance().font, x, y, width, height, null);
this.setMaxLength(Integer.MAX_VALUE);
this.tooltip = tooltip;
}
@Override
public void render(PoseStack poseStack, int mouseX, int mouseY, float partialTicks)
{
super.render(poseStack, mouseX, mouseY, partialTicks);
if(this.isVisible() && !this.isFocused() && this.tooltip != null && ChatFormatting.stripFormatting(this.getValue()).isEmpty())
{
int x = this.getX();
int y = this.getY();
if(this.getInnerWidth() != this.width)
{
x += 4;
y += (this.height - 8) / 2;
}
Minecraft.getInstance().font.drawShadow(poseStack, this.tooltip, (float) x, (float) y, 0x7F7F7F);
}
}
public void setTooltip(Component tooltip)
{
this.tooltip = tooltip;
}
public Component getTooltip()
{
return this.tooltip;
}
public void setText(Component text)
{
if(text != null)
{
this.setValue(text.getString());
}
else
{
this.setValue((String) null);
}
}
}

View File

@@ -1,13 +1,12 @@
package exopandora.worldhandler.gui.widget.menu;
import com.mojang.blaze3d.vertex.PoseStack;
import exopandora.worldhandler.gui.container.Container;
import net.minecraft.client.gui.GuiGraphics;
public interface IMenu
{
void initGui(Container container);
void initButtons(Container container);
void tick();
void draw(PoseStack matrix, int mouseX, int mouseY, float partialTicks);
void draw(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks);
}

View File

@@ -7,14 +7,13 @@ import java.util.function.BiFunction;
import javax.annotation.Nullable;
import com.mojang.blaze3d.vertex.PoseStack;
import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
import exopandora.worldhandler.gui.widget.button.GuiButtonList;
import exopandora.worldhandler.gui.widget.button.GuiButtonList.Persistence;
import exopandora.worldhandler.gui.widget.menu.Menu;
import exopandora.worldhandler.util.Node;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
@@ -110,7 +109,7 @@ public class MenuButtonList extends Menu
}
@Override
public void draw(PoseStack matrix, int mouseX, int mouseY, float partialTicks)
public void draw(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks)
{
}

View File

@@ -3,15 +3,14 @@ package exopandora.worldhandler.gui.widget.menu.impl;
import java.util.ArrayList;
import java.util.List;
import com.mojang.blaze3d.vertex.PoseStack;
import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
import exopandora.worldhandler.gui.widget.button.GuiButtonList;
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
import exopandora.worldhandler.gui.widget.menu.Menu;
import exopandora.worldhandler.util.UserStylableComponent;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.Style;
@@ -42,7 +41,7 @@ public class MenuColorField extends Menu
COLORS.add(ChatFormatting.WHITE);
}
private GuiTextFieldTooltip textField;
private GuiHintTextField textField;
private final UserStylableComponent component;
private final ILogicColorMenu logic;
private final String translationKey;
@@ -63,7 +62,7 @@ public class MenuColorField extends Menu
@Override
public void initGui(Container container)
{
this.textField = new GuiTextFieldTooltip(this.x + 118, this.y, 114, 20, Component.translatable(this.translationKey));
this.textField = new GuiHintTextField(this.x + 118, this.y, 114, 20, Component.translatable(this.translationKey));
this.textField.setFilter(this.logic::validate);
this.textField.setFormatter((string, index) -> FormattedCharSequence.forward(string, this.component.getStyle()));
this.textField.setValue(this.component.getText());
@@ -151,7 +150,7 @@ public class MenuColorField extends Menu
}
@Override
public void draw(PoseStack matrix, int mouseX, int mouseY, float partialTicks)
public void draw(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks)
{
}

View File

@@ -3,14 +3,13 @@ package exopandora.worldhandler.gui.widget.menu.impl;
import java.util.List;
import java.util.Objects;
import com.mojang.blaze3d.vertex.PoseStack;
import exopandora.worldhandler.config.Config;
import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
import exopandora.worldhandler.gui.widget.menu.Menu;
import exopandora.worldhandler.util.TextUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
@@ -104,9 +103,9 @@ public class MenuPageList<T> extends Menu
}
@Override
public void draw(PoseStack matrix, int mouseX, int mouseY, float partialTicks)
public void draw(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks)
{
Minecraft.getInstance().font.draw(matrix, String.format("%d/%d", this.persistence.getPage() + 1, this.getTotalPages()), this.x, this.y - 11, Config.getSkin().getHeadlineColor());
guiGraphics.drawString(Minecraft.getInstance().font, String.format("%d/%d", this.persistence.getPage() + 1, this.getTotalPages()), this.x, this.y - 11, Config.getSkin().getHeadlineColor(), false);
}
private void goLeft(Container container)

View File

@@ -13,7 +13,7 @@ import exopandora.worldhandler.gui.widget.button.GuiButtonItem;
import exopandora.worldhandler.gui.widget.button.GuiButtonList;
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
import exopandora.worldhandler.gui.widget.button.GuiSlider;
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
import exopandora.worldhandler.gui.widget.button.GuiHintTextField;
import exopandora.worldhandler.gui.widget.button.LogicSliderSimple;
import exopandora.worldhandler.usercontent.UsercontentAPI;
import exopandora.worldhandler.usercontent.model.JsonItem;
@@ -102,7 +102,7 @@ public class WidgetFactory extends AbstractWidgetFactory
}
else if(JsonWidget.Type.TEXTFIELD.equals(widget.getType()))
{
GuiTextFieldTooltip textfield = new GuiTextFieldTooltip
GuiHintTextField textfield = new GuiHintTextField
(
widget.getLayout().getX() + x,
widget.getLayout().getY() + y,

View File

@@ -17,13 +17,13 @@ import net.minecraft.server.packs.resources.ReloadableResourceManager;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.util.Unit;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.storage.loot.PredicateManager;
import net.minecraft.world.level.storage.loot.LootDataManager;
import net.minecraftforge.common.crafting.conditions.ICondition.IContext;
public class AdvancementHelper implements PreparableReloadListener
{
private static final AdvancementHelper INSTANCE = new AdvancementHelper();
private final ServerAdvancementManager manager = new ServerAdvancementManager(new PredicateManager(), IContext.EMPTY);
private final ServerAdvancementManager manager = new ServerAdvancementManager(new LootDataManager(), IContext.EMPTY);
@Override
public CompletableFuture<Void> reload(PreparationBarrier stage, ResourceManager resourceManager, ProfilerFiller preparationsProfiler, ProfilerFiller reloadProfiler, Executor backgroundExecutor, Executor gameExecutor)

View File

@@ -17,7 +17,7 @@ public class CommandHelper
public static void sendFeedback(CommandSourceStack source, String message)
{
source.sendSuccess(Component.literal(message), false);
source.sendSuccess(() -> Component.literal(message), false);
}
public static boolean canPlayerIssueCommand()

View File

@@ -5,13 +5,14 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
import exopandora.worldhandler.config.Config;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.resources.ResourceLocation;
public class RenderUtils
{
public static final double EPS = 0.0020000000949949026D;
public static void drawWatchIntoGui(PoseStack matrix, GuiComponent gui, int width, int height, long worldTicks, boolean smooth)
public static void drawWatchIntoGui(GuiGraphics guiGraphics, int width, int height, long worldTicks, boolean smooth)
{
float hour = TextUtils.toHour(worldTicks);
float minute = TextUtils.toMinute(worldTicks);
@@ -25,29 +26,29 @@ public class RenderUtils
float rotationHour = (360 / 12) * (hour >= 12 ? (hour - 12) : hour) - 180F;
float rotationMinute = (360 / 60) * minute - 180F;
matrix.pushPose();
matrix.translate(width + 5, height + 5, 0F);
matrix.scale(0.25F, 0.25F, 0.25F);
PoseStack poseStack = guiGraphics.pose();
poseStack.pushPose();
poseStack.translate(width + 5, height + 5, 0F);
poseStack.scale(0.25F, 0.25F, 0.25F);
matrix.mulPose(Axis.ZP.rotationDegrees(rotationHour));
GuiComponent.fill(matrix, -1, -1, 1, 11, 0xFF383838);
matrix.mulPose(Axis.ZN.rotationDegrees(rotationHour));
poseStack.mulPose(Axis.ZP.rotationDegrees(rotationHour));
guiGraphics.fill(-1, -1, 1, 11, 0xFF383838);
poseStack.mulPose(Axis.ZN.rotationDegrees(rotationHour));
matrix.mulPose(Axis.ZP.rotationDegrees(rotationMinute));
GuiComponent.fill(matrix, -1, -1, 1, 15, 0xFF6F6F6F);
matrix.mulPose(Axis.ZN.rotationDegrees(rotationMinute));
poseStack.mulPose(Axis.ZP.rotationDegrees(rotationMinute));
guiGraphics.fill(-1, -1, 1, 15, 0xFF6F6F6F);
poseStack.mulPose(Axis.ZN.rotationDegrees(rotationMinute));
matrix.popPose();
poseStack.popPose();
RenderUtils.colorDefaultButton();
RenderSystem.setShaderTexture(0, ResourceHelper.iconTexture());
GuiComponent.blit(matrix, width + 0, height, 48, 0, 10, 10);
guiGraphics.blit(ResourceHelper.iconTexture(), width + 0, height, 48, 0, 10, 10);
matrix.pushPose();
matrix.scale(0.5F, 0.5F, 0.5F);
GuiComponent.fill(matrix, (width + 5) * 2 - 1, (height + 4) * 2 + 1, (width + 6) * 2 - 1, (height + 5) * 2 + 1, 0xFF000000);
matrix.popPose();
poseStack.pushPose();
poseStack.scale(0.5F, 0.5F, 0.5F);
guiGraphics.fill((width + 5) * 2 - 1, (height + 4) * 2 + 1, (width + 6) * 2 - 1, (height + 5) * 2 + 1, 0xFF000000);
poseStack.popPose();
}
public static void colorDefaultButton()
@@ -85,39 +86,39 @@ public class RenderUtils
RenderSystem.setShaderColor(Math.max(0, r - 0.3F), Math.max(0, g - 0.3F), Math.max(0, b - 0.3F), a);
}
public static void drawTexturedTriangleBL(PoseStack matrix, GuiComponent gui, int x, int y, int textureX, int textureY, int size)
public static void drawTexturedTriangleBL(GuiGraphics guiGraphics, ResourceLocation texture, int x, int y, int textureX, int textureY, int size)
{
for(int i = 0; i < size; i++)
{
GuiComponent.blit(matrix, x, y + i, textureX, textureY + i, i + 1, 1);
guiGraphics.blit(texture, x, y + i, textureX, textureY + i, i + 1, 1);
}
}
public static void drawTexturedTriangleBR(PoseStack matrix, GuiComponent gui, int x, int y, int textureX, int textureY, int size)
public static void drawTexturedTriangleBR(GuiGraphics guiGraphics, ResourceLocation texture, int x, int y, int textureX, int textureY, int size)
{
for(int i = 0; i < size; i++)
{
GuiComponent.blit(matrix, x + size - i - 1, y + i, textureX + size - i - 1, textureY + i, i + 1, 1);
guiGraphics.blit(texture, x + size - i - 1, y + i, textureX + size - i - 1, textureY + i, i + 1, 1);
}
}
public static void drawTexturedTriangleTL(PoseStack matrix, GuiComponent gui, int x, int y, int textureX, int textureY, int size)
public static void drawTexturedTriangleTL(GuiGraphics guiGraphics, ResourceLocation texture, int x, int y, int textureX, int textureY, int size)
{
for(int i = 0; i < size; i++)
{
GuiComponent.blit(matrix, x, y + i, textureX, textureY, size - i, 1);
guiGraphics.blit(texture, x, y + i, textureX, textureY, size - i, 1);
}
}
public static void drawTexturedTriangleTR(PoseStack matrix, GuiComponent gui, int x, int y, int textureX, int textureY, int size)
public static void drawTexturedTriangleTR(GuiGraphics guiGraphics, ResourceLocation texture, int x, int y, int textureX, int textureY, int size)
{
for(int i = 0; i < size; i++)
{
GuiComponent.blit(matrix, x + i, y + i, textureX + i, textureY, size - i, 1);
guiGraphics.blit(texture, x + i, y + i, textureX + i, textureY, size - i, 1);
}
}
public static void drawTexturedWedgeGradientTR(PoseStack matrix, GuiComponent gui, int x, int y, int textureX, int textureY, int width, int height)
public static void drawTexturedWedgeGradientTR(GuiGraphics guiGraphics, ResourceLocation texture, int x, int y, int textureX, int textureY, int width, int height)
{
RenderSystem.enableBlend();
@@ -127,13 +128,13 @@ public class RenderUtils
int z = width - (int) (w * width);
RenderUtils.colorDefaultBackground(w);
GuiComponent.blit(matrix, x + z, y + i, textureX + z, textureY + i, width - z, 1);
guiGraphics.blit(texture, x + z, y + i, textureX + z, textureY + i, width - z, 1);
}
RenderSystem.disableBlend();
}
public static void drawTexturedWedgeGradientTL(PoseStack matrix, GuiComponent gui, int x, int y, int textureX, int textureY, int width, int height)
public static void drawTexturedWedgeGradientTL(GuiGraphics guiGraphics, ResourceLocation texture, int x, int y, int textureX, int textureY, int width, int height)
{
RenderSystem.enableBlend();
@@ -143,7 +144,7 @@ public class RenderUtils
int z = (int) (w * width);
RenderUtils.colorDefaultBackground(w);
GuiComponent.blit(matrix, x, y + i, textureX, textureY + i, z, 1);
guiGraphics.blit(texture, x, y + i, textureX, textureY + i, z, 1);
}
RenderSystem.disableBlend();

View File

@@ -6,5 +6,5 @@ public net.minecraft.commands.arguments.coordinates.LocalCoordinates m_119908_(L
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
public net.minecraft.client.gui.components.AbstractWidget m_274366_(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/gui/Font;Lnet/minecraft/network/chat/Component;IIIII)V # renderScrollingString
public net.minecraft.world.level.storage.PrimaryLevelData f_78443_ # settings
public net.minecraft.client.gui.components.AbstractWidget m_280138_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/gui/Font;Lnet/minecraft/network/chat/Component;IIIII)V # renderScrollingString

View File

@@ -1,5 +1,5 @@
modLoader="javafml"
loaderVersion="[45,)"
loaderVersion="[46,)"
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.19.4-${version}"
version="1.20-${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.19.4,)"
versionRange="[1.20,)"
ordering="NONE"
side="BOTH"

View File

@@ -193,7 +193,7 @@
"gui.worldhandler.items.enchantment.level": "Level",
"gui.worldhandler.items.enchantment.enchant": "Enchant",
"gui.worldhandler.blocks.sign_editor.look_at_sign": "Look at a Sign and press '%s'",
"gui.worldhandler.blocks.sign_editor.look_at_sign": "Look at a sign and press '%s'",
"gui.worldhandler.blocks.sign_editor.text_line_1": "Text Line I",
"gui.worldhandler.blocks.sign_editor.text_line_2": "Text Line II",
"gui.worldhandler.blocks.sign_editor.text_line_3": "Text Line III",
@@ -201,7 +201,7 @@
"gui.worldhandler.blocks.sign_editor.commmand": "Command",
"gui.worldhandler.blocks.sign_editor.format_text_line": "Format Text Line",
"gui.worldhandler.blocks.note_block_editor.look_at_note_block": "Look at a Note Block and press '%s'",
"gui.worldhandler.blocks.note_block_editor.look_at_note_block": "Look at a note block and press '%s'",
"gui.worldhandler.blocks.note_block_editor.c": "C",
"gui.worldhandler.blocks.note_block_editor.d": "D",
"gui.worldhandler.blocks.note_block_editor.e": "E",

View File

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