mod compiles, things *really* don't work

This commit is contained in:
GiantLuigi4 2023-09-22 15:26:43 -04:00
parent f7f92cd19c
commit 0867dd68d7
38 changed files with 1243 additions and 1168 deletions

View File

@ -3,6 +3,7 @@ plugins {
id 'maven-publish'
id 'net.neoforged.gradle' version '[6.0.18,6.2)'
id 'org.spongepowered.mixin' version '0.7.+'
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
}
version = mod_version
@ -12,7 +13,7 @@ java.toolchain.languageVersion = JavaLanguageVersion.of(17)
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
minecraft {
mappings channel: 'official', version: '1.20.1'
mappings channel: 'parchment', version: '2023.06.26-1.20.1'
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')

Binary file not shown.

View File

@ -5,6 +5,7 @@ pluginManagement {
name = 'NeoForged'
url = 'https://maven.neoforged.net/releases'
}
maven { url = 'https://maven.parchmentmc.org' } // Add this line
}
// resolutionStrategy {
// eachPlugin {

View File

@ -16,7 +16,6 @@ import net.minecraft.world.level.Level;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.network.NetworkEvent;
import net.minecraftforge.server.ServerLifecycleHooks;
import net.montoyo.mcef.api.CefInitEvent;
import net.montoyo.wd.core.HasAdvancement;
import net.montoyo.wd.core.JSServerRequest;
import net.montoyo.wd.data.GuiData;
@ -31,13 +30,14 @@ public class SharedProxy {
}
public void init() {
MinecraftForge.EVENT_BUS.addListener(this::onCefInit);
// MinecraftForge.EVENT_BUS.addListener(this::onCefInit);
onCefInit();
}
public void postInit() {
}
public void onCefInit(CefInitEvent event) {
public void onCefInit(/*CefInitEvent event*/) {
}
@Deprecated(forRemoval = true)
@ -46,7 +46,7 @@ public class SharedProxy {
}
public BlockGetter getWorld(NetworkEvent.Context context) {
if (context.getSender() != null) return context.getSender().level;
if (context.getSender() != null) return context.getSender().level();
return null;
}

View File

@ -73,7 +73,7 @@ public class WebDisplays {
cursorSupport = (ver.getMajorVersion() >= 1 && ver.getMinorVersion() >= 2 && ver.getIncrementalVersion() >= 4);
}
public static WDCreativeTab CREATIVE_TAB;
// public static WDCreativeTab CREATIVE_TAB;
public static final ResourceLocation ADV_PAD_BREAK = new ResourceLocation("webdisplays", "webdisplays/pad_break");
public static final String BLACKLIST_URL = "mod://webdisplays/blacklisted.html";
public static final Gson GSON = new Gson();
@ -127,7 +127,7 @@ public class WebDisplays {
CommonConfig.init();
CREATIVE_TAB = new WDCreativeTab();
// CREATIVE_TAB = new WDCreativeTab();
//Criterions
criterionPadBreak = new Criterion("pad_break");
@ -259,7 +259,7 @@ public class WebDisplays {
@SubscribeEvent
public void onToss(ItemTossEvent ev) {
if(!ev.getEntity().getLevel().isClientSide) {
if(!ev.getEntity().level().isClientSide) {
ItemStack is = ev.getEntity().getItem();
if(is.getItem() == ItemInit.MINEPAD.get()) {
@ -284,8 +284,8 @@ public class WebDisplays {
if((ev.getEntity() instanceof ServerPlayer && !hasPlayerAdvancement((ServerPlayer) ev.getEntity(), ADV_PAD_BREAK)) || PROXY.hasClientPlayerAdvancement(ADV_PAD_BREAK) != HasAdvancement.YES) {
ev.getCrafting().setDamageValue(CraftComponent.BADEXTCARD.ordinal());
if(!ev.getEntity().getLevel().isClientSide)
ev.getEntity().getLevel().playSound(null, ev.getEntity().getX(), ev.getEntity().getY(), ev.getEntity().getZ(), SoundEvents.ITEM_BREAK, SoundSource.MASTER, 1.0f, 1.0f);
if(!ev.getEntity().level().isClientSide)
ev.getEntity().level().playSound(null, ev.getEntity().getX(), ev.getEntity().getY(), ev.getEntity().getZ(), SoundEvents.ITEM_BREAK, SoundSource.MASTER, 1.0f, 1.0f);
}
}
}
@ -297,7 +297,7 @@ public class WebDisplays {
@SubscribeEvent
public void onLogIn(PlayerEvent.PlayerLoggedInEvent ev) {
if(!ev.getEntity().getLevel().isClientSide && ev.getEntity() instanceof ServerPlayer) {
if(!ev.getEntity().level().isClientSide && ev.getEntity() instanceof ServerPlayer) {
IWDDCapability cap = ev.getEntity().getCapability(WDDCapability.Provider.cap, null).orElseThrow(RuntimeException::new);
if(cap.isFirstRun()) {
@ -320,7 +320,7 @@ public class WebDisplays {
@SubscribeEvent
public void onLogOut(PlayerEvent.PlayerLoggedOutEvent ev) {
if(!ev.getEntity().getLevel().isClientSide)
if(!ev.getEntity().level().isClientSide)
Server.getInstance().getClientManager().revokeClientKey(ev.getEntity().getGameProfile().getId());
}
@ -361,7 +361,7 @@ public class WebDisplays {
if(sb.toString().equals("ironic he could save others from death but not himself")) {
Player ply = ev.getPlayer();
ply.getLevel().playSound(null, ply.getX(), ply.getY(), ply.getZ(), soundIronic, SoundSource.PLAYERS, 1.0f, 1.0f);
ply.level().playSound(null, ply.getX(), ply.getY(), ply.getZ(), soundIronic, SoundSource.PLAYERS, 1.0f, 1.0f);
}
}
@ -388,7 +388,7 @@ public class WebDisplays {
private static void registerSound(String resName) {
ResourceLocation resLoc = new ResourceLocation("webdisplays", resName);
SoundEvent ret = new SoundEvent(resLoc);
SoundEvent ret = SoundEvent.createVariableRangeEvent(resLoc);
SOUNDS.register(resName, () -> ret);
}

View File

@ -228,7 +228,7 @@ public class BlockScreen extends BaseEntityBlock {
if (tes != null && tes.hasUpgrade(side, DefaultUpgrade.REDINPUT)) {
Direction facing = Direction.from2DDataValue(side.reverse().ordinal()); //Opposite face
vec.sub(pos.getX(), pos.getY(), pos.getZ()).neg();
tes.updateJSRedstone(side, new Vector2i(vec.dot(side.right), vec.dot(side.up)), world.getSignal(pos, facing));
// tes.updateJSRedstone(side, new Vector2i(vec.dot(side.right), vec.dot(side.up)), world.getSignal(pos, facing));
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,149 +1,149 @@
/*
* Copyright (C) 2018 BARBOTIN Nicolas
*/
package net.montoyo.wd.client;
import net.montoyo.mcef.api.IScheme;
import net.montoyo.mcef.api.ISchemeResponseData;
import net.montoyo.mcef.api.ISchemeResponseHeaders;
import net.montoyo.mcef.api.SchemePreResponse;
import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.miniserv.Constants;
import net.montoyo.wd.miniserv.client.Client;
import net.montoyo.wd.miniserv.client.ClientTaskGetFile;
import net.montoyo.wd.utilities.Log;
import net.montoyo.wd.utilities.Util;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.UUID;
public class WDScheme implements IScheme {
private static final String ERROR_PAGE = "<!DOCTYPE html><html><head></head><body><h1>%d %s</h1><hr /><i>Miniserv powered by WebDisplays</i></body></html>";
private ClientTaskGetFile task;
private boolean isErrorPage;
@Override
public SchemePreResponse processRequest(String url) {
url = url.substring("wd://".length());
int pos = url.indexOf('/');
if(pos < 0)
return SchemePreResponse.NOT_HANDLED;
String uuidStr = url.substring(0, pos);
String fileStr = url.substring(pos + 1);
try {
fileStr = URLDecoder.decode(fileStr, "UTF-8");
} catch(UnsupportedEncodingException ex) {
Log.warningEx("UTF-8 isn't supported... yeah... and I'm a billionaire...", ex);
}
if(uuidStr.isEmpty() || Util.isFileNameInvalid(fileStr))
return SchemePreResponse.NOT_HANDLED;
UUID uuid;
try {
uuid = UUID.fromString(uuidStr);
} catch(IllegalArgumentException ex) {
return SchemePreResponse.NOT_HANDLED; //Invalid UUID
}
task = new ClientTaskGetFile(uuid, fileStr);
return Client.getInstance().addTask(task) ? SchemePreResponse.HANDLED_CONTINUE : SchemePreResponse.NOT_HANDLED;
}
@Override
public void getResponseHeaders(ISchemeResponseHeaders resp) {
Log.info("Waiting for response...");
int status = task.waitForResponse();
Log.info("Got response %d", status);
if(status == 0) {
//OK
int extPos = task.getFileName().lastIndexOf('.');
if(extPos >= 0) {
String mime = ((ClientProxy) WebDisplays.PROXY).getMCEF().mimeTypeFromExtension(task.getFileName().substring(extPos + 1));
if(mime != null)
resp.setMimeType(mime);
}
resp.setStatus(200);
resp.setStatusText("OK");
resp.setResponseLength(-1);
return;
}
int errCode;
String errStr;
if(status == Constants.GETF_STATUS_NOT_FOUND) {
errCode = 404;
errStr = "Not Found";
} else {
errCode = 500;
errStr = "Internal Server Error";
}
resp.setStatus(errCode);
resp.setStatusText(errStr);
try {
dataToWrite = String.format(ERROR_PAGE, errCode, errStr).getBytes("UTF-8");
dataOffset = 0;
amountToWrite = dataToWrite.length;
isErrorPage = true;
resp.setResponseLength(amountToWrite);
} catch(UnsupportedEncodingException ex) {
resp.setResponseLength(0);
}
}
private byte[] dataToWrite;
private int dataOffset;
private int amountToWrite;
@Override
public boolean readResponse(ISchemeResponseData data) {
if(dataToWrite == null) {
if(isErrorPage) {
data.setAmountRead(0);
return false;
}
dataToWrite = task.waitForData();
dataOffset = 3; //packet ID + size
amountToWrite = task.getDataLength();
if(amountToWrite <= 0) {
dataToWrite = null;
data.setAmountRead(0);
return false;
}
}
int toWrite = data.getBytesToRead();
if(toWrite > amountToWrite)
toWrite = amountToWrite;
System.arraycopy(dataToWrite, dataOffset, data.getDataArray(), 0, toWrite);
data.setAmountRead(toWrite);
dataOffset += toWrite;
amountToWrite -= toWrite;
if(amountToWrite <= 0) {
if(!isErrorPage)
task.nextData();
dataToWrite = null;
}
return true;
}
}
///*
// * Copyright (C) 2018 BARBOTIN Nicolas
// */
//
//package net.montoyo.wd.client;
//
//import net.montoyo.mcef.api.IScheme;
//import net.montoyo.mcef.api.ISchemeResponseData;
//import net.montoyo.mcef.api.ISchemeResponseHeaders;
//import net.montoyo.mcef.api.SchemePreResponse;
//import net.montoyo.wd.WebDisplays;
//import net.montoyo.wd.miniserv.Constants;
//import net.montoyo.wd.miniserv.client.Client;
//import net.montoyo.wd.miniserv.client.ClientTaskGetFile;
//import net.montoyo.wd.utilities.Log;
//import net.montoyo.wd.utilities.Util;
//
//import java.io.UnsupportedEncodingException;
//import java.net.URLDecoder;
//import java.util.UUID;
//
//public class WDScheme implements IScheme {
//
// private static final String ERROR_PAGE = "<!DOCTYPE html><html><head></head><body><h1>%d %s</h1><hr /><i>Miniserv powered by WebDisplays</i></body></html>";
// private ClientTaskGetFile task;
// private boolean isErrorPage;
//
// @Override
// public SchemePreResponse processRequest(String url) {
// url = url.substring("wd://".length());
//
// int pos = url.indexOf('/');
// if(pos < 0)
// return SchemePreResponse.NOT_HANDLED;
//
// String uuidStr = url.substring(0, pos);
// String fileStr = url.substring(pos + 1);
//
// try {
// fileStr = URLDecoder.decode(fileStr, "UTF-8");
// } catch(UnsupportedEncodingException ex) {
// Log.warningEx("UTF-8 isn't supported... yeah... and I'm a billionaire...", ex);
// }
//
// if(uuidStr.isEmpty() || Util.isFileNameInvalid(fileStr))
// return SchemePreResponse.NOT_HANDLED;
//
// UUID uuid;
// try {
// uuid = UUID.fromString(uuidStr);
// } catch(IllegalArgumentException ex) {
// return SchemePreResponse.NOT_HANDLED; //Invalid UUID
// }
//
// task = new ClientTaskGetFile(uuid, fileStr);
// return Client.getInstance().addTask(task) ? SchemePreResponse.HANDLED_CONTINUE : SchemePreResponse.NOT_HANDLED;
// }
//
// @Override
// public void getResponseHeaders(ISchemeResponseHeaders resp) {
// Log.info("Waiting for response...");
// int status = task.waitForResponse();
// Log.info("Got response %d", status);
//
// if(status == 0) {
// //OK
// int extPos = task.getFileName().lastIndexOf('.');
// if(extPos >= 0) {
// String mime = ((ClientProxy) WebDisplays.PROXY).getMCEF().mimeTypeFromExtension(task.getFileName().substring(extPos + 1));
//
// if(mime != null)
// resp.setMimeType(mime);
// }
//
// resp.setStatus(200);
// resp.setStatusText("OK");
// resp.setResponseLength(-1);
// return;
// }
//
// int errCode;
// String errStr;
//
// if(status == Constants.GETF_STATUS_NOT_FOUND) {
// errCode = 404;
// errStr = "Not Found";
// } else {
// errCode = 500;
// errStr = "Internal Server Error";
// }
//
// resp.setStatus(errCode);
// resp.setStatusText(errStr);
//
// try {
// dataToWrite = String.format(ERROR_PAGE, errCode, errStr).getBytes("UTF-8");
// dataOffset = 0;
// amountToWrite = dataToWrite.length;
// isErrorPage = true;
// resp.setResponseLength(amountToWrite);
// } catch(UnsupportedEncodingException ex) {
// resp.setResponseLength(0);
// }
// }
//
// private byte[] dataToWrite;
// private int dataOffset;
// private int amountToWrite;
//
// @Override
// public boolean readResponse(ISchemeResponseData data) {
// if(dataToWrite == null) {
// if(isErrorPage) {
// data.setAmountRead(0);
// return false;
// }
//
// dataToWrite = task.waitForData();
// dataOffset = 3; //packet ID + size
// amountToWrite = task.getDataLength();
//
// if(amountToWrite <= 0) {
// dataToWrite = null;
// data.setAmountRead(0);
// return false;
// }
// }
//
// int toWrite = data.getBytesToRead();
// if(toWrite > amountToWrite)
// toWrite = amountToWrite;
//
// System.arraycopy(dataToWrite, dataOffset, data.getDataArray(), 0, toWrite);
// data.setAmountRead(toWrite);
//
// dataOffset += toWrite;
// amountToWrite -= toWrite;
//
// if(amountToWrite <= 0) {
// if(!isErrorPage)
// task.nextData();
//
// dataToWrite = null;
// }
//
// return true;
// }
//
//}

View File

@ -136,16 +136,16 @@ public class GuiKeyboard extends WDScreen {
defaultBackground = showWarning;
syncTicks = 5;
if (vivecraftPresent)
if (VRPlayer.get() != null)
KeyboardHandler.setOverlayShowing(true);
// if (vivecraftPresent)
// if (VRPlayer.get() != null)
// KeyboardHandler.setOverlayShowing(true);
}
@Override
public void onClose() {
if (vivecraftPresent)
if (VRPlayer.get() != null)
KeyboardHandler.setOverlayShowing(false);
// if (vivecraftPresent)
// if (VRPlayer.get() != null)
// KeyboardHandler.setOverlayShowing(false);
super.onClose();
}

View File

@ -37,8 +37,8 @@ public class GuiMinePad extends WDScreen {
this();
this.pad = pad;
if (WebDisplays.cursorSupport)
pad.view.allowCursorChanges(true);
// if (WebDisplays.cursorSupport)
// pad.view.allowCursorChanges(true);
}
@Override
@ -61,31 +61,31 @@ public class GuiMinePad extends WDScreen {
bb.vertex(x, y + h, 0.0).color(255, 255, 255, 255).endVertex();
}
@Override
public void render(PoseStack poseStack, int mouseX, int mouseY, float ptt) {
renderBackground(poseStack);
RenderSystem.disableTexture();
RenderSystem.disableCull();
RenderSystem.setShaderColor(0.73f, 0.73f, 0.73f, 1.0f);
Tesselator t = Tesselator.getInstance();
BufferBuilder bb = t.getBuilder();
bb.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
addRect(bb, vx, vy - 16, vw, 16);
addRect(bb, vx, vy + vh, vw, 16);
addRect(bb, vx - 16, vy, 16, vh);
addRect(bb, vx + vw, vy, 16, vh);
t.end();
RenderSystem.enableTexture();
if (pad.view != null) {
pad.view.draw(poseStack, vx, vy + vh, vx + vw, vy);
}
RenderSystem.enableCull();
}
// @Override
// public void render(PoseStack poseStack, int mouseX, int mouseY, float ptt) {
// renderBackground(poseStack);
//
// RenderSystem.disableTexture();
// RenderSystem.disableCull();
// RenderSystem.setShaderColor(0.73f, 0.73f, 0.73f, 1.0f);
//
// Tesselator t = Tesselator.getInstance();
// BufferBuilder bb = t.getBuilder();
// bb.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
// addRect(bb, vx, vy - 16, vw, 16);
// addRect(bb, vx, vy + vh, vw, 16);
// addRect(bb, vx - 16, vy, 16, vh);
// addRect(bb, vx + vw, vy, 16, vh);
// t.end();
//
// RenderSystem.enableTexture();
//
// if (pad.view != null) {
// pad.view.draw(poseStack, vx, vy + vh, vx + vw, vy);
// }
//
// RenderSystem.enableCull();
// }
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
@ -99,12 +99,13 @@ public class GuiMinePad extends WDScreen {
@Override
public boolean charTyped(char codePoint, int modifiers) {
if (pad.view != null) {
pad.view.injectKeyTyped((int) codePoint, modifiers);
return true;
} else {
return super.charTyped(codePoint, modifiers);
}
// if (pad.view != null) {
// pad.view.injectKeyTyped((int) codePoint, modifiers);
// return true;
// } else {
// return super.charTyped(codePoint, modifiers);
// }
return false;
}
/* copied from MCEF */
@ -128,16 +129,16 @@ public class GuiMinePad extends WDScreen {
key = '\n';
}
if (pad.view != null) {
if (pressed)
pad.view.injectKeyPressedByKeyCode(keyCode, key, modifiers);
else
pad.view.injectKeyReleasedByKeyCode(keyCode, key, modifiers);
if (pressed && key == '\n')
if (modifiers != 0) pad.view.injectKeyTyped('\r', modifiers);
return true;
}
// if (pad.view != null) {
// if (pressed)
// pad.view.injectKeyPressedByKeyCode(keyCode, key, modifiers);
// else
// pad.view.injectKeyReleasedByKeyCode(keyCode, key, modifiers);
//
// if (pressed && key == '\n')
// if (modifiers != 0) pad.view.injectKeyTyped('\r', modifiers);
// return true;
// }
return false;
}
@ -176,20 +177,20 @@ public class GuiMinePad extends WDScreen {
double mx = (sx - vx) / vw;
double my = (sy - vy) / vh;
if (pad.view != null && mx >= 0 && mx <= 1) {
int wheel = (int) scrollAmount;
//Scale again according to the webview
sx = (int) (mx * WebDisplays.INSTANCE.padResX);
sy = (int) (my * WebDisplays.INSTANCE.padResY);
if (wheel != 0)
pad.view.injectMouseWheel(sx, sy, (hasControlDown() && ! hasAltDown() && !hasShiftDown()) ? GLFW.GLFW_MOD_CONTROL : 0, wheel, 0);
if (btn == -1)
pad.view.injectMouseMove(sx, sy, 0, sy < 0);
else
pad.view.injectMouseButton(sx, sy, 0, btn + 1, pressed, 1);
}
// if (pad.view != null && mx >= 0 && mx <= 1) {
// int wheel = (int) scrollAmount;
//
// //Scale again according to the webview
// sx = (int) (mx * WebDisplays.INSTANCE.padResX);
// sy = (int) (my * WebDisplays.INSTANCE.padResY);
//
// if (wheel != 0)
// pad.view.injectMouseWheel(sx, sy, (hasControlDown() && ! hasAltDown() && !hasShiftDown()) ? GLFW.GLFW_MOD_CONTROL : 0, wheel, 0);
// if (btn == -1)
// pad.view.injectMouseMove(sx, sy, 0, sy < 0);
// else
// pad.view.injectMouseButton(sx, sy, 0, btn + 1, pressed, 1);
// }
}
public static Optional<Character> getChar(int keyCode, int scanCode) {
@ -222,7 +223,7 @@ public class GuiMinePad extends WDScreen {
public void removed() {
super.removed();
if (pad.view instanceof CefBrowserOsr osr) {
osr.allowCursorChanges(true);
// osr.allowCursorChanges(true);
osr.onCursorChange(null, 0);
}
}
@ -230,10 +231,10 @@ public class GuiMinePad extends WDScreen {
@Override
public void onClose() {
super.onClose();
if (WebDisplays.cursorSupport) {
pad.view.allowCursorChanges(false);
if (pad.view instanceof CefBrowserOsr osr)
osr.onCursorChange(null, 0);
}
// if (WebDisplays.cursorSupport) {
// pad.view.allowCursorChanges(false);
// if (pad.view instanceof CefBrowserOsr osr)
// osr.onCursorChange(null, 0);
// }
}
}

View File

@ -8,6 +8,7 @@ import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
@ -23,6 +24,8 @@ import net.montoyo.wd.miniserv.client.*;
import net.montoyo.wd.net.WDNetworkRegistry;
import net.montoyo.wd.utilities.*;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GL11;
import javax.annotation.Nullable;
import javax.swing.filechooser.FileSystemView;
@ -93,48 +96,50 @@ public class GuiServer extends WDScreen {
}
@Override
public void render(PoseStack poseStack, int mouseX, int mouseY, float ptt) {
public void render(GuiGraphics poseStack, int mouseX, int mouseY, float ptt) {
super.render(poseStack, mouseX, mouseY, ptt);
int x = (width - 256) / 2;
int y = (height - 176) / 2;
RenderSystem.enableTexture();
// RenderSystem.enableTexture();
GL11.glEnable(GL11.GL_TEXTURE_2D);
RenderSystem.setShaderTexture(0, BG_IMAGE);
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
blit(poseStack, x, y, 0, 0, 256, 176);
// blit(poseStack, x, y, 0, 0, 256, 176);
x += 18;
y += 18;
for(int i = 0; i < lines.size(); i++) {
if(selectedLine == i) {
drawWhiteQuad(x - 1, y - 2, font.width(lines.get(i)) + 1, 12);
font.drawShadow(poseStack, lines.get(i), x, y, 0xFF129700, false);
} else
font.drawShadow(poseStack, lines.get(i), x, y, 0xFFFFFFFF, false);
// if(selectedLine == i) {
// drawWhiteQuad(x - 1, y - 2, font.width(lines.get(i)) + 1, 12);
// font.drawShadow(poseStack, lines.get(i), x, y, 0xFF129700, false);
// } else
// font.drawShadow(poseStack, lines.get(i), x, y, 0xFFFFFFFF, false);
y += 12;
}
if(!promptLocked) {
if (queue.isEmpty()) {
x = font.drawShadow(poseStack, userPrompt, x, y, 0xFFFFFFFF, false);
x = font.drawShadow(poseStack, prompt, x, y, 0xFFFFFFFF, false);
} else {
x = font.drawShadow(poseStack, tr("press_for_more"), x, y, 0xFFFFFFFF, false);
}
// if (queue.isEmpty()) {
// x = font.drawShadow(poseStack, userPrompt, x, y, 0xFFFFFFFF, false);
// x = font.drawShadow(poseStack, prompt, x, y, 0xFFFFFFFF, false);
// } else {
// x = font.drawShadow(poseStack, tr("press_for_more"), x, y, 0xFFFFFFFF, false);
// }
}
if(!uploadWizard && blinkTime < 5)
drawWhiteQuad(x + 1, y, 6, 8);
RenderSystem.enableTexture();
// RenderSystem.enableTexture();
GL11.glEnable(GL11.GL_TEXTURE_2D);
RenderSystem.enableBlend();
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
RenderSystem.setShaderTexture(0, FG_IMAGE);
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
blit(poseStack,(width - 256) / 2, (height - 176) / 2, 0, 0, 256, 176);
// blit(poseStack,(width - 256) / 2, (height - 176) / 2, 0, 0, 256, 176);
}
private void drawWhiteQuad(int x, int y, int w, int h) {
@ -144,7 +149,8 @@ public class GuiServer extends WDScreen {
float yd2 = (float) (y + h);
float zd = (float) getBlitOffset();
RenderSystem.disableTexture();
// RenderSystem.disableTexture();
GL11.glDisable(GL11.GL_TEXTURE_2D);
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
Tesselator t = Tesselator.getInstance();
BufferBuilder bb = t.getBuilder();
@ -154,9 +160,14 @@ public class GuiServer extends WDScreen {
bb.vertex(xd2, yd, zd).endVertex();
bb.vertex(xd, yd, zd).endVertex();
t.end();
RenderSystem.enableTexture();
GL11.glEnable(GL11.GL_TEXTURE_2D);
// RenderSystem.enableTexture();
}
private float getBlitOffset() {
return 0;
}
@Override
public void tick() {
super.tick();

View File

@ -126,7 +126,7 @@ public class GuiSetURL2 extends WDScreen {
}
url = Util.addProtocol(url);
url = ((ClientProxy) WebDisplays.PROXY).getMCEF().punycode(url);
// url = ((ClientProxy) WebDisplays.PROXY).getMCEF().punycode(url);
if (isPad) {
UUID uuid = getUUID();

View File

@ -7,6 +7,7 @@ package net.montoyo.wd.client.gui;
import com.mojang.blaze3d.platform.Lighting;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.resources.language.I18n;
@ -77,15 +78,16 @@ public class RenderRecipe extends Screen {
Log.info("Loaded %d recipes", recipes.size());
nextRecipe();
}
@Override
public void render(PoseStack poseStack, int mouseX, int mouseY, float partialTick) {
renderBackground(poseStack);
public void render(GuiGraphics context, int mouseX, int mouseY, float partialTick) {
// renderBackground(poseStack);
renderBackground(context);
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
RenderSystem.setShaderTexture(0, CRAFTING_TABLE_GUI_TEXTURES);
blit(poseStack, x, y, 0, 0, SIZE_X, SIZE_Y);
font.draw(poseStack, I18n.get("container.crafting"), x + 28, y + 6, 0x404040);
// context.blit(x, y, 0, 0, SIZE_X, SIZE_Y);
// font.draw(poseStack, I18n.get("container.crafting"), x + 28, y + 6, 0x404040);
Lighting.setupForFlatItems();
// RenderSystem.disableLighting(); //TODO: Need this?
@ -98,15 +100,15 @@ public class RenderRecipe extends Screen {
int x = this.x + 30 + sx * 18;
int y = this.y + 17 + sy * 18;
renderItem.renderAndDecorateItem(minecraft.player, is, x, y, 0);
renderItem.renderGuiItemDecorations(font, is, x, y, null);
// renderItem.renderAndDecorateItem(minecraft.player, is, x, y, 0);
// renderItem.renderGuiItemDecorations(font, is, x, y, null);
}
}
}
if(recipeResult != null) {
renderItem.renderAndDecorateItem(minecraft.player, recipeResult, x + 124, y + 35, 0);
renderItem.renderGuiItemDecorations(font, recipeResult, x + 124, y + 35, null);
// renderItem.renderAndDecorateItem(minecraft.player, recipeResult, x + 124, y + 35, 0);
// renderItem.renderGuiItemDecorations(font, recipeResult, x + 124, y + 35, null);
}
// GlStateManager.enableLighting();
@ -127,7 +129,7 @@ public class RenderRecipe extends Screen {
}
}
recipeResult = recipe.getResultItem();
// recipeResult = recipe.getResultItem();
}
private void nextRecipe() {

View File

@ -9,6 +9,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
@ -111,15 +112,15 @@ public abstract class WDScreen extends Screen {
}
@Override
public void render(PoseStack poseStack, int mouseX, int mouseY, float ptt) {
public void render(GuiGraphics poseStack, int mouseX, int mouseY, float ptt) {
if(defaultBackground)
renderBackground(poseStack);
for(Control ctrl: controls)
ctrl.draw(poseStack, mouseX, mouseY, ptt);
for(Control ctrl: postDrawList)
ctrl.postDraw(poseStack, mouseX, mouseY, ptt);
// for(Control ctrl: controls)
// ctrl.draw(poseStack, mouseX, mouseY, ptt);
//
// for(Control ctrl: postDrawList)
// ctrl.postDraw(poseStack, mouseX, mouseY, ptt);
}
@Override
@ -167,7 +168,7 @@ public abstract class WDScreen extends Screen {
@Override
protected void init() {
CURRENT_SCREEN = this;
minecraft.keyboardHandler.setSendRepeatsToGui(true);
// minecraft.keyboardHandler.setSendRepeatsToGui(true);
}
@Override
@ -180,7 +181,7 @@ public abstract class WDScreen extends Screen {
for(Control ctrl : controls)
ctrl.destroy();
Minecraft.getInstance().keyboardHandler.setSendRepeatsToGui(false);
// Minecraft.getInstance().keyboardHandler.setSendRepeatsToGui(false);
CURRENT_SCREEN = null;
}
@ -363,11 +364,11 @@ public abstract class WDScreen extends Screen {
}
public void drawItemStackTooltip(PoseStack poseStack, ItemStack is, int x, int y) {
renderTooltip(poseStack, is, x, y); //Since it's protected...
// renderTooltip(poseStack, is, x, y); //Since it's protected...
}
public void drawTooltip(PoseStack poseStack, List<String> lines, int x, int y) {
renderTooltip(poseStack, lines.stream().map(a -> FormattedCharSequence.forward(a, Style.EMPTY)).collect(Collectors.toList()), x, y, font); //This is also protected...
// renderTooltip(poseStack, lines.stream().map(a -> FormattedCharSequence.forward(a, Style.EMPTY)).collect(Collectors.toList()), x, y, font); //This is also protected...
}
public void requirePostDraw(Control ctrl) {

View File

@ -5,10 +5,15 @@
package net.montoyo.wd.client.gui.controls;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.ComponentContents;
import net.minecraft.network.chat.MutableComponent;
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
import org.lwjgl.glfw.GLFW;
import java.util.function.Supplier;
public class Button extends Control {
protected final net.minecraft.client.gui.components.Button btn;
@ -31,17 +36,23 @@ public class Button extends Control {
}
}
public Button() {
btn = new net.minecraft.client.gui.components.Button(0,0, 0, 0, Component.nullToEmpty(null), a -> {});
btn = net.minecraft.client.gui.components.Button.builder(Component.nullToEmpty(""), a -> {})
.bounds(0, 0, 0, 0)
.build();
}
public Button(String text, int x, int y, int width) {
btn = new net.minecraft.client.gui.components.Button(x, y, width, 20, Component.nullToEmpty(text), a -> {});
btn = net.minecraft.client.gui.components.Button.builder(Component.nullToEmpty(text), a -> {})
.bounds(x, y, width, 20)
.build();
}
public Button(String text, int x, int y) {
btn = new net.minecraft.client.gui.components.Button(0, 0, x, y, Component.nullToEmpty(text), a -> {});
btn = net.minecraft.client.gui.components.Button.builder(Component.nullToEmpty(text), a -> {})
.bounds(0, 0, x, y)
.build();
}
@Override
@ -71,7 +82,7 @@ public class Button extends Control {
}
@Override
public void draw(PoseStack poseStack, int mouseX, int mouseY, float ptt) {
public void draw(GuiGraphics poseStack, int mouseX, int mouseY, float ptt) {
btn.render(poseStack, mouseX, mouseY, ptt);
}
@ -103,18 +114,20 @@ public class Button extends Control {
@Override
public void setPos(int x, int y) {
btn.x = x;
btn.y = y;
// btn.x = x;
// btn.y = y;
}
@Override
public int getX() {
return btn.x;
// return btn.x;
return 0;
}
@Override
public int getY() {
return btn.y;
// return btn.y;
return 0;
}
public net.minecraft.client.gui.components.Button getMcButton() {
@ -204,8 +217,8 @@ public class Button extends Control {
@Override
public void load(JsonOWrapper json) {
super.load(json);
btn.x = json.getInt("x", 0);
btn.y = json.getInt("y", 0);
// btn.x = json.getInt("x", 0);
// btn.y = json.getInt("y", 0);
btn.setWidth(json.getInt("width", 200));
btn.setHeight(json.getInt("height", 20));
btn.setMessage(Component.nullToEmpty(tr(json.getString("label", btn.getMessage().getContents().toString()))));

View File

@ -7,6 +7,7 @@ package net.montoyo.wd.client.gui.controls;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
@ -75,21 +76,21 @@ public class CheckBox extends BasicControl {
}
@Override
public void draw(PoseStack poseStack, int mouseX, int mouseY, float ptt) {
if(visible) {
// GlStateManager.disableAlpha();
poseStack.pushPose();
RenderSystem.setShaderTexture(2, checked ? texChecked : texUnchecked);
RenderSystem.bindTexture(2);
RenderSystem.enableBlend();
fillTexturedRect(poseStack, x, y, WIDTH, HEIGHT, 0.0, 0.0, 1.0, 1.0);
RenderSystem.disableBlend();
RenderSystem.bindTexture(-1);
poseStack.popPose();
boolean inside = (!disabled && mouseX >= x && mouseX <= x + WIDTH + 2 + labelW && mouseY >= y && mouseY < y + HEIGHT);
font.draw(poseStack, label, x + WIDTH + 2, y + 4, inside ? 0xFF0080FF : COLOR_WHITE);
}
public void draw(GuiGraphics poseStack, int mouseX, int mouseY, float ptt) {
// if(visible) {
//// GlStateManager.disableAlpha();
// poseStack.pushPose();
// RenderSystem.setShaderTexture(2, checked ? texChecked : texUnchecked);
// RenderSystem.bindTexture(2);
// RenderSystem.enableBlend();
// fillTexturedRect(poseStack, x, y, WIDTH, HEIGHT, 0.0, 0.0, 1.0, 1.0);
// RenderSystem.disableBlend();
// RenderSystem.bindTexture(-1);
//
// poseStack.popPose();
// boolean inside = (!disabled && mouseX >= x && mouseX <= x + WIDTH + 2 + labelW && mouseY >= y && mouseY < y + HEIGHT);
//// font.draw(poseStack, label, x + WIDTH + 2, y + 4, inside ? 0xFF0080FF : COLOR_WHITE);
// }
}
public void setLabel(String label) {
@ -134,9 +135,9 @@ public class CheckBox extends BasicControl {
}
@Override
public void postDraw(PoseStack poseStack, int mouseX, int mouseY, float ptt) {
public void postDraw(GuiGraphics poseStack, int mouseX, int mouseY, float ptt) {
if(tooltip != null && !disabled && mouseX >= x && mouseX <= x + WIDTH + 2 + labelW && mouseY >= y && mouseY < y + HEIGHT)
parent.drawTooltip(poseStack, tooltip, mouseX, mouseY);
parent.drawTooltip(poseStack.pose(), tooltip, mouseX, mouseY);
}
}

View File

@ -5,6 +5,7 @@
package net.montoyo.wd.client.gui.controls;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.GuiGraphics;
import net.montoyo.wd.client.gui.loading.GuiLoader;
import net.montoyo.wd.client.gui.loading.JsonAWrapper;
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
@ -137,13 +138,13 @@ public abstract class Container extends BasicControl {
}
@Override
public void draw(PoseStack poseStack, int mouseX, int mouseY, float ptt) {
public void draw(GuiGraphics poseStack, int mouseX, int mouseY, float ptt) {
if(visible) {
mouseX -= x + paddingX;
mouseY -= y + paddingY;
poseStack.pushPose();
poseStack.translate(x + paddingX, y + paddingY, 0.0);
poseStack.pose().pushPose();
poseStack.pose().translate(x + paddingX, y + paddingY, 0.0);
if(disabled) {
for(Control ctrl : childs)
@ -153,7 +154,7 @@ public abstract class Container extends BasicControl {
ctrl.draw(poseStack, mouseX, mouseY, ptt);
}
poseStack.popPose();
poseStack.pose().popPose();
}
}

View File

@ -10,6 +10,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
@ -89,10 +90,10 @@ public abstract class Control {
return false;
}
public void draw(PoseStack poseStack, int mouseX, int mouseY, float ptt) {
public void draw(GuiGraphics poseStack, int mouseX, int mouseY, float ptt) {
}
public void postDraw(PoseStack poseStack, int mouseX, int mouseY, float ptt) {
public void postDraw(GuiGraphics poseStack, int mouseX, int mouseY, float ptt) {
}
public void destroy() {

View File

@ -9,8 +9,10 @@ import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexFormat;
import net.minecraft.client.gui.GuiGraphics;
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
import net.montoyo.wd.utilities.Bounds;
import org.lwjgl.opengl.GL11;
import static org.lwjgl.opengl.GL11.*;
@ -94,13 +96,14 @@ public class ControlGroup extends Container {
}
@Override
public void draw(PoseStack poseStack, int mouseX, int mouseY, float ptt) {
public void draw(GuiGraphics poseStack, int mouseX, int mouseY, float ptt) {
super.draw(poseStack, mouseX, mouseY, ptt);
if(visible) {
poseStack.pushPose();
poseStack.pose().pushPose();
RenderSystem.setShaderColor(0.5f, 0.5f, 0.5f, 1.f);
RenderSystem.disableTexture();
// RenderSystem.disableTexture();
GL11.glDisable(GL_TEXTURE_2D);
RenderSystem.enableBlend();
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
@ -159,11 +162,12 @@ public class ControlGroup extends Container {
tessellator.end();
RenderSystem.disableBlend();
RenderSystem.enableTexture();
poseStack.popPose();
// RenderSystem.enableTexture();
GL11.glEnable(GL_TEXTURE_2D);
poseStack.pose().popPose();
if(labelW != 0)
font.drawShadow(poseStack, label, x + 10 + ((int) bp), y, labelColor, labelShadowed);
// if(labelW != 0)
// font.drawShadow(poseStack, label, x + 10 + ((int) bp), y, labelColor, labelShadowed);
}
}

View File

@ -6,8 +6,10 @@ package net.montoyo.wd.client.gui.controls;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.resources.ResourceLocation;
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GL11;
public class Icon extends BasicControl {
@ -44,17 +46,18 @@ public class Icon extends BasicControl {
}
@Override
public void draw(PoseStack poseStack, int mouseX, int mouseY, float ptt) {
public void draw(GuiGraphics poseStack, int mouseX, int mouseY, float ptt) {
if(texture != null) {
poseStack.pushPose();
RenderSystem.enableTexture();
poseStack.pose().pushPose();
// RenderSystem.enableTexture();
GL11.glEnable(GL11.GL_TEXTURE_2D);
RenderSystem.setShaderTexture(1, texture);
RenderSystem.bindTexture(1);
RenderSystem.enableBlend();
fillTexturedRect(poseStack, x, y, width, height, u1, v1, u2, v2);
fillTexturedRect(poseStack.pose(), x, y, width, height, u1, v1, u2, v2);
RenderSystem.disableBlend();
RenderSystem.bindTexture(-1);
poseStack.popPose();
poseStack.pose().popPose();
}
}

View File

@ -5,6 +5,7 @@
package net.montoyo.wd.client.gui.controls;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.GuiGraphics;
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
public class Label extends BasicControl {
@ -72,9 +73,9 @@ public class Label extends BasicControl {
}
@Override
public void draw(PoseStack poseStack, int mouseX, int mouseY, float ptt) {
if(visible)
font.drawShadow(poseStack, label, x, y, color, shadowed);
public void draw(GuiGraphics poseStack, int mouseX, int mouseY, float ptt) {
// if(visible)
// font.drawShadow(poseStack, label, x, y, color, shadowed);
}
@Override

View File

@ -9,6 +9,7 @@ import com.mojang.blaze3d.pipeline.TextureTarget;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
import java.util.ArrayList;
@ -120,7 +121,7 @@ public class List extends BasicControl {
break;
int color = (i == selected) ? selColor : COLOR_WHITE;
font.draw(poseStack, content.get(i).text, 4, i * 12 + offset, color);
// font.draw(poseStack, content.get(i).text, 4, i * 12 + offset, color);
}
}
@ -311,7 +312,7 @@ public class List extends BasicControl {
}
@Override
public void draw(PoseStack poseStack, int mouseX, int mouseY, float ptt) {
public void draw(GuiGraphics poseStack, int mouseX, int mouseY, float ptt) {
if(visible) {
if(update) {
renderToFBO();
@ -320,7 +321,7 @@ public class List extends BasicControl {
fbo.bindRead(); //TODO: Make sure is right
RenderSystem.setShaderColor(1.f, 1.f, 1.f, 1.f);
fillTexturedRect(poseStack, x, y, width, height, 0.0, 1.0, 1.0, 0.0);
// fillTexturedRect(poseStack, x, y, width, height, 0.0, 1.0, 1.0, 0.0);
fbo.unbindRead();
fillRect(x + width - 5, y + 1 + scrollPos, 4, scrollSize, (scrolling || isInScrollbar(mouseX, mouseY)) ? 0xFF202020 : 0xFF404040);

View File

@ -5,6 +5,7 @@
package net.montoyo.wd.client.gui.controls;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.network.chat.Component;
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
@ -190,7 +191,7 @@ public class TextField extends Control {
}
@Override
public void draw(PoseStack poseStack, int mouseX, int mouseY, float ptt) {
public void draw(GuiGraphics poseStack, int mouseX, int mouseY, float ptt) {
field.render(poseStack, mouseX, mouseY, ptt);
}
@ -241,23 +242,25 @@ public class TextField extends Control {
@Override
public void setPos(int x, int y) {
field.x = x + 1;
field.y = y + 1;
// field.x = x + 1;
// field.y = y + 1;
}
@Override
public int getX() {
return field.x - 1;
// return field.x - 1;
return 0;
}
@Override
public int getY() {
return field.y - 1;
// return field.y - 1;
return 0;
}
public void setDisabled(boolean en) {
enabled = !en;
field.setFocus(enabled);
// field.setFocus(enabled);
}
public boolean isDisabled() {
@ -265,12 +268,12 @@ public class TextField extends Control {
}
public void enable() {
field.setFocus(true);
// field.setFocus(true);
enabled = true;
}
public void disable() {
field.setFocus(false);
// field.setFocus(false);
enabled = false;
}
@ -291,7 +294,7 @@ public class TextField extends Control {
}
public void setFocused(boolean val) {
field.setFocus(val);
// field.setFocus(val);
}
public boolean hasFocus() {
@ -299,7 +302,7 @@ public class TextField extends Control {
}
public void focus() {
field.setFocus(true);
// field.setFocus(true);
}
public void setTextColor(int color) {
@ -336,8 +339,8 @@ public class TextField extends Control {
@Override
public void load(JsonOWrapper json) {
super.load(json);
field.x = json.getInt("x", 0) + 1;
field.y = json.getInt("y", 0) + 1;
// field.x = json.getInt("x", 0) + 1;
// field.y = json.getInt("y", 0) + 1;
field.setWidth(json.getInt("width", 200) - 2);
field.setHeight(json.getInt("height", 22) - 2);
field.setValue(tr(json.getString("text", "")));
@ -350,7 +353,7 @@ public class TextField extends Control {
field.setTextColor(textColor);
field.setTextColorUneditable(disabledColor);
field.setFocus(enabled);
// field.setFocus(enabled);
}
}

View File

@ -6,6 +6,7 @@ package net.montoyo.wd.client.gui.controls;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.world.item.ItemStack;
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
@ -26,7 +27,7 @@ public class UpgradeGroup extends BasicControl {
}
@Override
public void draw(PoseStack poseStack, int mouseX, int mouseY, float ptt) {
public void draw(GuiGraphics poseStack, int mouseX, int mouseY, float ptt) {
if(upgrades != null) {
int x = this.x;
@ -34,17 +35,17 @@ public class UpgradeGroup extends BasicControl {
if(is == overStack && !disabled)
fillRect(x, y, 16, 16, 0x80FF0000);
renderItem.renderAndDecorateItem(mc.player, is, x, y, 0);
renderItem.renderAndDecorateItem(is, font.lineHeight, x, y); //TODO is lineHeight right?
// renderItem.renderAndDecorateItem(mc.player, is, x, y, 0);
// renderItem.renderAndDecorateItem(is, font.lineHeight, x, y); //TODO is lineHeight right?
x += 18;
}
}
}
@Override
public void postDraw(PoseStack poseStack, int mouseX, int mouseY, float ptt) {
public void postDraw(GuiGraphics poseStack, int mouseX, int mouseY, float ptt) {
if(overStack != null)
parent.drawItemStackTooltip(poseStack, overStack, mouseX, mouseY);
parent.drawItemStackTooltip(poseStack.pose(), overStack, mouseX, mouseY);
}
@Override

View File

@ -39,16 +39,27 @@ public class ScreenModelLoader implements IGeometryLoader<ScreenModelLoader.Scre
}
public static class ScreenModelGeometry implements IUnbakedGeometry<ScreenModelGeometry> {
@Override
public BakedModel bake(IGeometryBakingContext iGeometryBakingContext, ModelBakery arg, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState, ItemOverrides itemOverrides, ResourceLocation arg4) {
return new ScreenBaker(modelState, spriteGetter, itemOverrides, iGeometryBakingContext.getTransforms());
public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation) {
return new ScreenBaker(modelState, spriteGetter, overrides, context.getTransforms());
}
// @Override
// public void resolveParents(Function<ResourceLocation, UnbakedModel> modelGetter, IGeometryBakingContext context) {
// IUnbakedGeometry.super.resolveParents(modelGetter, context);
// }
// @Override
// public Set<String> getConfigurableComponentNames() {
// return IUnbakedGeometry.super.getConfigurableComponentNames();
// }
@Override
public Collection<Material> getMaterials(IGeometryBakingContext iGeometryBakingContext, Function<ResourceLocation, UnbakedModel> function, Set<Pair<String, String>> set) {
return Arrays.asList(MATERIALS_SIDES);
}
// TODO: ?
// @Override
// public Collection<Material> getMaterials(IGeometryBakingContext iGeometryBakingContext, Function<ResourceLocation, UnbakedModel> function, Set<Pair<String, String>> set) {
// return Arrays.asList(MATERIALS_SIDES);
// }
}
}

View File

@ -51,8 +51,8 @@ public class JSRequestControl extends ScreenControl {
@Override
public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
ServerPlayer player = ctx.getSender();
if (reqType == null || data == null) Log.warning("Caught invalid JS request from player %s (UUID %s)", player.getName(), player.getGameProfile().getId().toString());
else tes.handleJSRequest(player, side, reqId, reqType, data);
// if (reqType == null || data == null) Log.warning("Caught invalid JS request from player %s (UUID %s)", player.getName(), player.getGameProfile().getId().toString());
// else tes.handleJSRequest(player, side, reqId, reqType, data);
}
@Override

View File

@ -1,21 +1,21 @@
/*
* Copyright (C) 2018 BARBOTIN Nicolas
*/
package net.montoyo.wd.core;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.montoyo.wd.init.BlockInit;
public class WDCreativeTab extends CreativeModeTab {
public WDCreativeTab() {
super("webdisplays");
}
@Override
public ItemStack makeIcon() {
return new ItemStack(BlockInit.blockScreen.get());
}
}
///*
// * Copyright (C) 2018 BARBOTIN Nicolas
// */
//
//package net.montoyo.wd.core;
//
//import net.minecraft.world.item.CreativeModeTab;
//import net.minecraft.world.item.ItemStack;
//import net.montoyo.wd.init.BlockInit;
//
//public class WDCreativeTab extends CreativeModeTab {
//
// public WDCreativeTab() {
// super("webdisplays");
// }
//
// @Override
// public ItemStack makeIcon() {
// return new ItemStack(BlockInit.blockScreen.get());
// }
//}

View File

@ -391,7 +391,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase {
else if((scr.getScreen(screenSide).rightsFor(owner.uuid) & ScreenRights.CHANGE_URL) == 0)
return err("restrictions");
else {
scr.evalJS(screenSide, code);
// scr.evalJS(screenSide, code);
return TRUE;
}
}

View File

@ -45,12 +45,12 @@ public class ItemInit{
}
}
public static final RegistryObject<Item> SCREEN = ITEMS.register("screen", () -> new BlockItem(BlockInit.blockScreen.get(), new Item.Properties().tab(WebDisplays.CREATIVE_TAB)));
public static final RegistryObject<Item> SCREEN = ITEMS.register("screen", () -> new BlockItem(BlockInit.blockScreen.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
public static final RegistryObject<Item> KEYBOARD = ITEMS.register("keyboard", () -> new KeyboardItem(BlockInit.blockKeyBoard.get(), new Item.Properties().tab(WebDisplays.CREATIVE_TAB)));
public static final RegistryObject<Item> REDSTONE_CONTROLLER = ITEMS.register("redctrl", () -> new BlockItem(BlockInit.blockRedControl.get(), new Item.Properties().tab(WebDisplays.CREATIVE_TAB)));
public static final RegistryObject<Item> REMOTE_CONTROLLER = ITEMS.register("rctrl", () -> new BlockItem(BlockInit.blockRControl.get(), new Item.Properties().tab(WebDisplays.CREATIVE_TAB)));
public static final RegistryObject<Item> SERVER = ITEMS.register("server", () -> new BlockItem(BlockInit.blockServer.get(), new Item.Properties().tab(WebDisplays.CREATIVE_TAB)));
public static final RegistryObject<Item> KEYBOARD = ITEMS.register("keyboard", () -> new KeyboardItem(BlockInit.blockKeyBoard.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
public static final RegistryObject<Item> REDSTONE_CONTROLLER = ITEMS.register("redctrl", () -> new BlockItem(BlockInit.blockRedControl.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
public static final RegistryObject<Item> REMOTE_CONTROLLER = ITEMS.register("rctrl", () -> new BlockItem(BlockInit.blockRControl.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
public static final RegistryObject<Item> SERVER = ITEMS.register("server", () -> new BlockItem(BlockInit.blockServer.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
public static RegistryObject<Item> getComputerCraftItem(int index) {
return COMP_CRAFT_ITEMS[index];

View File

@ -13,8 +13,8 @@ public class ItemCraftComponent extends ItemMulti implements WDItem {
public ItemCraftComponent(Properties properties) {
super(CraftComponent.class, properties
//setRegistryName("craftcomp");
.tab(WebDisplays.CREATIVE_TAB));
// .tab(WebDisplays.CREATIVE_TAB)
);
//Hide the bad extension card from the creative tab
creativeTabItems.clear(CraftComponent.BADEXTCARD.ordinal());

View File

@ -33,9 +33,9 @@ public class ItemLaserPointer extends Item implements WDItem {
public ItemLaserPointer(Properties properties) {
super(properties
//setRegistryName("laserpointer")
.stacksTo(1)
.tab(WebDisplays.CREATIVE_TAB));
// .tab(WebDisplays.CREATIVE_TAB)
);
}
//Laser pointer

View File

@ -30,9 +30,9 @@ public class ItemLinker extends Item implements WDItem {
public ItemLinker(Properties properties) {
super(properties
//setRegistryName("linker");
.stacksTo(1)
.tab(WebDisplays.CREATIVE_TAB));
// .tab(WebDisplays.CREATIVE_TAB)
);
}
@Override

View File

@ -31,11 +31,10 @@ public class ItemMinePad2 extends Item implements WDItem {
public ItemMinePad2(Properties properties) {
super(properties
//setRegistryName("minepad");
.stacksTo(1)
//TODO what is Full3D();
.defaultDurability(0)
.tab(WebDisplays.CREATIVE_TAB));
// .tab(WebDisplays.CREATIVE_TAB)
);
}
private static String getURL(ItemStack is) {
@ -76,7 +75,7 @@ public class ItemMinePad2 extends Item implements WDItem {
@Override
public boolean onEntityItemUpdate(ItemStack stack, ItemEntity ent) {
if (ent.isOnGround() && !ent.getLevel().isClientSide) {
if (ent.onGround() && !ent.level().isClientSide) {
CompoundTag tag = ent.getItem().getTag();
if (tag != null && tag.contains("ThrowHeight")) {
@ -95,11 +94,11 @@ public class ItemMinePad2 extends Item implements WDItem {
ent.getItem().setTag(null);
if (thrower != null && height - ent.getBlockY() >= 20.0) {
ent.getLevel().playSound(null, ent.getBlockX(), ent.getBlockY(), ent.getBlockZ(), SoundEvents.GLASS_BREAK, SoundSource.BLOCKS, 4.0f, 1.0f);
ent.getLevel().addFreshEntity(new ItemEntity(ent.getLevel(), ent.getBlockX(), ent.getBlockY(), ent.getBlockZ(), CraftComponent.EXTCARD.makeItemStack()));
ent.level().playSound(null, ent.getBlockX(), ent.getBlockY(), ent.getBlockZ(), SoundEvents.GLASS_BREAK, SoundSource.BLOCKS, 4.0f, 1.0f);
ent.level().addFreshEntity(new ItemEntity(ent.level(), ent.getBlockX(), ent.getBlockY(), ent.getBlockZ(), CraftComponent.EXTCARD.makeItemStack()));
ent.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION);
Player ply = ent.getLevel().getPlayerByUUID(thrower);
Player ply = ent.level().getPlayerByUUID(thrower);
if (ply != null && ply instanceof ServerPlayer)
WebDisplays.INSTANCE.criterionPadBreak.trigger(((ServerPlayer) ply).getAdvancements());
}

View File

@ -26,9 +26,9 @@ public class ItemOwnershipThief extends Item implements WDItem {
public ItemOwnershipThief(Properties properties) {
super(properties
//setRegistryName("ownerthief");
.stacksTo(1)
.tab(WebDisplays.CREATIVE_TAB));
// .tab(WebDisplays.CREATIVE_TAB)
);
}
@Override

View File

@ -24,9 +24,9 @@ public class ItemScreenConfigurator extends Item implements WDItem {
public ItemScreenConfigurator(Properties properties) {
super(properties
//setRegistryName("screencfg");
.stacksTo(1)
.tab(WebDisplays.CREATIVE_TAB));
// .tab(WebDisplays.CREATIVE_TAB)
);
}
@Override

View File

@ -21,7 +21,7 @@ public class ItemUpgrade extends ItemMulti implements IUpgrade, WDItem {
public final DefaultUpgrade type;
public ItemUpgrade(DefaultUpgrade type) {
super(DefaultUpgrade.class, new Properties().tab(WebDisplays.CREATIVE_TAB));
super(DefaultUpgrade.class, new Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/);
this.type = type;
}

View File

@ -3,6 +3,7 @@ package net.montoyo.wd.mixins;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiGraphics;
import net.montoyo.wd.client.ClientProxy;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@ -24,7 +25,8 @@ public class OverlayMixin {
protected int screenHeight;
@Inject(at = @At("HEAD"), method = "renderCrosshair", cancellable = true)
public void preDrawCrosshair(PoseStack poseStack, CallbackInfo ci) {
ClientProxy.renderCrosshair(minecraft.options, screenWidth, screenHeight, ((Gui) (Object) this).getBlitOffset(), poseStack, ci);
public void preDrawCrosshair(GuiGraphics pGuiGraphics, CallbackInfo ci) {
// ClientProxy.renderCrosshair(minecraft.options, screenWidth, screenHeight, ((Gui) (Object) this).getBlitOffset(), poseStack, ci);
ClientProxy.renderCrosshair(minecraft.options, screenWidth, screenHeight, 0, pGuiGraphics, ci);
}
}

View File

@ -42,9 +42,9 @@ public class C2SMessageRedstoneCtrl extends Packet implements Runnable {
@Override
public void run() {
Level world = player.level;
Level world = player.level();
BlockPos blockPos = pos.toBlock();
final double maxRange = player.getAttribute(ForgeMod.REACH_DISTANCE.get()).getValue();
final double maxRange = player.getAttribute(ForgeMod.BLOCK_REACH.get()).getValue();
if (player.distanceToSqr(blockPos.getX(), blockPos.getY(), blockPos.getZ()) > maxRange * maxRange)
return;