This commit is contained in:
Waterpicker 2022-06-24 05:19:52 -05:00
parent 632eb3cdf6
commit e6a5d38f55
11 changed files with 135 additions and 147 deletions

View File

@ -14,6 +14,8 @@ import net.montoyo.wd.client.ClientProxy;
import net.montoyo.wd.utilities.BlockSide; import net.montoyo.wd.utilities.BlockSide;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import java.util.Optional;
import static net.minecraftforge.api.distmarker.Dist.CLIENT; import static net.minecraftforge.api.distmarker.Dist.CLIENT;
import static org.lwjgl.opengl.GL11.glColor4f; import static org.lwjgl.opengl.GL11.glColor4f;
@ -94,16 +96,18 @@ public class GuiMinePad extends WDScreen {
} }
public void key(int keyCode, int scanCode, boolean pressed) { public void key(int keyCode, int scanCode, boolean pressed) {
char key = getChar(keyCode, scanCode); Optional<Character> key = getChar(keyCode, scanCode);
if (pad.view != null && key.isPresent()) {
char c = key.get();
if (pad.view != null) {
if (pressed) if (pressed)
pad.view.injectKeyPressedByKeyCode(keyCode, key, 0); pad.view.injectKeyPressedByKeyCode(keyCode, c, 0);
else else
pad.view.injectKeyReleasedByKeyCode(keyCode, key, 0); pad.view.injectKeyReleasedByKeyCode(keyCode, c, 0);
if (key != 0) if (c != 0)
pad.view.injectKeyTyped(key, 0); pad.view.injectKeyTyped(c, 0);
} }
} }
@ -150,7 +154,7 @@ public class GuiMinePad extends WDScreen {
} }
} }
public char getChar(int keyCode, int scanCode) { public static Optional<Character> getChar(int keyCode, int scanCode) {
String keystr = GLFW.glfwGetKeyName(keyCode, scanCode); String keystr = GLFW.glfwGetKeyName(keyCode, scanCode);
if(keystr == null){ if(keystr == null){
keystr = "\0"; keystr = "\0";
@ -159,10 +163,10 @@ public class GuiMinePad extends WDScreen {
keystr = "\n"; keystr = "\n";
} }
if(keystr.length() == 0){ if(keystr.length() == 0){
return (char) -1; return Optional.empty();
} }
return keystr.charAt(keystr.length() - 1); return Optional.of(keystr.charAt(keystr.length() - 1));
} }
@Override @Override

View File

@ -4,15 +4,11 @@
package net.montoyo.wd.client.gui; package net.montoyo.wd.client.gui;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.resources.language.I18n; import net.minecraft.client.resources.language.I18n;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.item.ItemStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.montoyo.wd.WebDisplays; import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.client.gui.controls.*; import net.montoyo.wd.client.gui.controls.*;
@ -176,7 +172,7 @@ public class GuiScreenConfig extends WDScreen {
updateMyRights(); updateMyRights();
updateRotationStr(); updateRotationStr();
minecraft.getSoundManager().play(PositionedSoundRecord.getRecord(WebDisplays.INSTANCE.soundScreenCfg, 1.0f, 1.0f)); minecraft.getSoundManager().play(SimpleSoundInstance.forUI(WebDisplays.INSTANCE.soundScreenCfg, 1.0f, 1.0f));
} }
private void updateRotationStr() { private void updateRotationStr() {
@ -247,8 +243,8 @@ public class GuiScreenConfig extends WDScreen {
} else if(ev.getSource() == tfResX) { } else if(ev.getSource() == tfResX) {
tfResX.setFocused(false); tfResX.setFocused(false);
tfResY.focus(); tfResY.focus();
tfResY.getMcField().setCursorPositionZero(); tfResY.getMcField().setCursorPosition(0);
tfResY.getMcField().setSelectionPos(tfResY.getText().length()); tfResY.getMcField().setHighlightPos(tfResY.getText().length());
} }
} }
@ -371,8 +367,8 @@ public class GuiScreenConfig extends WDScreen {
} }
@Override @Override
public void updateScreen() { public void tick() {
super.updateScreen(); super.tick();
if(acFailTicks >= 0) { if(acFailTicks >= 0) {
if(++acFailTicks >= 10) { if(++acFailTicks >= 10) {

View File

@ -4,22 +4,24 @@
package net.montoyo.wd.client.gui; package net.montoyo.wd.client.gui;
import net.minecraft.client.audio.ISound; import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.audio.PositionedSoundRecord; import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.renderer.BufferBuilder; import com.mojang.blaze3d.vertex.*;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.resources.language.I18n;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.client.resources.sounds.SoundInstance;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.util.ResourceLocation; import net.minecraft.network.chat.Component;
import net.minecraft.util.SoundCategory; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.sounds.SoundSource;
import net.montoyo.wd.WebDisplays; import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.miniserv.Constants; import net.montoyo.wd.miniserv.Constants;
import net.montoyo.wd.miniserv.client.*; import net.montoyo.wd.miniserv.client.*;
import net.montoyo.wd.net.Messages;
import net.montoyo.wd.utilities.*; import net.montoyo.wd.utilities.*;
import org.lwjgl.input.Keyboard; import org.lwjgl.glfw.GLFW;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.swing.filechooser.FileSystemView; import javax.swing.filechooser.FileSystemView;
@ -32,8 +34,9 @@ import java.text.Collator;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.function.Supplier;
import static org.lwjgl.opengl.GL11.*; import static net.montoyo.wd.client.gui.GuiMinePad.getChar;
public class GuiServer extends WDScreen { public class GuiServer extends WDScreen {
@ -59,7 +62,7 @@ public class GuiServer extends WDScreen {
private int accessTrials; private int accessTrials;
private int accessTime; private int accessTime;
private int accessState = -1; private int accessState = -1;
private PositionedSoundRecord accessSound; private SimpleSoundInstance accessSound;
//Upload wizard //Upload wizard
private boolean uploadWizard; private boolean uploadWizard;
@ -71,6 +74,7 @@ public class GuiServer extends WDScreen {
private long uploadFilterTime; private long uploadFilterTime;
public GuiServer(Vector3i vec, NameUUIDPair owner) { public GuiServer(Vector3i vec, NameUUIDPair owner) {
super(Component.nullToEmpty(null));
serverPos = vec; serverPos = vec;
this.owner = owner; this.owner = owner;
//userPrompt = owner.name + "@miniserv$ "; //userPrompt = owner.name + "@miniserv$ ";
@ -85,75 +89,73 @@ public class GuiServer extends WDScreen {
} }
private static String tr(String key, Object ... args) { private static String tr(String key, Object ... args) {
return I18n.format("webdisplays.server." + key, args); return I18n.get("webdisplays.server." + key, args);
} }
@Override @Override
public void drawScreen(int mouseX, int mouseY, float ptt) { public void render(PoseStack poseStack, int mouseX, int mouseY, float ptt) {
super.drawScreen(mouseX, mouseY, ptt); super.render(poseStack, mouseX, mouseY, ptt);
int x = (width - 256) / 2; int x = (width - 256) / 2;
int y = (height - 176) / 2; int y = (height - 176) / 2;
GlStateManager.enableTexture2D(); RenderSystem.enableTexture();
mc.renderEngine.bindTexture(BG_IMAGE); RenderSystem.setShaderTexture(0, BG_IMAGE);
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
drawTexturedModalRect(x, y, 0, 0, 256, 176); blit(poseStack, x, y, 0, 0, 256, 176);
x += 18; x += 18;
y += 18; y += 18;
for(int i = 0; i < lines.size(); i++) { for(int i = 0; i < lines.size(); i++) {
if(selectedLine == i) { if(selectedLine == i) {
drawWhiteQuad(x - 1, y - 2, fontRenderer.getStringWidth(lines.get(i)) + 1, 12); drawWhiteQuad(x - 1, y - 2, font.width(lines.get(i)) + 1, 12);
fontRenderer.drawString(lines.get(i), x, y, 0xFF129700, false); font.drawShadow(poseStack, lines.get(i), x, y, 0xFF129700, false);
} else } else
fontRenderer.drawString(lines.get(i), x, y, 0xFFFFFFFF, false); font.drawShadow(poseStack, lines.get(i), x, y, 0xFFFFFFFF, false);
y += 12; y += 12;
} }
if(!promptLocked) { if(!promptLocked) {
x = fontRenderer.drawString(userPrompt, x, y, 0xFFFFFFFF, false); x = font.drawShadow(poseStack, userPrompt, x, y, 0xFFFFFFFF, false);
x = fontRenderer.drawString(prompt, x, y, 0xFFFFFFFF, false); x = font.drawShadow(poseStack, prompt, x, y, 0xFFFFFFFF, false);
} }
if(!uploadWizard && blinkTime < 5) if(!uploadWizard && blinkTime < 5)
drawWhiteQuad(x + 1, y, 6, 8); drawWhiteQuad(x + 1, y, 6, 8);
GlStateManager.disableAlpha(); RenderSystem.enableTexture();
GlStateManager.enableTexture2D(); RenderSystem.enableBlend();
GlStateManager.enableBlend(); RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); RenderSystem.setShaderTexture(0, FG_IMAGE);
mc.renderEngine.bindTexture(FG_IMAGE); RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); blit(poseStack,(width - 256) / 2, (height - 176) / 2, 0, 0, 256, 176);
drawTexturedModalRect((width - 256) / 2, (height - 176) / 2, 0, 0, 256, 176);
GlStateManager.enableAlpha();
} }
private void drawWhiteQuad(int x, int y, int w, int h) { private void drawWhiteQuad(int x, int y, int w, int h) {
double xd = (double) x; float xd = (float) x;
double xd2 = (double) (x + w); float xd2 = (float) (x + w);
double yd = (double) y; float yd = (float) y;
double yd2 = (double) (y + h); float yd2 = (float) (y + h);
double zd = (double) zLevel; float zd = (float) getBlitOffset();
GlStateManager.disableTexture2D(); RenderSystem.disableTexture();
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
Tessellator t = Tessellator.getInstance(); Tesselator t = Tesselator.getInstance();
BufferBuilder bb = t.getBuffer(); BufferBuilder bb = t.getBuilder();
bb.begin(GL_QUADS, DefaultVertexFormats.POSITION); bb.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION);
bb.pos(xd, yd2, zd).endVertex(); bb.vertex(xd, yd2, zd).endVertex();
bb.pos(xd2, yd2, zd).endVertex(); bb.vertex(xd2, yd2, zd).endVertex();
bb.pos(xd2, yd, zd).endVertex(); bb.vertex(xd2, yd, zd).endVertex();
bb.pos(xd, yd, zd).endVertex(); bb.vertex(xd, yd, zd).endVertex();
t.draw(); t.end();
GlStateManager.enableTexture2D(); RenderSystem.enableTexture();
} }
@Override @Override
public void updateScreen() { public void tick() {
super.updateScreen(); super.tick();
if(accessState >= 0) { if(accessState >= 0) {
if(--accessTime <= 0) { if(--accessTime <= 0) {
@ -167,8 +169,8 @@ public class GuiServer extends WDScreen {
accessTime = 20; accessTime = 20;
} else { } else {
if(accessSound == null) { if(accessSound == null) {
accessSound = new PositionedSoundRecord(WebDisplays.INSTANCE.soundServer.getSoundName(), SoundCategory.MASTER, 1.0f, 1.0f, true, 0, ISound.AttenuationType.NONE, 0.0f, 0.0f, 0.0f); accessSound = new SimpleSoundInstance(WebDisplays.INSTANCE.soundServer.getLocation(), SoundSource.MASTER, 1.0f, 1.0f, true, 0, SoundInstance.Attenuation.NONE, 0.0f, 0.0f, 0.0f, false);
mc.getSoundHandler().playSound(accessSound); minecraft.getSoundManager().play(accessSound);
} }
writeLine("YOU DIDN'T SAY THE MAGIC WORD!"); writeLine("YOU DIDN'T SAY THE MAGIC WORD!");
@ -199,10 +201,38 @@ public class GuiServer extends WDScreen {
} }
@Override @Override
public void handleKeyboardInput() throws IOException { public boolean keyReleased(int keyCode, int scanCode, int modifiers) {
boolean keyState = Keyboard.getEventKeyState(); Supplier<Boolean> predicate = () -> super.keyReleased(keyCode, scanCode, modifiers);
int keyCode = Keyboard.getEventKey();
try {
return handleKeyboardInput(keyCode, true, predicate);
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
Supplier<Boolean> predicate = () -> super.keyPressed(keyCode, scanCode, modifiers);
getChar(keyCode, scanCode).ifPresent(c -> {
try {
keyTyped(c, keyCode);
} catch (IOException e) {
e.printStackTrace();
}
});
try {
return handleKeyboardInput(keyCode, true, predicate);
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
public boolean handleKeyboardInput(int keyCode, boolean keyState, Supplier<Boolean> booleanSupplier) throws IOException {
if(uploadWizard) { if(uploadWizard) {
if(keyState) { if(keyState) {
if(keyCode == Keyboard.KEY_UP) { if(keyCode == Keyboard.KEY_UP) {
@ -249,20 +279,20 @@ public class GuiServer extends WDScreen {
if(keyCode == Keyboard.KEY_ESCAPE) { if(keyCode == Keyboard.KEY_ESCAPE) {
quitUploadWizard(); quitUploadWizard();
return; //Don't let the screen handle this return true; //Don't let the screen handle this
} }
super.handleKeyboardInput(); return booleanSupplier.get();
} else { } else {
super.handleKeyboardInput(); boolean value = booleanSupplier.get();
if(keyState) { if(keyState) {
boolean ctrl = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL); boolean ctrl = Screen.hasControlDown();
if(keyCode == Keyboard.KEY_L && ctrl) if(keyCode == GLFW.GLFW_KEY_L && ctrl)
lines.clear(); lines.clear();
else if(keyCode == Keyboard.KEY_V && ctrl) { else if(keyCode == Keyboard.KEY_V && ctrl) {
prompt += getClipboardString(); prompt += minecraft.keyboardHandler.getClipboard();
if(prompt.length() > MAX_LINE_LEN) if(prompt.length() > MAX_LINE_LEN)
prompt = prompt.substring(0, MAX_LINE_LEN); prompt = prompt.substring(0, MAX_LINE_LEN);
@ -274,12 +304,18 @@ public class GuiServer extends WDScreen {
} }
} }
} }
return value;
} }
} }
@Override @Override
public boolean charTyped(char codePoint, int modifiers) {
return super.charTyped(codePoint, modifiers);
}
protected void keyTyped(char typedChar, int keyCode) throws IOException { protected void keyTyped(char typedChar, int keyCode) throws IOException {
super.keyTyped(typedChar, keyCode); // super.keyTyped(typedChar, keyCode);
if(uploadWizard) { if(uploadWizard) {
boolean found = false; boolean found = false;
@ -374,11 +410,11 @@ public class GuiServer extends WDScreen {
} }
@Override @Override
public void onGuiClosed() { public void onClose() {
super.onGuiClosed(); super.onClose();
if(accessSound != null) if(accessSound != null)
mc.getSoundHandler().stopSound(accessSound); minecraft.getSoundManager().stop(accessSound);
} }
private boolean queueTask(ClientTask<?> task) { private boolean queueTask(ClientTask<?> task) {
@ -432,7 +468,7 @@ public class GuiServer extends WDScreen {
@CommandHandler("exit") @CommandHandler("exit")
public void commandExit() { public void commandExit() {
mc.displayGuiScreen(null); minecraft.setScreen(null);
} }
@CommandHandler("access") @CommandHandler("access")
@ -466,7 +502,7 @@ public class GuiServer extends WDScreen {
@CommandHandler("quota") @CommandHandler("quota")
public void commandQuota() { public void commandQuota() {
if(!mc.player.getGameProfile().getId().equals(owner.uuid)) { if(!minecraft.player.getGameProfile().getId().equals(owner.uuid)) {
writeLine(tr("errowner")); writeLine(tr("errowner"));
return; return;
} }
@ -512,7 +548,7 @@ public class GuiServer extends WDScreen {
int status = t.getStatus(); int status = t.getStatus();
if(status == 0) { if(status == 0) {
writeLine(tr("urlcopied")); writeLine(tr("urlcopied"));
setClipboardString(t.getURL()); Minecraft.getInstance().keyboardHandler.setClipboard(t.getURL());
} else if(status == Constants.GETF_STATUS_NOT_FOUND) } else if(status == Constants.GETF_STATUS_NOT_FOUND)
writeLine(tr("notfound")); writeLine(tr("notfound"));
else else
@ -588,7 +624,7 @@ public class GuiServer extends WDScreen {
@CommandHandler("upload") @CommandHandler("upload")
public void commandUpload(String[] args) { public void commandUpload(String[] args) {
if(!mc.player.getGameProfile().getId().equals(owner.uuid)) { if(!minecraft.player.getGameProfile().getId().equals(owner.uuid)) {
writeLine(tr("errowner")); writeLine(tr("errowner"));
return; return;
} }
@ -620,7 +656,7 @@ public class GuiServer extends WDScreen {
@CommandHandler("rm") @CommandHandler("rm")
public void commandDelete(String[] args) { public void commandDelete(String[] args) {
if(!mc.player.getGameProfile().getId().equals(owner.uuid)) { if(!minecraft.player.getGameProfile().getId().equals(owner.uuid)) {
writeLine(tr("errowner")); writeLine(tr("errowner"));
return; return;
} }
@ -653,7 +689,7 @@ public class GuiServer extends WDScreen {
@CommandHandler("reconnect") @CommandHandler("reconnect")
public void commandReconnect() { public void commandReconnect() {
Client.getInstance().stop(); Client.getInstance().stop();
WebDisplays.NET_HANDLER.sendToServer(Client.getInstance().beginConnection()); Messages.INSTANCE.sendToServer(Client.getInstance().beginConnection());
} }
private void startFileUpload(File f, boolean quit) { private void startFileUpload(File f, boolean quit) {

View File

@ -7,10 +7,8 @@ package net.montoyo.wd.client.gui.loading;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.IResource;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.Resource; import net.minecraft.server.packs.resources.Resource;
import net.minecraft.util.ResourceLocation;
import net.montoyo.wd.client.gui.controls.*; import net.montoyo.wd.client.gui.controls.*;
import net.montoyo.wd.utilities.Log; import net.montoyo.wd.utilities.Log;

View File

@ -5,9 +5,7 @@
package net.montoyo.wd.client.renderers; package net.montoyo.wd.client.renderers;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.block.model.ItemOverrides; import net.minecraft.client.renderer.block.model.ItemOverrides;
import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlas;
@ -87,7 +85,7 @@ public class ScreenBaker implements IModelBaker {
putVertex(data, 1, rotateVec(new Vector3f(1.0f, 0.0f, 1.0f), side), tex, rotateTex(side, 16.0f, 16.0f), side.backward); putVertex(data, 1, rotateVec(new Vector3f(1.0f, 0.0f, 1.0f), side), tex, rotateTex(side, 16.0f, 16.0f), side.backward);
putVertex(data, 0, rotateVec(new Vector3f(1.0f, 0.0f, 0.0f), side), tex, rotateTex(side, 16.0f, 0.0f ), side.backward); putVertex(data, 0, rotateVec(new Vector3f(1.0f, 0.0f, 0.0f), side), tex, rotateTex(side, 16.0f, 0.0f ), side.backward);
return new BakedQuad(data, 0xFFFFFFFF, blockFacings[side.ordinal()], tex, true, DefaultVertexFormat.ITEM); return new BakedQuad(data, 0xFFFFFFFF, blockFacings[side.ordinal()], tex, true);
} }
@Nonnull @Nonnull

View File

@ -4,13 +4,9 @@
package net.montoyo.wd.core; package net.montoyo.wd.core;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.montoyo.wd.WebDisplays; import net.montoyo.wd.init.BlockInit;
import javax.annotation.Nonnull;
public class WDCreativeTab extends CreativeModeTab { public class WDCreativeTab extends CreativeModeTab {
@ -20,6 +16,6 @@ public class WDCreativeTab extends CreativeModeTab {
@Override @Override
public ItemStack makeIcon() { public ItemStack makeIcon() {
return WebDisplays.INSTANCE.blockScreen.getItem(); return new ItemStack(BlockInit.blockScreen.get());
} }
} }

View File

@ -4,19 +4,12 @@
package net.montoyo.wd.data; package net.montoyo.wd.data;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.montoyo.wd.client.gui.GuiKeyboard; import net.montoyo.wd.client.gui.GuiKeyboard;
import net.montoyo.wd.entity.TileEntityScreen; import net.montoyo.wd.entity.TileEntityScreen;
import net.montoyo.wd.utilities.BlockSide; import net.montoyo.wd.utilities.BlockSide;

View File

@ -4,16 +4,11 @@
package net.montoyo.wd.data; package net.montoyo.wd.data;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.montoyo.wd.client.gui.GuiServer; import net.montoyo.wd.client.gui.GuiServer;
import net.montoyo.wd.utilities.NameUUIDPair; import net.montoyo.wd.utilities.NameUUIDPair;
import net.montoyo.wd.utilities.Vector3i; import net.montoyo.wd.utilities.Vector3i;

View File

@ -20,7 +20,7 @@ import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.net.Message; import net.montoyo.wd.net.Message;
@Message(messageId = 7, side = Side.SERVER) @Message(messageId = 7, side = Side.SERVER)
public class SMessagePadCtrl implements IMessage, Runnable { public class SMessagePadCtrl implements Runnable {
private int id; private int id;
private String url; private String url;
@ -81,7 +81,7 @@ public class SMessagePadCtrl implements IMessage, Runnable {
} }
@Override @Override
public void fromBytes(ByteBuf buf) { public void encode(ByteBuf buf) {
id = buf.readInt(); id = buf.readInt();
url = ByteBufUtils.readUTF8String(buf); url = ByteBufUtils.readUTF8String(buf);
} }

View File

@ -4,30 +4,17 @@
package net.montoyo.wd.net.server; package net.montoyo.wd.net.server;
import io.netty.buffer.ByteBuf;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.common.ForgeMod; import net.minecraftforge.common.ForgeMod;
import net.minecraftforge.fml.common.network.ByteBufUtils;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.network.NetworkEvent; import net.minecraftforge.network.NetworkEvent;
import net.montoyo.wd.core.ScreenRights; import net.montoyo.wd.core.ScreenRights;
import net.montoyo.wd.entity.TileEntityRedCtrl; import net.montoyo.wd.entity.TileEntityRedCtrl;
import net.montoyo.wd.entity.TileEntityScreen; import net.montoyo.wd.entity.TileEntityScreen;
import net.montoyo.wd.net.Message;
import net.montoyo.wd.utilities.Util; import net.montoyo.wd.utilities.Util;
import net.montoyo.wd.utilities.Vector3i; import net.montoyo.wd.utilities.Vector3i;

View File

@ -4,43 +4,28 @@
package net.montoyo.wd.net.server; package net.montoyo.wd.net.server;
import net.minecraft.block.state.IBlockState;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.ForgeMod; import net.minecraftforge.common.ForgeMod;
import net.minecraftforge.fml.common.network.ByteBufUtils;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.network.NetworkEvent; import net.minecraftforge.network.NetworkEvent;
import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.block.BlockPeripheral; import net.montoyo.wd.block.BlockPeripheral;
import net.montoyo.wd.core.DefaultPeripheral; import net.montoyo.wd.core.DefaultPeripheral;
import net.montoyo.wd.core.JSServerRequest; import net.montoyo.wd.core.JSServerRequest;
import net.montoyo.wd.core.MissingPermissionException; import net.montoyo.wd.core.MissingPermissionException;
import net.montoyo.wd.core.ScreenRights; import net.montoyo.wd.core.ScreenRights;
import net.montoyo.wd.entity.TileEntityScreen; import net.montoyo.wd.entity.TileEntityScreen;
import net.montoyo.wd.net.Message; import net.montoyo.wd.init.BlockInit;
import net.montoyo.wd.utilities.*; import net.montoyo.wd.utilities.*;
import java.util.function.Supplier; import java.util.function.Supplier;
@Message(messageId = 2, side = Side.SERVER) public class SMessageScreenCtrl implements Runnable {
public class SMessageScreenCtrl implements IMessage, Runnable {
public static final int CTRL_SET_URL = 0; public static final int CTRL_SET_URL = 0;
public static final int CTRL_SHUT_DOWN = 1; public static final int CTRL_SHUT_DOWN = 1;
@ -306,7 +291,7 @@ public class SMessageScreenCtrl implements IMessage, Runnable {
return; //Out of range (player reach distance) return; //Out of range (player reach distance)
BlockState bs = world.getBlockState(blockPos); BlockState bs = world.getBlockState(blockPos);
if(bs.getBlock() != WebDisplays.INSTANCE.blockPeripheral || bs.getValue(BlockPeripheral.type) != DefaultPeripheral.REMOTE_CONTROLLER) if(bs.getBlock() != BlockInit.blockPeripheral.get() || bs.getValue(BlockPeripheral.type) != DefaultPeripheral.REMOTE_CONTROLLER)
return; //I call it hax... return; //I call it hax...
} else if(player.shouldRenderAtSqrDistance(player.distanceToSqr(bp.getX(), bp.getY(), bp.getZ()))) } else if(player.shouldRenderAtSqrDistance(player.distanceToSqr(bp.getX(), bp.getY(), bp.getZ())))
return; //Out of range (range problem) return; //Out of range (range problem)