mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-10 20:11:35 +01:00
Goggle overlay offset
-added two config entries to offset the goggle overlay on x/y axis -added a command (/create overlay [reset]) to allow editing the overlay position ingame
This commit is contained in:
parent
a25f90f4ab
commit
480dcdebed
10 changed files with 213 additions and 17 deletions
|
@ -336,7 +336,7 @@ c77b46d8b459e5c7cc495393546f3fcca8a1fa1d assets\create\blockstates\weathered_lim
|
|||
7f39521b211441f5c3e06d60c5978cebe16cacfb assets\create\blockstates\zinc_block.json
|
||||
b7181bcd8182b2f17088e5aa881f374c9c65470c assets\create\blockstates\zinc_ore.json
|
||||
5753bc985f4c202fe16387c32fb8ad80c631c933 assets\create\lang\en_ud.json
|
||||
0640b1b64ac1a1e337178f932f22b0b2aea61d46 assets\create\lang\en_us.json
|
||||
21f721489c30a85337d5007895a54ff1db9e5f6c assets\create\lang\en_us.json
|
||||
846200eb548d3bfa2e77b41039de159b4b6cfb45 assets\create\models\block\acacia_window.json
|
||||
1930fa3a3c98d53dd19e4ee7f55bc27fd47aa281 assets\create\models\block\acacia_window_pane_noside.json
|
||||
1763ea2c9b981d187f5031ba608f3d5d3be3986a assets\create\models\block\acacia_window_pane_noside_alt.json
|
||||
|
|
|
@ -815,6 +815,15 @@
|
|||
|
||||
"create.mechanical_mixer.min_ingredients": "Min. Ingredients",
|
||||
|
||||
"create.gui.config.overlay1": "Hi :)",
|
||||
"create.gui.config.overlay2": "This is a sample overlay",
|
||||
"create.gui.config.overlay3": "Click or drag with your mouse",
|
||||
"create.gui.config.overlay4": "to move this preview",
|
||||
"create.gui.config.overlay5": "Press ESC to exit this screen",
|
||||
"create.gui.config.overlay6": "and save the new position",
|
||||
"create.gui.config.overlay7": "Run /create overlay reset",
|
||||
"create.gui.config.overlay8": "to reset to the default position",
|
||||
|
||||
"create.command.killTPSCommand": "killtps",
|
||||
"create.command.killTPSCommand.status.slowed_by.0": "[Create]: Server tick is currently slowed by %s ms :o",
|
||||
"create.command.killTPSCommand.status.slowed_by.1": "[Create]: Server tick is slowed by %s ms now >:)",
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
package com.simibubi.create.content.contraptions.goggles;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.gui.AbstractSimiScreen;
|
||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GoggleConfigScreen extends AbstractSimiScreen {
|
||||
|
||||
private int offsetX;
|
||||
private int offsetY;
|
||||
private final List<String> tooltip;
|
||||
|
||||
public GoggleConfigScreen() {
|
||||
String spacing = " ";
|
||||
tooltip = new ArrayList<>();
|
||||
tooltip.add(spacing + Lang.translate("gui.config.overlay1"));
|
||||
tooltip.add(spacing + TextFormatting.GRAY + Lang.translate("gui.config.overlay2"));
|
||||
tooltip.add("");
|
||||
tooltip.add(spacing + Lang.translate("gui.config.overlay3"));
|
||||
tooltip.add(spacing + Lang.translate("gui.config.overlay4"));
|
||||
tooltip.add("");
|
||||
tooltip.add(spacing + TextFormatting.GRAY + Lang.translate("gui.config.overlay5"));
|
||||
tooltip.add(spacing + TextFormatting.GRAY + Lang.translate("gui.config.overlay6"));
|
||||
tooltip.add("");
|
||||
tooltip.add(spacing + Lang.translate("gui.config.overlay7"));
|
||||
tooltip.add(spacing + Lang.translate("gui.config.overlay8"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
this.width = mc.getWindow().getScaledWidth();
|
||||
this.height = mc.getWindow().getScaledHeight();
|
||||
|
||||
offsetX = AllConfigs.CLIENT.overlayOffsetX.get();
|
||||
offsetY = AllConfigs.CLIENT.overlayOffsetY.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removed() {
|
||||
AllConfigs.CLIENT.overlayOffsetX.set(offsetX);
|
||||
AllConfigs.CLIENT.overlayOffsetY.set(offsetY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double x, double y, int button) {
|
||||
updateOffset(x, y);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseDragged(double p_mouseDragged_1_, double p_mouseDragged_3_, int p_mouseDragged_5_, double p_mouseDragged_6_, double p_mouseDragged_8_) {
|
||||
updateOffset(p_mouseDragged_1_, p_mouseDragged_3_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updateOffset(double windowX, double windowY) {
|
||||
offsetX = (int) (windowX - (this.width / 2));
|
||||
offsetY = (int) (windowY - (this.height / 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderWindow(int mouseX, int mouseY, float partialTicks) {
|
||||
RenderSystem.pushMatrix();
|
||||
int posX = this.width / 2 + offsetX;
|
||||
int posY = this.height / 2 + offsetY;
|
||||
//tooltipScreen.renderTooltip(tooltip, tooltipScreen.width / 2, tooltipScreen.height / 2);
|
||||
renderTooltip(tooltip, posX, posY);
|
||||
|
||||
ItemStack item = AllItems.GOGGLES.asStack();
|
||||
//GuiGameElement.of(item).at(tooltipScreen.width / 2 + 10, tooltipScreen.height / 2 - 16).render();
|
||||
GuiGameElement.of(item).at(posX + 10, posY - 16).render();
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
}
|
|
@ -1,12 +1,9 @@
|
|||
package com.simibubi.create.content.contraptions.goggles;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
|
@ -23,6 +20,9 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
|||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@EventBusSubscriber(value = Dist.CLIENT)
|
||||
public class GoggleOverlayRenderer {
|
||||
|
||||
|
@ -76,10 +76,14 @@ public class GoggleOverlayRenderer {
|
|||
RenderSystem.pushMatrix();
|
||||
Screen tooltipScreen = new TooltipScreen(null);
|
||||
tooltipScreen.init(mc, mc.getWindow().getScaledWidth(), mc.getWindow().getScaledHeight());
|
||||
tooltipScreen.renderTooltip(tooltip, tooltipScreen.width / 2, tooltipScreen.height / 2);
|
||||
|
||||
int posX = tooltipScreen.width / 2 + AllConfigs.CLIENT.overlayOffsetX.get();
|
||||
int posY = tooltipScreen.height / 2 + AllConfigs.CLIENT.overlayOffsetY.get();
|
||||
//tooltipScreen.renderTooltip(tooltip, tooltipScreen.width / 2, tooltipScreen.height / 2);
|
||||
tooltipScreen.renderTooltip(tooltip, posX, posY);
|
||||
|
||||
ItemStack item = AllItems.GOGGLES.asStack();
|
||||
GuiGameElement.of(item).at(tooltipScreen.width / 2 + 10, tooltipScreen.height / 2 - 16).render();
|
||||
//GuiGameElement.of(item).at(tooltipScreen.width / 2 + 10, tooltipScreen.height / 2 - 16).render();
|
||||
GuiGameElement.of(item).at(posX + 10, posY - 16).render();
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,19 +1,23 @@
|
|||
package com.simibubi.create.foundation.command;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.simibubi.create.content.contraptions.goggles.GoggleConfigScreen;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.gui.ScreenOpener;
|
||||
import com.simibubi.create.foundation.networking.SimplePacketBase;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ConfigureConfigPacket extends SimplePacketBase {
|
||||
|
||||
private String option;
|
||||
private String value;
|
||||
private final String option;
|
||||
private final String value;
|
||||
|
||||
public ConfigureConfigPacket(String option, String value) {
|
||||
this.option = option;
|
||||
|
@ -34,11 +38,44 @@ public class ConfigureConfigPacket extends SimplePacketBase {
|
|||
@Override
|
||||
public void handle(Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {
|
||||
if (option.equals("rainbowDebug")) {
|
||||
AllConfigs.CLIENT.rainbowDebug.set(Boolean.parseBoolean(value));
|
||||
try {
|
||||
Actions.valueOf(option).performAction(value);
|
||||
} catch (IllegalArgumentException e) {
|
||||
LogManager.getLogger().warn("Received ConfigureConfigPacket with invalid Option: " + option);
|
||||
}
|
||||
}));
|
||||
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
|
||||
enum Actions {
|
||||
rainbowDebug((value) -> {
|
||||
AllConfigs.CLIENT.rainbowDebug.set(Boolean.parseBoolean(value));
|
||||
}),
|
||||
overlayScreen((value) -> {
|
||||
overlayScreenAction();
|
||||
}),
|
||||
overlayReset((value) -> {
|
||||
AllConfigs.CLIENT.overlayOffsetX.set(0);
|
||||
AllConfigs.CLIENT.overlayOffsetY.set(0);
|
||||
}),
|
||||
|
||||
;
|
||||
|
||||
private final Consumer<String> consumer;
|
||||
|
||||
Actions(Consumer<String> action) {
|
||||
this.consumer = action;
|
||||
}
|
||||
|
||||
void performAction(String value){
|
||||
consumer.accept(value);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static void overlayScreenAction(){
|
||||
//this doesn't work if i move it into the enum constructor like the other two. if there's a proper way to do this, please let me know
|
||||
ScreenOpener.open(new GoggleConfigScreen());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ public class CreateCommand {
|
|||
public CreateCommand(CommandDispatcher<CommandSource> dispatcher) {
|
||||
dispatcher.register(Commands.literal("create")
|
||||
.then(ToggleDebugCommand.register())
|
||||
.then(OverlayConfigCommand.register())
|
||||
.then(ClearBufferCacheCommand.register())
|
||||
//.then(KillTPSCommand.register()) //Commented out for release
|
||||
);
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package com.simibubi.create.foundation.command;
|
||||
|
||||
import com.mojang.brigadier.builder.ArgumentBuilder;
|
||||
import com.simibubi.create.foundation.networking.AllPackets;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.Commands;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.network.PacketDistributor;
|
||||
|
||||
public class OverlayConfigCommand {
|
||||
|
||||
public static ArgumentBuilder<CommandSource, ?> register() {
|
||||
return Commands.literal("overlay")
|
||||
.requires(cs -> cs.hasPermissionLevel(0))
|
||||
.then(Commands.literal("reset")
|
||||
.executes(ctx -> {
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> ConfigureConfigPacket.Actions.overlayReset.performAction(""));
|
||||
|
||||
DistExecutor.runWhenOn(Dist.DEDICATED_SERVER, () -> () ->
|
||||
AllPackets.channel.send(
|
||||
PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) ctx.getSource().getEntity()),
|
||||
new ConfigureConfigPacket(ConfigureConfigPacket.Actions.overlayReset.name(), "")));
|
||||
|
||||
ctx.getSource().sendFeedback(new StringTextComponent("reset overlay offset"), true);
|
||||
|
||||
return 1;
|
||||
})
|
||||
)
|
||||
.executes(ctx -> {
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> ConfigureConfigPacket.Actions.overlayScreen.performAction(""));
|
||||
|
||||
DistExecutor.runWhenOn(Dist.DEDICATED_SERVER, () -> () ->
|
||||
AllPackets.channel.send(
|
||||
PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) ctx.getSource().getEntity()),
|
||||
new ConfigureConfigPacket(ConfigureConfigPacket.Actions.overlayScreen.name(), "")));
|
||||
|
||||
ctx.getSource().sendFeedback(new StringTextComponent("window opened"), true);
|
||||
|
||||
return 1;
|
||||
});
|
||||
|
||||
}
|
||||
}
|
|
@ -21,12 +21,13 @@ public class ToggleDebugCommand {
|
|||
.then(Commands.argument("value", BoolArgumentType.bool())
|
||||
.executes(ctx -> {
|
||||
boolean value = BoolArgumentType.getBool(ctx, "value");
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> AllConfigs.CLIENT.rainbowDebug.set(value));
|
||||
//DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> AllConfigs.CLIENT.rainbowDebug.set(value));
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> ConfigureConfigPacket.Actions.rainbowDebug.performAction(String.valueOf(value)));
|
||||
|
||||
DistExecutor.runWhenOn(Dist.DEDICATED_SERVER, () -> () ->
|
||||
AllPackets.channel.send(
|
||||
PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) ctx.getSource().getEntity()),
|
||||
new ConfigureConfigPacket("rainbowDebug", String.valueOf(value))));
|
||||
new ConfigureConfigPacket(ConfigureConfigPacket.Actions.rainbowDebug.name(), String.valueOf(value))));
|
||||
|
||||
ctx.getSource().sendFeedback(new StringTextComponent((value ? "enabled" : "disabled") + " rainbow debug"), true);
|
||||
|
||||
|
|
|
@ -13,6 +13,9 @@ public class CClient extends ConfigBase {
|
|||
public ConfigBool rainbowDebug =
|
||||
b(true, "enableRainbowDebug", "Show colourful debug information while the F3-Menu is open.");
|
||||
|
||||
public ConfigInt overlayOffsetX = i(0, Integer.MIN_VALUE, Integer.MAX_VALUE, "overlayOffsetX", "Offset the overlay from goggle- and hover- information by this many pixels on the X axis; Use /create overlay");
|
||||
public ConfigInt overlayOffsetY = i(0, Integer.MIN_VALUE, Integer.MAX_VALUE, "overlayOffsetY", "Offset the overlay from goggle- and hover- information by this many pixels on the Y axis; Use /create overlay");
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "client";
|
||||
|
|
|
@ -343,6 +343,15 @@
|
|||
"create.tooltip.analogStrength": "Analog Strength: %1$s/15",
|
||||
"create.mechanical_mixer.min_ingredients": "Min. Ingredients",
|
||||
|
||||
"create.gui.config.overlay1": "Hi :)",
|
||||
"create.gui.config.overlay2": "This is a sample overlay",
|
||||
"create.gui.config.overlay3": "Click or drag with your mouse",
|
||||
"create.gui.config.overlay4": "to move this preview",
|
||||
"create.gui.config.overlay5": "Press ESC to exit this screen",
|
||||
"create.gui.config.overlay6": "and save the new position",
|
||||
"create.gui.config.overlay7": "Run /create overlay reset",
|
||||
"create.gui.config.overlay8": "to reset to the default position",
|
||||
|
||||
"create.command.killTPSCommand": "killtps",
|
||||
"create.command.killTPSCommand.status.slowed_by.0": "[Create]: Server tick is currently slowed by %s ms :o",
|
||||
"create.command.killTPSCommand.status.slowed_by.1": "[Create]: Server tick is slowed by %s ms now >:)",
|
||||
|
|
Loading…
Reference in a new issue