various thhingingses

This commit is contained in:
GiantLuigi4 2023-03-09 21:50:12 -05:00
parent b9716dd537
commit b01e15ab73
25 changed files with 360 additions and 254 deletions

View File

@ -1,12 +1,9 @@
# WebDisplays for Minecraft 1.12.2
This is the WebDisplays mod for Minecraft 1.12.2. I don't have time to maintain it anymore, so I changed the license recently and anybody is welcome to create forks and/or re-distribute it. For more info see [LICENSE](LICENSE).
# WebDisplays for Minecraft 1.19.2
This is a fork of the Web Displays mod from 1.12, updated to work on 1.19, and with some bug fixes and reworking.
### Wiki
* The Wiki that details all blocks/items can be found on my website https://montoyo.net/wdwiki/
### Things before release
* Release ready. Targeted release date: 17/02/2018.
### Delayed things
* Plugin API
* The Shop

View File

@ -75,7 +75,7 @@ dependencies {
minecraft 'net.minecraftforge:forge:1.19.2-43.2.6'
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
implementation fg.deobf("com.github.Mysticpasta1:mcef-forge:d45957d9f6")
implementation fg.deobf("com.github.Mysticpasta1:mcef-forge:cb00f566f1")
implementation fg.deobf("curse.maven:cloth_config_forge-348521:3972423")
implementation fg.deobf("curse.maven:SU-370704:4410614")
implementation fg.deobf("curse.maven:spark-361579:4381167")

View File

@ -12,8 +12,10 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.BlockGetter;
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;
@ -27,10 +29,14 @@ public class SharedProxy {
}
public void init() {
MinecraftForge.EVENT_BUS.addListener(this::onCefInit);
}
public void postInit() {
}
public void onCefInit(CefInitEvent event) {
}
@Deprecated(forRemoval = true)
public Level getWorld(ResourceKey<Level> dim) {

View File

@ -225,7 +225,7 @@ public class BlockScreen extends BaseEntityBlock {
// }
Vector2i size = Multiblock.measure(world, pos, side);
if (size.x < 2 || size.y < 2) {
if (size.x < 2 && size.y < 2) {
Util.toast(player, "tooSmall");
return InteractionResult.SUCCESS;
}

View File

@ -1,8 +1,10 @@
package net.montoyo.wd.block.item;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.montoyo.wd.block.BlockKeyboardLeft;
@ -20,7 +22,7 @@ public class KeyboardItem extends BlockItem {
Direction d = BlockKeyboardLeft.mapDirection(facing);
if (isValid(arg, arg2, d)) {
if (isValid(arg.getClickedPos(), arg.getLevel(), arg2, d)) {
Block kbRight = BlockInit.blockKbRight.get();
BlockState rightState = kbRight.defaultBlockState();
@ -31,11 +33,22 @@ public class KeyboardItem extends BlockItem {
11
)) return false;
return arg.getLevel().setBlock(arg.getClickedPos(), arg2, 11);// 161
} else if (isValid(arg.getClickedPos().relative(d.getOpposite(), 2), arg.getLevel(), arg2, d)) {
Block kbRight = BlockInit.blockKbRight.get();
BlockState rightState = kbRight.defaultBlockState();
rightState = rightState.setValue(BlockKeyboardLeft.FACING, facing);
if (!arg.getLevel().setBlock(
arg.getClickedPos(),
rightState,
11
)) return false;
return arg.getLevel().setBlock(arg.getClickedPos().relative(d.getOpposite()), arg2, 11);// 161
}
return false;
}
private boolean isValid(BlockPlaceContext context, BlockState state, Direction d) {
return context.getLevel().getBlockState(context.getClickedPos().relative(d)).isAir();
private boolean isValid(BlockPos pos, Level level, BlockState state, Direction d) {
return level.getBlockState(pos.relative(d)).isAir();
}
}

View File

@ -153,22 +153,29 @@ public class ClientProxy extends SharedProxy implements IDisplayHandler, IJSQuer
@Override
public void preInit() {
super.preInit();
mc = Minecraft.getInstance();
MinecraftForge.EVENT_BUS.register(this);
mcef = MCEFApi.getAPI();
if(mcef != null)
mcef.registerScheme("wd", WDScheme.class, true, false, false, true, true, false, false);
}
@Override
public void init() {
super.init();
}
@Override
public void onCefInit(CefInitEvent event) {
MinecraftForge.EVENT_BUS.register(this);
mcef = event.getApi();
if(mcef != null)
mcef.registerScheme("wd", WDScheme.class, true, false, false, true, true, false, false);
jsDispatcher = new JSQueryDispatcher(this);
minePadRenderer = new MinePadRenderer();
laserPointerRenderer = new LaserPointerRenderer();
if(mcef == null)
throw new RuntimeException("MCEF is missing");
mcef.registerDisplayHandler(this);
//mcef.registerJSQueryHandler(this); //TODO why crashing on this method!
findAdvancementToProgressField();

View File

@ -121,7 +121,7 @@ public abstract class WDScreen extends Screen {
for(Control ctrl: postDrawList)
ctrl.postDraw(poseStack, mouseX, mouseY, ptt);
}
@Override
public boolean charTyped(char codePoint, int modifiers) {
boolean typed = false;
@ -207,7 +207,7 @@ public abstract class WDScreen extends Screen {
boolean down = false;
for (Control ctrl : controls)
down = down || ctrl.keyDown(keyCode);
down = down || ctrl.keyDown(keyCode, scanCode, modifiers);
if (Minecraft.getInstance().screen instanceof GuiKeyboard) {
return down;
@ -221,7 +221,7 @@ public abstract class WDScreen extends Screen {
boolean up = false;
for(Control ctrl : controls)
up = up || ctrl.keyUp(keyCode);
up = up || ctrl.keyUp(keyCode, scanCode, modifiers);
return up || super.keyReleased(keyCode, scanCode, modifiers);
}

View File

@ -158,7 +158,7 @@ public class Button extends Control {
}
@Override
public boolean keyUp(int key) {
public boolean keyUp(int key, int scanCode, int modifiers) {
if(key == GLFW.GLFW_KEY_LEFT_SHIFT || key == GLFW.GLFW_KEY_RIGHT_SHIFT) {
shiftDown = false;
btn.setFGColor(originalColor);
@ -170,7 +170,7 @@ public class Button extends Control {
}
@Override
public boolean keyDown(int key) {
public boolean keyDown(int key, int scanCode, int modifiers) {
if(key == GLFW.GLFW_KEY_LEFT_SHIFT || key == GLFW.GLFW_KEY_RIGHT_SHIFT) {
shiftDown = true;
btn.setFGColor(shiftColor);

View File

@ -36,24 +36,24 @@ public abstract class Container extends BasicControl {
}
@Override
public boolean keyUp(int key) {
public boolean keyUp(int key, int scanCode, int modifiers) {
boolean up = false;
if(!disabled) {
for(Control ctrl : childs)
up = up || ctrl.keyUp(key);
up = up || ctrl.keyUp(key, scanCode, modifiers);
}
return up;
}
@Override
public boolean keyDown(int key) {
public boolean keyDown(int key, int scanCode, int modifiers) {
boolean down = false;
if(!disabled) {
for(Control ctrl : childs)
down = down || ctrl.keyDown(key);
down = down || ctrl.keyDown(key, scanCode, modifiers);
}
return down;

View File

@ -62,11 +62,11 @@ public abstract class Control {
return false;
}
public boolean keyUp(int key) {
public boolean keyUp(int key, int scanCode, int modifiers) {
return false;
}
public boolean keyDown(int key) {
public boolean keyDown(int key, int scanCode, int modifiers) {
return false;
}

View File

@ -8,10 +8,14 @@ import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.network.chat.Component;
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
import org.cef.browser.CefBrowserOsr;
import org.lwjgl.glfw.GLFW;
import java.util.ArrayList;
import static java.awt.event.KeyEvent.VK_ENTER;
import static org.lwjgl.glfw.GLFW.*;
public class TextField extends Control {
public static class EnterPressedEvent extends Event<TextField> {
@ -104,30 +108,35 @@ public class TextField extends Control {
field = new EditBox(font, x + 1, y + 1, width - 2, height - 2, Component.nullToEmpty(""));
field.setValue(text);
}
@Override
public boolean keyDown(int key) {
if(key == GLFW.GLFW_KEY_BACKSPACE) {
String old;
if(enabled && field.isFocused())
old = field.getValue();
else
old = null;
if(field.getValue().length() > 0)
field.setValue(field.getValue().substring(0, field.getValue().length() - 1));
if(enabled && field.isFocused() && !field.getValue().equals(old)) {
for(TextChangeListener tcl : listeners)
tcl.onTextChange(this, old, field.getValue());
parent.actionPerformed(new TextChangedEvent(this, old));
}
}
return false;
// TODO: make this public static in CefBrowserOSR
private long mapScanCode(int key, char c) {
if (key == GLFW_KEY_LEFT_CONTROL || key == GLFW_KEY_RIGHT_CONTROL) return 29;
return switch (key) {
case GLFW_KEY_DELETE -> 83;
case GLFW_KEY_LEFT -> 75;
case GLFW_KEY_DOWN -> 80;
case GLFW_KEY_UP -> 72;
case GLFW_KEY_RIGHT -> 77;
case GLFW_KEY_PAGE_DOWN -> 81;
case GLFW_KEY_PAGE_UP -> 73;
case GLFW_KEY_END -> 79;
case GLFW_KEY_HOME -> 71;
case VK_ENTER, GLFW_KEY_ENTER, GLFW_KEY_KP_ENTER -> 28;
default -> GLFW.glfwGetKeyScancode(key);
};
}
@Override
public boolean keyDown(int key, int scanCode, int modifiers) {
return field.keyPressed(key, scanCode, modifiers);
}
@Override
public boolean keyUp(int key, int scanCode, int modifiers) {
return field.keyReleased(key, scanCode, modifiers);
}
@Override
public boolean keyTyped(int keyCode, int modifier) {
if(keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_KP_ENTER)
@ -141,24 +150,45 @@ public class TextField extends Control {
else
old = null;
field.charTyped((char) keyCode, modifier);
if(enabled && field.isFocused() && !field.getValue().equals(old)) {
for(TextChangeListener tcl : listeners)
tcl.onTextChange(this, old, field.getValue());
parent.actionPerformed(new TextChangedEvent(this, old));
}
return field.charTyped((char) keyCode, modifier);
}
return false;
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
return field.mouseClicked(mouseX, mouseY, mouseButton);
}
@Override
public boolean mouseReleased(double mouseX, double mouseY, int state) {
return field.mouseReleased(mouseX, mouseY, state);
}
@Override
public boolean mouseClickMove(double mouseX, double mouseY, int button, double dragX, double dragY) {
return field.mouseClicked(mouseX, mouseY, 0);
}
@Override
public boolean mouseMove(double mouseX, double mouseY) {
field.mouseMoved(mouseX, mouseY);
return true;
}
@Override
public boolean mouseScroll(double mouseX, double mouseY, double amount) {
return field.mouseScrolled(mouseX, mouseY, amount);
}
@Override
public void draw(PoseStack poseStack, int mouseX, int mouseY, float ptt) {
field.render(poseStack, mouseX, mouseY, ptt);

View File

@ -9,10 +9,13 @@ import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.world.phys.AABB;
import net.montoyo.mcef.api.IStringVisitor;
import net.montoyo.wd.SharedProxy;
import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.client.ClientProxy;
@ -157,68 +160,15 @@ public class ScreenRenderer implements BlockEntityRenderer<TileEntityScreen> {
//Bounding box debugging
// poseStack.pushPose();
// poseStack.translate(-te.getBlockPos().getX(), -te.getBlockPos().getY(), -te.getBlockPos().getZ());
// renderAABB(te.getRenderBoundingBox());
// poseStack.popPose();
poseStack.pushPose();
poseStack.translate(-te.getBlockPos().getX(), -te.getBlockPos().getY(), -te.getBlockPos().getZ());
LevelRenderer.renderLineBox(
poseStack, bufferSource.getBuffer(RenderType.LINES),
te.getRenderBoundingBox(), 1, 1, 1, 1f
);
poseStack.popPose();
//Re-enable lighting
RenderSystem.enableCull();
}
public void renderAABB(AABB bb) {
RenderSystem.disableTexture();
RenderSystem.enableBlend();
RenderSystem.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
RenderSystem.disableCull();
RenderSystem.setShaderColor(0.f, 0.5f, 1.f, 0.75f);
RenderSystem.depthMask(false);
Tesselator t = new Tesselator();
BufferBuilder vb = t.getBuilder();
VertexBuffer tb = new VertexBuffer();
vb.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION);
//Bottom
vb.vertex(bb.minX, bb.minY, bb.minZ).endVertex();
vb.vertex(bb.maxX, bb.minY, bb.minZ).endVertex();
vb.vertex(bb.maxX, bb.minY, bb.maxZ).endVertex();
vb.vertex(bb.minX, bb.minY, bb.maxZ).endVertex();
//Top
vb.vertex(bb.minX, bb.maxY, bb.minZ).endVertex();
vb.vertex(bb.maxX, bb.maxY, bb.minZ).endVertex();
vb.vertex(bb.maxX, bb.maxY, bb.maxZ).endVertex();
vb.vertex(bb.minX, bb.maxY, bb.maxZ).endVertex();
//Left
vb.vertex(bb.minX, bb.minY, bb.minZ).endVertex();
vb.vertex(bb.minX, bb.minY, bb.maxZ).endVertex();
vb.vertex(bb.minX, bb.maxY, bb.maxZ).endVertex();
vb.vertex(bb.minX, bb.maxY, bb.minZ).endVertex();
//Right
vb.vertex(bb.maxX, bb.minY, bb.minZ).endVertex();
vb.vertex(bb.maxX, bb.minY, bb.maxZ).endVertex();
vb.vertex(bb.maxX, bb.maxY, bb.maxZ).endVertex();
vb.vertex(bb.maxX, bb.maxY, bb.minZ).endVertex();
//Front
vb.vertex(bb.minX, bb.minY, bb.minZ).endVertex();
vb.vertex(bb.maxX, bb.minY, bb.minZ).endVertex();
vb.vertex(bb.maxX, bb.maxY, bb.minZ).endVertex();
vb.vertex(bb.minX, bb.maxY, bb.minZ).endVertex();
//Back
vb.vertex(bb.minX, bb.minY, bb.maxZ).endVertex();
vb.vertex(bb.maxX, bb.minY, bb.maxZ).endVertex();
vb.vertex(bb.maxX, bb.maxY, bb.maxZ).endVertex();
vb.vertex(bb.minX, bb.maxY, bb.maxZ).endVertex();
tb.draw();
RenderSystem.depthMask(true);
RenderSystem.enableCull();
RenderSystem.enableTexture();
RenderSystem.disableBlend();
}
}

View File

@ -5,6 +5,8 @@
package net.montoyo.wd.data;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.Level;
import net.minecraftforge.api.distmarker.Dist;
@ -15,9 +17,15 @@ import net.montoyo.wd.net.Messages;
import net.montoyo.wd.net.client.CMessageOpenGui;
import java.util.HashMap;
import java.util.function.Function;
public abstract class GuiData {
protected static class GuiType {
Class<?> clazz;
ResourceLocation id;
}
private static final HashMap<String, Class<? extends GuiData>> dataTable = new HashMap<>();
static {
dataTable.put("SetURL", SetURLData.class);
@ -30,7 +38,14 @@ public abstract class GuiData {
public static Class<? extends GuiData> classOf(String name) {
return dataTable.get(name);
}
public GuiData() {
}
// public GuiData(FriendlyByteBuf buf) {
// this.deserialize(buf);
// }
@OnlyIn(Dist.CLIENT)
public abstract Screen createGui(Screen old, Level world);
public abstract String getName();
@ -39,4 +54,7 @@ public abstract class GuiData {
Messages.INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), new CMessageOpenGui(this));
}
// public abstract void serialize(FriendlyByteBuf buf);
// public abstract void deserialize(FriendlyByteBuf buf);
}

View File

@ -6,6 +6,7 @@ package net.montoyo.wd.data;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.api.distmarker.Dist;
@ -23,10 +24,14 @@ public class KeyboardData extends GuiData {
public int kbX;
public int kbY;
public int kbZ;
public KeyboardData() {
}
// public KeyboardData(FriendlyByteBuf buf) {
// super(buf);
// }
public KeyboardData(TileEntityScreen tes, BlockSide side, BlockPos kbPos) {
pos = new Vector3i(tes.getBlockPos());
this.side = side;
@ -51,5 +56,24 @@ public class KeyboardData extends GuiData {
public String getName() {
return "Keyboard";
}
// @Override
// public void serialize(FriendlyByteBuf buf) {
// buf.writeInt(pos.x);
// buf.writeInt(pos.y);
// buf.writeInt(pos.z);
// buf.writeByte(side.ordinal());
// buf.writeInt(kbX);
// buf.writeInt(kbY);
// buf.writeInt(kbZ);
// }
//
// @Override
// public void deserialize(FriendlyByteBuf buf) {
// this.pos = new Vector3i(buf.readInt(), buf.readInt(), buf.readInt());
// this.side = BlockSide.values()[buf.readByte()];
// this.kbX = buf.readInt();
// this.kbY = buf.readInt();
// this.kbZ = buf.readInt();
// }
}

View File

@ -7,6 +7,7 @@ package net.montoyo.wd.data;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Style;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level;
@ -21,10 +22,15 @@ public class RedstoneCtrlData extends GuiData {
public Vector3i pos;
public String risingEdgeURL;
public String fallingEdgeURL;
public RedstoneCtrlData() {
super();
}
// public RedstoneCtrlData(FriendlyByteBuf buf) {
// super(buf);
// }
public RedstoneCtrlData(ResourceLocation d, BlockPos p, String r, String f) {
dimension = d;
pos = new Vector3i(p);

View File

@ -5,6 +5,7 @@
package net.montoyo.wd.data;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
@ -30,10 +31,14 @@ public class ScreenConfigData extends GuiData {
public NameUUIDPair[] friends;
public int friendRights;
public int otherRights;
public ScreenConfigData() {
}
// public ScreenConfigData(FriendlyByteBuf buf) {
// super(buf);
// }
public ScreenConfigData(Vector3i pos, BlockSide side, TileEntityScreen.Screen scr) {
this.pos = pos;
this.side = side;

View File

@ -6,6 +6,7 @@ package net.montoyo.wd.data;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@ -17,10 +18,14 @@ public class ServerData extends GuiData {
public Vector3i pos;
public NameUUIDPair owner;
public ServerData() {
}
// public ServerData(FriendlyByteBuf buf) {
// super(buf);
// }
public ServerData(BlockPos bp, NameUUIDPair owner) {
pos = new Vector3i(bp);
this.owner = owner;

View File

@ -6,6 +6,7 @@ package net.montoyo.wd.data;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.api.distmarker.Dist;
@ -23,10 +24,14 @@ public class SetURLData extends GuiData {
public String url;
public boolean isRemote;
public Vector3i remoteLocation;
public SetURLData() {
}
// public SetURLData(FriendlyByteBuf buf) {
// super(buf);
// }
public SetURLData(Vector3i pos, BlockSide side, String url) {
this.pos = pos;
this.side = side;

View File

@ -16,8 +16,6 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.network.Connection;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
@ -30,9 +28,9 @@ 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.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraftforge.network.PacketDistributor;
import net.montoyo.mcef.api.IBrowser;
import net.montoyo.wd.SharedProxy;
import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.block.BlockScreen;
import net.montoyo.wd.client.ClientProxy;
@ -47,9 +45,7 @@ import net.montoyo.wd.init.TileInit;
import net.montoyo.wd.miniserv.SyncPlugin;
import net.montoyo.wd.net.Messages;
import net.montoyo.wd.net.client.*;
import net.montoyo.wd.net.server.SMessageGetUrl;
import net.montoyo.wd.net.server.SMessageRequestTEData;
import net.montoyo.wd.net.server.URLMessage;
import net.montoyo.wd.utilities.*;
import org.lwjgl.glfw.GLFW;
@ -57,10 +53,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.awt.event.InputEvent;
import java.io.IOException;
import java.net.*;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.function.Consumer;
import static net.montoyo.wd.block.BlockPeripheral.point;
@ -672,19 +665,47 @@ public class TileEntityScreen extends BlockEntity {
private void updateAABB() {
Vector3i origin = new Vector3i(getBlockPos());
Vector3i tmp = new Vector3i();
AABB aabb = new AABB(origin);
MutableAABB box = null;
for (Screen scr : screens) {
tmp.set(origin);
tmp.addMul(scr.side.right, scr.size.x);
tmp.addMul(scr.side.up, scr.size.y);
tmp.add(scr.side.forward);
Vector3i f = scr.side.forward;
int fx = Math.max(f.x, 0);
int fy = Math.max(f.y, 0);
int fz = Math.max(f.z, 0);
int ox = 0;
if (scr.side.equals(BlockSide.NORTH)) ox = 1;
int oz = 0;
if (
scr.side.equals(BlockSide.EAST) ||
scr.side.equals(BlockSide.TOP) ||
scr.side.equals(BlockSide.BOTTOM)
) oz = 1;
aabb.expand(tmp);
if (box == null) {
box = new MutableAABB(
origin.x + fx + ox,
origin.y + fy,
origin.z + fz + oz,
origin.x + ox + scr.side.right.x * scr.size.x + fx + scr.side.up.x * scr.size.y,
origin.y + scr.side.right.y * scr.size.x + fy + scr.side.up.y * scr.size.y,
origin.z + oz + scr.side.right.z * scr.size.x + fz + scr.side.up.z * scr.size.y
);
} else {
box.expand(
origin.x + fx + ox,
origin.y + fy,
origin.z + fz + oz,
origin.x + ox + scr.side.right.x * scr.size.x + fx + scr.side.up.x * scr.size.y,
origin.y + scr.side.right.y * scr.size.x + fy + scr.side.up.y * scr.size.y,
origin.z + oz + scr.side.right.z * scr.size.x + fz + scr.side.up.z * scr.size.y
);
}
}
renderBB = aabb.toMc().expandTowards(0.1, 0.1, 0.1);
renderBB = box.toMc();
}
@Override

View File

@ -1,75 +0,0 @@
/*
* Copyright (C) 2018 BARBOTIN Nicolas
*/
package net.montoyo.wd.utilities;
public final class AABB {
public final Vector3i start;
public final Vector3i end;
public AABB() {
start = new Vector3i();
end = new Vector3i();
}
public AABB(Vector3i pos) {
start = pos.clone();
end = pos.clone();
}
public AABB(Vector3i a, Vector3i b) {
start = new Vector3i();
end = new Vector3i();
start.x = Math.min(a.x, b.x);
start.y = Math.min(a.y, b.y);
start.z = Math.min(a.z, b.z);
end.x = Math.max(a.x, b.x);
end.y = Math.max(a.y, b.y);
end.z = Math.max(a.z, b.z);
}
public AABB(net.minecraft.world.phys.AABB bb) {
start = new Vector3i();
end = new Vector3i();
start.x = (int) bb.minX;
start.y = (int) bb.minY;
start.z = (int) bb.minZ;
end.x = (int) Math.ceil(bb.maxX);
end.y = (int) Math.ceil(bb.maxY);
end.z = (int) Math.ceil(bb.maxZ);
}
public AABB expand(Vector3i vec) {
if(vec.x > end.x)
end.x = vec.x;
else if(vec.x < start.x)
start.x = vec.x;
if(vec.y > end.y)
end.y = vec.y;
else if(vec.y < start.y)
start.y = vec.y;
if(vec.z > end.z)
end.z = vec.z;
else if(vec.z < start.z)
start.z = vec.z;
return this;
}
public AABB move(Vector3i start) {
end.sub(this.start).add(start);
this.start.set(start);
return this;
}
public net.minecraft.world.phys.AABB toMc() {
return new net.minecraft.world.phys.AABB(start.x, start.y, start.z, end.x, end.y, end.z);
}
}

View File

@ -0,0 +1,83 @@
/*
* Copyright (C) 2018 BARBOTIN Nicolas
*/
package net.montoyo.wd.utilities;
import net.minecraft.world.phys.AABB;
public final class MutableAABB extends AABB {
public MutableAABB() {
super(0, 0, 0, 0, 0, 0);
}
public MutableAABB(Vector3i pos) {
super(pos.x, pos.y, pos.z, pos.x, pos.y, pos.z);
}
public MutableAABB(Vector3i a, Vector3i b) {
super(a.x, a.y, a.z, b.x, b.y, b.z);
}
public MutableAABB(net.minecraft.world.phys.AABB bb) {
super(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ);
}
public MutableAABB(double x1, double y1, double z1, double x2, double y2, double z2) {
super(x1, y1, z1, x2, y2, z2);
}
public MutableAABB expand(Vector3i vec) {
if (vec.x > maxX)
maxX = vec.x;
else if (vec.x < minX)
minX = vec.x;
if (vec.y > maxY)
maxY = vec.y;
else if (vec.y < minY)
minY = vec.y;
if (vec.z > maxZ)
maxZ = vec.z;
else if (vec.z < minZ)
minZ = vec.z;
return this;
}
@Override
public AABB move(double x, double y, double z) {
minX += x;
minY += y;
minZ += z;
maxX += x;
maxY += y;
maxZ += z;
return this;
}
public net.minecraft.world.phys.AABB toMc() {
return new AABB(minX, minY, minZ, maxX, maxY, maxZ);
}
public void setAndCheck(double x1, double y1, double z1, double x2, double y2, double z2) {
minX = Math.min(x1, x2);
minY = Math.min(y1, y2);
minZ = Math.min(z1, z2);
maxX = Math.max(x1, x2);
maxY = Math.max(y1, y2);
maxZ = Math.max(z1, z2);
}
public void expand(double x1, double y1, double z1, double x2, double y2, double z2) {
minX = Math.min(minX, Math.min(x1, x2));
minY = Math.min(minY, Math.min(y1, y2));
minZ = Math.min(minZ, Math.min(z1, z2));
maxX = Math.max(maxX, Math.max(x1, x2));
maxY = Math.max(maxY, Math.max(y1, y2));
maxZ = Math.max(maxZ, Math.max(z1, z2));
}
}

View File

@ -19,7 +19,8 @@ import java.util.StringJoiner;
import java.util.UUID;
public abstract class Util {
@Deprecated(forRemoval = true)
public static void serialize(FriendlyByteBuf bb, Object f) {
Class<?> cls = f.getClass();
@ -60,7 +61,8 @@ public abstract class Util {
} else
throw new RuntimeException(String.format("Cannot transmit class %s over network!", cls.getName()));
}
@Deprecated(forRemoval = true)
public static Object unserialize(FriendlyByteBuf bb, Class cls) {
if(cls == Integer.class || cls == Integer.TYPE)
return bb.readInt();

View File

@ -1 +0,0 @@
public net.minecraft.client.resources.sounds.SimpleSoundInstance

View File

@ -0,0 +1,10 @@
public net.minecraft.client.resources.sounds.SimpleSoundInstance
# AABB
public-f net.minecraft.world.phys.AABB f_82288_
public-f net.minecraft.world.phys.AABB f_82289_
public-f net.minecraft.world.phys.AABB f_82290_
public-f net.minecraft.world.phys.AABB f_82291_
public-f net.minecraft.world.phys.AABB f_82292_
public-f net.minecraft.world.phys.AABB f_82293_

View File

@ -1,38 +1,38 @@
{
"itemGroup.webdisplays": "§5Web Displays",
"tile.webdisplays.screen.name": "Web Screen",
"tile.webdisplays.peripheral.name": "Peripheral",
"tile.webdisplays.peripheral.keyboard.name": "Keyboard",
"tile.webdisplays.peripheral.remotectrl.name": "Remote Controller",
"tile.webdisplays.peripheral.ccinterface.name": "ComputerCraft Interface",
"tile.webdisplays.peripheral.cointerface.name": "OpenComputers Interface",
"tile.webdisplays.peripheral.redstonectrl.name": "Redstone Controller",
"tile.webdisplays.peripheral.server.name": "Server",
"item.webdisplays.screencfg.name": "Screen Configurator",
"item.webdisplays.ownerthief.name": "Ownership Thief [ADMIN]",
"item.webdisplays.linker.name": "Linking Tool",
"item.webdisplays.craftcomp.name": "Craft Component",
"item.webdisplays.craftcomp.stonekey.name": "Stone Key",
"item.webdisplays.craftcomp.upgrade.name": "Blank Upgrade",
"item.webdisplays.craftcomp.peripheral.name": "Peripheral Base",
"item.webdisplays.craftcomp.batcell.name": "Battery Cell",
"item.webdisplays.craftcomp.batpack.name": "Battery Pack",
"item.webdisplays.craftcomp.laserdiode.name": "650nm Laser Diode",
"item.webdisplays.craftcomp.backlight.name": "Backlight",
"item.webdisplays.craftcomp.extcard.name": "Extension Card",
"item.webdisplays.craftcomp.badextcard.name": "Bad Extension Card",
"item.webdisplays.minepad.name": "minePad",
"item.webdisplays.minepad2.name": "minePad 2",
"item.webdisplays.upgrade.name": "Screen Upgrade",
"item.webdisplays.upgrade.lasermouse.name": "Laser Sensor",
"item.webdisplays.upgrade.redinput.name": "Redstone Input Port",
"item.webdisplays.upgrade.redoutput.name": "Redstone Output Port",
"item.webdisplays.upgrade.gps.name": "GPS Module",
"item.webdisplays.laserpointer.name": "Laser Pointer",
"item.webdisplays.advicon.name": "Advancement Icon",
"item.webdisplays.advicon.wd.name": "WebDisplays",
"item.webdisplays.advicon.brokenpad.name": "Broken minePad",
"item.webdisplays.advicon.pigeon.name": "Pigeon",
"block.webdisplays.screen": "Web Screen",
"block.webdisplays.peripheral": "Peripheral",
"block.webdisplays.peripheral.keyboard": "Keyboard",
"block.webdisplays.peripheral.remotectrl": "Remote Controller",
"block.webdisplays.peripheral.ccinterface": "ComputerCraft Interface",
"block.webdisplays.peripheral.cointerface": "OpenComputers Interface",
"block.webdisplays.peripheral.redstonectrl": "Redstone Controller",
"block.webdisplays.peripheral.server": "Server",
"item.webdisplays.screencfg": "Screen Configurator",
"item.webdisplays.ownerthief": "Ownership Thief [ADMIN]",
"item.webdisplays.linker": "Linking Tool",
"item.webdisplays.craftcomp": "Craft Component",
"item.webdisplays.craftcomp.stonekey": "Stone Key",
"item.webdisplays.craftcomp.upgrade": "Blank Upgrade",
"item.webdisplays.craftcomp.peripheral": "Peripheral Base",
"item.webdisplays.craftcomp.batcell": "Battery Cell",
"item.webdisplays.craftcomp.batpack": "Battery Pack",
"item.webdisplays.craftcomp.laserdiode": "650nm Laser Diode",
"item.webdisplays.craftcomp.backlight": "Backlight",
"item.webdisplays.craftcomp.extcard": "Extension Card",
"item.webdisplays.craftcomp.badextcard": "Bad Extension Card",
"item.webdisplays.minepad": "minePad",
"item.webdisplays.minepad2": "minePad 2",
"item.webdisplays.upgrade": "Screen Upgrade",
"item.webdisplays.upgrade.lasermouse": "Laser Sensor",
"item.webdisplays.upgrade.redinput": "Redstone Input Port",
"item.webdisplays.upgrade.redoutput": "Redstone Output Port",
"item.webdisplays.upgrade.gps": "GPS Module",
"item.webdisplays.laserpointer": "Laser Pointer",
"item.webdisplays.advicon": "Advancement Icon",
"item.webdisplays.advicon.wd": "WebDisplays",
"item.webdisplays.advicon.brokenpad": "Broken minePad",
"item.webdisplays.advicon.pigeon": "Pigeon",
"item.webdisplays.wiki": "Hit 'F1' to open the Wiki",
"webdisplays.message.tooSmall": "Too small! Minimum size is 2x2.",
"webdisplays.message.tooBig": "Too big! Maximum size is %dx%d.",