lot of the work is done
This commit is contained in:
parent
76a2a704dd
commit
f7f92cd19c
|
|
@ -71,17 +71,18 @@ repositories{
|
|||
url = "https://www.cursemaven.com"
|
||||
}
|
||||
flatDir { dirs 'libs' }
|
||||
maven { url 'https://mcef-download.cinemamod.com/repository/releases' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft 'net.neoforged:forge:1.20.1-47.1.65'
|
||||
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
|
||||
|
||||
|
||||
// implementation fg.deobf("com.github.Mysticpasta1:mcef-forge:2ec6581622")
|
||||
// implementation fg.deobf("curse.maven:SU-370704:4485052")
|
||||
// implementation fg.deobf("curse.maven:spark-361579:4381167")
|
||||
|
||||
// implementation fg.deobf("flatdir.lib:mcef:1.2.4")
|
||||
implementation fg.deobf("flatdir.lib:mcef:2.x")
|
||||
// implementation fg.deobf("flatdir.lib:smallerunits:2.1.3")
|
||||
|
||||
// compileOnly fg.deobf("curse.maven:vivecraft-667903:4409427")
|
||||
|
|
|
|||
BIN
libs/mcef-2.x.jar
Normal file
BIN
libs/mcef-2.x.jar
Normal file
Binary file not shown.
|
|
@ -17,7 +17,6 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
|
|
@ -41,7 +40,7 @@ public class BlockKeyboardRight extends Block implements IPeripheral {
|
|||
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
|
||||
|
||||
public BlockKeyboardRight() {
|
||||
super(Properties.of(Material.STONE)
|
||||
super(Properties.copy(Blocks.STONE)
|
||||
.strength(1.5f, 10.f));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,19 +15,18 @@ import net.minecraft.world.level.BlockGetter;
|
|||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.PushReaction;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
import net.montoyo.mcef.utilities.Log;
|
||||
import net.montoyo.wd.core.DefaultPeripheral;
|
||||
import net.montoyo.wd.entity.TileEntityInterfaceBase;
|
||||
import net.montoyo.wd.entity.TileEntityPeripheralBase;
|
||||
|
|
@ -35,13 +34,14 @@ import net.montoyo.wd.entity.TileEntityServer;
|
|||
import net.montoyo.wd.item.ItemLinker;
|
||||
import net.montoyo.wd.net.WDNetworkRegistry;
|
||||
import net.montoyo.wd.net.client_bound.S2CMessageCloseGui;
|
||||
import net.montoyo.wd.utilities.Log;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class BlockPeripheral extends WDBlockContainer {
|
||||
DefaultPeripheral type;
|
||||
|
||||
public BlockPeripheral(DefaultPeripheral type) {
|
||||
super(BlockBehaviour.Properties.of(Material.STONE).strength(1.5f, 10.f));
|
||||
super(BlockBehaviour.Properties.copy(Blocks.STONE).strength(1.5f, 10.f));
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -740,11 +740,11 @@ public class ClientProxy extends SharedProxy implements IDisplayHandler, IJSQuer
|
|||
if (LaserPointerRenderer.isOn()) {
|
||||
ItemLaserPointer.tick(mc);
|
||||
} else {
|
||||
ItemLaserPointer.deselect(mc, jsDispatcher);
|
||||
ItemLaserPointer.deselect(mc);
|
||||
}
|
||||
|
||||
//Handle JS queries
|
||||
jsDispatcher.handleQueries();
|
||||
// //Handle JS queries
|
||||
// jsDispatcher.handleQueries();
|
||||
|
||||
//Miniserv
|
||||
if (msClientStarted && mc.player == null) {
|
||||
|
|
|
|||
|
|
@ -1,372 +1,370 @@
|
|||
/*
|
||||
* Copyright (C) 2018 BARBOTIN Nicolas
|
||||
*/
|
||||
|
||||
package net.montoyo.wd.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.montoyo.mcef.api.IBrowser;
|
||||
import net.montoyo.mcef.api.IJSQueryCallback;
|
||||
import net.montoyo.wd.block.BlockScreen;
|
||||
import net.montoyo.wd.core.DefaultUpgrade;
|
||||
import net.montoyo.wd.core.IScreenQueryHandler;
|
||||
import net.montoyo.wd.core.IUpgrade;
|
||||
import net.montoyo.wd.core.JSServerRequest;
|
||||
import net.montoyo.wd.entity.TileEntityScreen;
|
||||
import net.montoyo.wd.net.WDNetworkRegistry;
|
||||
import net.montoyo.wd.net.server_bound.C2SMessageScreenCtrl;
|
||||
import net.montoyo.wd.utilities.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public final class JSQueryDispatcher {
|
||||
|
||||
private static final class QueryData {
|
||||
|
||||
private final IBrowser browser;
|
||||
private final String query;
|
||||
private final String args;
|
||||
private final IJSQueryCallback callback;
|
||||
|
||||
private QueryData(IBrowser b, String q, String a, IJSQueryCallback cb) {
|
||||
browser = b;
|
||||
query = q;
|
||||
args = a;
|
||||
callback = cb;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static final class ServerQuery {
|
||||
|
||||
private static int lastId = 0;
|
||||
|
||||
private final TileEntityScreen tes;
|
||||
private final BlockSide side;
|
||||
private final IJSQueryCallback callback;
|
||||
private final int id;
|
||||
|
||||
private ServerQuery(TileEntityScreen t, BlockSide s, IJSQueryCallback cb) {
|
||||
tes = t;
|
||||
side = s;
|
||||
callback = cb;
|
||||
id = lastId++;
|
||||
}
|
||||
|
||||
public TileEntityScreen getTileEntity() {
|
||||
return tes;
|
||||
}
|
||||
|
||||
public BlockSide getSide() {
|
||||
return side;
|
||||
}
|
||||
|
||||
public TileEntityScreen.Screen getScreen() {
|
||||
return tes.getScreen(side);
|
||||
}
|
||||
|
||||
public void success(String resp) {
|
||||
callback.success(resp);
|
||||
}
|
||||
|
||||
public void error(int errId, String errStr) {
|
||||
callback.failure(errId, errStr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final ClientProxy proxy;
|
||||
private final ArrayDeque<QueryData> queue = new ArrayDeque<>();
|
||||
private final ClientProxy.ScreenSidePair lookupResult = new ClientProxy.ScreenSidePair();
|
||||
private final HashMap<String, IScreenQueryHandler> handlers = new HashMap<>();
|
||||
private final ArrayList<ServerQuery> serverQueries = new ArrayList<>();
|
||||
private final Minecraft mc = Minecraft.getInstance();
|
||||
|
||||
public JSQueryDispatcher(ClientProxy proxy) {
|
||||
this.proxy = proxy;
|
||||
registerDefaults();
|
||||
}
|
||||
|
||||
public void enqueueQuery(IBrowser b, String q, String a, IJSQueryCallback cb) {
|
||||
synchronized(queue) {
|
||||
queue.offer(new QueryData(b, q, a, cb));
|
||||
}
|
||||
}
|
||||
|
||||
public void handleQueries() {
|
||||
while(true) {
|
||||
QueryData next;
|
||||
synchronized(queue) {
|
||||
next = queue.poll();
|
||||
}
|
||||
|
||||
if(next == null)
|
||||
break;
|
||||
|
||||
if(proxy.findScreenFromBrowser(next.browser, lookupResult)) {
|
||||
Object[] args = (next.args == null) ? new Object[0] : parseArgs(next.args);
|
||||
|
||||
if(args == null)
|
||||
next.callback.failure(400, "Malformed request parameters");
|
||||
else {
|
||||
try {
|
||||
handlers.get(next.query).handleQuery(next.callback, lookupResult.tes, lookupResult.side, args);
|
||||
} catch(Throwable t) {
|
||||
Log.warningEx("Could not execute JS query %s(%s)", t, next.query, (next.args == null) ? "" : next.args);
|
||||
next.callback.failure(500, "Internal error");
|
||||
}
|
||||
}
|
||||
} else
|
||||
next.callback.failure(403, "A screen is required");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canHandleQuery(String q) {
|
||||
return handlers.containsKey(q);
|
||||
}
|
||||
|
||||
private static Object[] parseArgs(String args) {
|
||||
ArrayList<String> array = new ArrayList<>();
|
||||
int lastIdx = 0;
|
||||
boolean inString = false;
|
||||
boolean escape = false;
|
||||
boolean hadString = false;
|
||||
|
||||
for(int i = 0; i < args.length(); i++) {
|
||||
char chr = args.charAt(i);
|
||||
|
||||
if(inString) {
|
||||
if(escape)
|
||||
escape = false;
|
||||
else {
|
||||
if(chr == '\"')
|
||||
inString = false;
|
||||
else if(chr == '\\')
|
||||
escape = true;
|
||||
}
|
||||
} else if(chr == '\"') {
|
||||
if(hadString)
|
||||
return null;
|
||||
|
||||
inString = true;
|
||||
hadString = true;
|
||||
} else if(chr == ',') {
|
||||
array.add(args.substring(lastIdx, i).trim());
|
||||
lastIdx = i + 1;
|
||||
hadString = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(inString)
|
||||
return null; //Non terminated string
|
||||
|
||||
array.add(args.substring(lastIdx).trim());
|
||||
Object[] ret = new Object[array.size()];
|
||||
|
||||
for(int i = 0; i < ret.length; i++) {
|
||||
String str = array.get(i);
|
||||
if(str.isEmpty())
|
||||
return null; //Nah...
|
||||
|
||||
if(str.charAt(0) == '\"') //String
|
||||
ret[i] = str.substring(1, str.length() - 1);
|
||||
else {
|
||||
try {
|
||||
ret[i] = Double.parseDouble(str);
|
||||
} catch(NumberFormatException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void register(String query, IScreenQueryHandler handler) {
|
||||
handlers.put(query.toLowerCase(), handler);
|
||||
}
|
||||
|
||||
public ServerQuery fulfillQuery(int id) {
|
||||
int toRemove = -1;
|
||||
|
||||
for(int i = 0; i < serverQueries.size(); i++) {
|
||||
ServerQuery sq = serverQueries.get(i);
|
||||
|
||||
if(sq.id == id) {
|
||||
toRemove = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(toRemove < 0)
|
||||
return null;
|
||||
else
|
||||
return serverQueries.remove(toRemove);
|
||||
}
|
||||
|
||||
private void makeServerQuery(TileEntityScreen tes, BlockSide side, IJSQueryCallback cb, JSServerRequest type, Object ... data) {
|
||||
ServerQuery ret = new ServerQuery(tes, side, cb);
|
||||
serverQueries.add(ret);
|
||||
|
||||
WDNetworkRegistry.INSTANCE.sendToServer(C2SMessageScreenCtrl.jsRequest(tes, side, ret.id, type, data));
|
||||
}
|
||||
|
||||
private void registerDefaults() {
|
||||
VideoType.registerQueries(this);
|
||||
|
||||
register("GetSize", (cb, tes, side, args) -> {
|
||||
Vector2i size = tes.getScreen(side).size;
|
||||
cb.success("{\"x\":" + size.x + ",\"y\":" + size.y + "}");
|
||||
});
|
||||
|
||||
register("GetRedstoneAt", (cb, tes, side, args) -> {
|
||||
if(!tes.hasUpgrade(side, DefaultUpgrade.REDINPUT)) {
|
||||
cb.failure(403, "Missing upgrade");
|
||||
return;
|
||||
}
|
||||
|
||||
if(args.length == 2 && args[0] instanceof Double && args[1] instanceof Double) {
|
||||
TileEntityScreen.Screen scr = tes.getScreen(side);
|
||||
int x = ((Double) args[0]).intValue();
|
||||
int y = ((Double) args[1]).intValue();
|
||||
|
||||
if(x < 0 || x >= scr.size.x || y < 0 || y >= scr.size.y)
|
||||
cb.failure(403, "Out of range");
|
||||
else {
|
||||
BlockPos bpos = (new Vector3i(tes.getBlockPos())).addMul(side.right, x).addMul(side.up, y).toBlock();
|
||||
int level = tes.getLevel().getBlockState(bpos).getValue(BlockScreen.emitting) ? 0 : tes.getLevel().getSignal(bpos, Direction.values()[side.reverse().ordinal()]);
|
||||
cb.success("{\"level\":" + level + "}");
|
||||
}
|
||||
} else
|
||||
cb.failure(400, "Wrong arguments");
|
||||
});
|
||||
|
||||
register("GetRedstoneArray", (cb, tes, side, args) -> {
|
||||
if(tes.hasUpgrade(side, DefaultUpgrade.REDINPUT)) {
|
||||
final Direction facing = Direction.values()[side.reverse().ordinal()];
|
||||
final StringJoiner resp = new StringJoiner(",", "{\"levels\":[", "]}");
|
||||
|
||||
tes.forEachScreenBlocks(side, bp -> {
|
||||
if(tes.getLevel().getBlockState(bp).getValue(BlockScreen.emitting))
|
||||
resp.add("0");
|
||||
else
|
||||
resp.add("" + tes.getLevel().getSignal(bp, facing));
|
||||
});
|
||||
|
||||
cb.success(resp.toString());
|
||||
} else
|
||||
cb.failure(403, "Missing upgrade");
|
||||
});
|
||||
|
||||
register("ClearRedstone", (cb, tes, side, args) -> {
|
||||
if(tes.hasUpgrade(side, DefaultUpgrade.REDOUTPUT)) {
|
||||
if(tes.getScreen(side).owner.uuid.equals(mc.player.getGameProfile().getId()))
|
||||
makeServerQuery(tes, side, cb, JSServerRequest.CLEAR_REDSTONE);
|
||||
else
|
||||
cb.success("{\"status\":\"notOwner\"}");
|
||||
} else
|
||||
cb.failure(403, "Missing upgrade");
|
||||
});
|
||||
|
||||
register("SetRedstoneAt", (cb, tes, side, args) -> {
|
||||
if(args.length != 3 || !Arrays.stream(args).allMatch((obj) -> obj instanceof Double)) {
|
||||
cb.failure(400, "Wrong arguments");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!tes.hasUpgrade(side, DefaultUpgrade.REDOUTPUT)) {
|
||||
cb.failure(403, "Missing upgrade");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!tes.getScreen(side).owner.uuid.equals(mc.player.getGameProfile().getId())) {
|
||||
cb.success("{\"status\":\"notOwner\"}");
|
||||
return;
|
||||
}
|
||||
|
||||
int x = ((Double) args[0]).intValue();
|
||||
int y = ((Double) args[1]).intValue();
|
||||
boolean state = ((Double) args[2]) > 0.0;
|
||||
|
||||
Vector2i size = tes.getScreen(side).size;
|
||||
if(x < 0 || x >= size.x || y < 0 || y >= size.y) {
|
||||
cb.failure(403, "Out of range");
|
||||
return;
|
||||
}
|
||||
|
||||
makeServerQuery(tes, side, cb, JSServerRequest.SET_REDSTONE_AT, x, y, state);
|
||||
});
|
||||
|
||||
register("IsEmitting", (cb, tes, side, args) -> {
|
||||
if(!tes.hasUpgrade(side, DefaultUpgrade.REDOUTPUT)) {
|
||||
cb.failure(403, "Missing upgrade");
|
||||
return;
|
||||
}
|
||||
|
||||
if(args.length == 2 && args[0] instanceof Double && args[1] instanceof Double) {
|
||||
TileEntityScreen.Screen scr = tes.getScreen(side);
|
||||
int x = ((Double) args[0]).intValue();
|
||||
int y = ((Double) args[1]).intValue();
|
||||
|
||||
if(x < 0 || x >= scr.size.x || y < 0 || y >= scr.size.y)
|
||||
cb.failure(403, "Out of range");
|
||||
else {
|
||||
BlockPos bpos = (new Vector3i(tes.getBlockPos())).addMul(side.right, x).addMul(side.up, y).toBlock();
|
||||
boolean e = tes.getLevel().getBlockState(bpos).getValue(BlockScreen.emitting);
|
||||
cb.success("{\"emitting\":" + (e ? "true" : "false") + "}");
|
||||
}
|
||||
} else
|
||||
cb.failure(400, "Wrong arguments");
|
||||
});
|
||||
|
||||
register("GetEmissionArray", (cb, tes, side, args) -> {
|
||||
if(tes.hasUpgrade(side, DefaultUpgrade.REDOUTPUT)) {
|
||||
final StringJoiner resp = new StringJoiner(",", "{\"emission\":[", "]}");
|
||||
tes.forEachScreenBlocks(side, bp -> resp.add(tes.getLevel().getBlockState(bp).getValue(BlockScreen.emitting) ? "1" : "0"));
|
||||
cb.success(resp.toString());
|
||||
} else
|
||||
cb.failure(403, "Missing upgrade");
|
||||
});
|
||||
|
||||
register("GetLocation", (cb, tes, side, args) -> {
|
||||
if(!tes.hasUpgrade(side, DefaultUpgrade.GPS)) {
|
||||
cb.failure(403, "Missing upgrade");
|
||||
return;
|
||||
}
|
||||
|
||||
BlockPos bp = tes.getBlockPos();
|
||||
cb.success("{\"x\":" + bp.getX() + ",\"y\":" + bp.getY() + ",\"z\":" + bp.getZ() + ",\"side\":\"" + side + "\"}");
|
||||
});
|
||||
|
||||
register("GetUpgrades", (cb, tes, side, args) -> {
|
||||
final StringBuilder sb = new StringBuilder("{\"upgrades\":[");
|
||||
final ArrayList<ItemStack> upgrades = tes.getScreen(side).upgrades;
|
||||
|
||||
for(int i = 0; i < upgrades.size(); i++) {
|
||||
if(i > 0)
|
||||
sb.append(',');
|
||||
|
||||
sb.append('\"');
|
||||
sb.append(Util.addSlashes(((IUpgrade) upgrades.get(i).getItem()).getJSName(upgrades.get(i))));
|
||||
sb.append('\"');
|
||||
}
|
||||
|
||||
cb.success(sb.append("]}").toString());
|
||||
});
|
||||
|
||||
register("IsOwner", (cb, tes, side, args) -> {
|
||||
boolean res = (tes.getScreen(side).owner != null && tes.getScreen(side).owner.uuid.equals(mc.player.getGameProfile().getId()));
|
||||
cb.success("{\"isOwner\":" + (res ? "true}" : "false}"));
|
||||
});
|
||||
|
||||
register("GetRotation", (cb, tes, side, args) -> cb.success("{\"rotation\":" + tes.getScreen(side).rotation.ordinal() + "}"));
|
||||
register("GetSide", (cb, tes, side, args) -> cb.success("{\"side\":" + tes.getScreen(side).side.ordinal() + "}"));
|
||||
}
|
||||
|
||||
}
|
||||
///*
|
||||
// * Copyright (C) 2018 BARBOTIN Nicolas
|
||||
// */
|
||||
//
|
||||
//package net.montoyo.wd.client;
|
||||
//
|
||||
//import net.minecraft.client.Minecraft;
|
||||
//import net.minecraft.core.BlockPos;
|
||||
//import net.minecraft.core.Direction;
|
||||
//import net.minecraft.world.item.ItemStack;
|
||||
//import net.minecraftforge.api.distmarker.Dist;
|
||||
//import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
//import net.montoyo.wd.block.BlockScreen;
|
||||
//import net.montoyo.wd.core.DefaultUpgrade;
|
||||
//import net.montoyo.wd.core.IScreenQueryHandler;
|
||||
//import net.montoyo.wd.core.IUpgrade;
|
||||
//import net.montoyo.wd.core.JSServerRequest;
|
||||
//import net.montoyo.wd.entity.TileEntityScreen;
|
||||
//import net.montoyo.wd.net.WDNetworkRegistry;
|
||||
//import net.montoyo.wd.net.server_bound.C2SMessageScreenCtrl;
|
||||
//import net.montoyo.wd.utilities.*;
|
||||
//
|
||||
//import java.util.*;
|
||||
//
|
||||
//@OnlyIn(Dist.CLIENT)
|
||||
//public final class JSQueryDispatcher {
|
||||
//
|
||||
// private static final class QueryData {
|
||||
//
|
||||
// private final IBrowser browser;
|
||||
// private final String query;
|
||||
// private final String args;
|
||||
// private final IJSQueryCallback callback;
|
||||
//
|
||||
// private QueryData(IBrowser b, String q, String a, IJSQueryCallback cb) {
|
||||
// browser = b;
|
||||
// query = q;
|
||||
// args = a;
|
||||
// callback = cb;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public static final class ServerQuery {
|
||||
//
|
||||
// private static int lastId = 0;
|
||||
//
|
||||
// private final TileEntityScreen tes;
|
||||
// private final BlockSide side;
|
||||
// private final IJSQueryCallback callback;
|
||||
// private final int id;
|
||||
//
|
||||
// private ServerQuery(TileEntityScreen t, BlockSide s, IJSQueryCallback cb) {
|
||||
// tes = t;
|
||||
// side = s;
|
||||
// callback = cb;
|
||||
// id = lastId++;
|
||||
// }
|
||||
//
|
||||
// public TileEntityScreen getTileEntity() {
|
||||
// return tes;
|
||||
// }
|
||||
//
|
||||
// public BlockSide getSide() {
|
||||
// return side;
|
||||
// }
|
||||
//
|
||||
// public TileEntityScreen.Screen getScreen() {
|
||||
// return tes.getScreen(side);
|
||||
// }
|
||||
//
|
||||
// public void success(String resp) {
|
||||
// callback.success(resp);
|
||||
// }
|
||||
//
|
||||
// public void error(int errId, String errStr) {
|
||||
// callback.failure(errId, errStr);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// private final ClientProxy proxy;
|
||||
// private final ArrayDeque<QueryData> queue = new ArrayDeque<>();
|
||||
// private final ClientProxy.ScreenSidePair lookupResult = new ClientProxy.ScreenSidePair();
|
||||
// private final HashMap<String, IScreenQueryHandler> handlers = new HashMap<>();
|
||||
// private final ArrayList<ServerQuery> serverQueries = new ArrayList<>();
|
||||
// private final Minecraft mc = Minecraft.getInstance();
|
||||
//
|
||||
// public JSQueryDispatcher(ClientProxy proxy) {
|
||||
// this.proxy = proxy;
|
||||
// registerDefaults();
|
||||
// }
|
||||
//
|
||||
// public void enqueueQuery(IBrowser b, String q, String a, IJSQueryCallback cb) {
|
||||
// synchronized(queue) {
|
||||
// queue.offer(new QueryData(b, q, a, cb));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void handleQueries() {
|
||||
// while(true) {
|
||||
// QueryData next;
|
||||
// synchronized(queue) {
|
||||
// next = queue.poll();
|
||||
// }
|
||||
//
|
||||
// if(next == null)
|
||||
// break;
|
||||
//
|
||||
// if(proxy.findScreenFromBrowser(next.browser, lookupResult)) {
|
||||
// Object[] args = (next.args == null) ? new Object[0] : parseArgs(next.args);
|
||||
//
|
||||
// if(args == null)
|
||||
// next.callback.failure(400, "Malformed request parameters");
|
||||
// else {
|
||||
// try {
|
||||
// handlers.get(next.query).handleQuery(next.callback, lookupResult.tes, lookupResult.side, args);
|
||||
// } catch(Throwable t) {
|
||||
// Log.warningEx("Could not execute JS query %s(%s)", t, next.query, (next.args == null) ? "" : next.args);
|
||||
// next.callback.failure(500, "Internal error");
|
||||
// }
|
||||
// }
|
||||
// } else
|
||||
// next.callback.failure(403, "A screen is required");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public boolean canHandleQuery(String q) {
|
||||
// return handlers.containsKey(q);
|
||||
// }
|
||||
//
|
||||
// private static Object[] parseArgs(String args) {
|
||||
// ArrayList<String> array = new ArrayList<>();
|
||||
// int lastIdx = 0;
|
||||
// boolean inString = false;
|
||||
// boolean escape = false;
|
||||
// boolean hadString = false;
|
||||
//
|
||||
// for(int i = 0; i < args.length(); i++) {
|
||||
// char chr = args.charAt(i);
|
||||
//
|
||||
// if(inString) {
|
||||
// if(escape)
|
||||
// escape = false;
|
||||
// else {
|
||||
// if(chr == '\"')
|
||||
// inString = false;
|
||||
// else if(chr == '\\')
|
||||
// escape = true;
|
||||
// }
|
||||
// } else if(chr == '\"') {
|
||||
// if(hadString)
|
||||
// return null;
|
||||
//
|
||||
// inString = true;
|
||||
// hadString = true;
|
||||
// } else if(chr == ',') {
|
||||
// array.add(args.substring(lastIdx, i).trim());
|
||||
// lastIdx = i + 1;
|
||||
// hadString = false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(inString)
|
||||
// return null; //Non terminated string
|
||||
//
|
||||
// array.add(args.substring(lastIdx).trim());
|
||||
// Object[] ret = new Object[array.size()];
|
||||
//
|
||||
// for(int i = 0; i < ret.length; i++) {
|
||||
// String str = array.get(i);
|
||||
// if(str.isEmpty())
|
||||
// return null; //Nah...
|
||||
//
|
||||
// if(str.charAt(0) == '\"') //String
|
||||
// ret[i] = str.substring(1, str.length() - 1);
|
||||
// else {
|
||||
// try {
|
||||
// ret[i] = Double.parseDouble(str);
|
||||
// } catch(NumberFormatException ex) {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return ret;
|
||||
// }
|
||||
//
|
||||
// public void register(String query, IScreenQueryHandler handler) {
|
||||
// handlers.put(query.toLowerCase(), handler);
|
||||
// }
|
||||
//
|
||||
// public ServerQuery fulfillQuery(int id) {
|
||||
// int toRemove = -1;
|
||||
//
|
||||
// for(int i = 0; i < serverQueries.size(); i++) {
|
||||
// ServerQuery sq = serverQueries.get(i);
|
||||
//
|
||||
// if(sq.id == id) {
|
||||
// toRemove = i;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(toRemove < 0)
|
||||
// return null;
|
||||
// else
|
||||
// return serverQueries.remove(toRemove);
|
||||
// }
|
||||
//
|
||||
// private void makeServerQuery(TileEntityScreen tes, BlockSide side, IJSQueryCallback cb, JSServerRequest type, Object ... data) {
|
||||
// ServerQuery ret = new ServerQuery(tes, side, cb);
|
||||
// serverQueries.add(ret);
|
||||
//
|
||||
// WDNetworkRegistry.INSTANCE.sendToServer(C2SMessageScreenCtrl.jsRequest(tes, side, ret.id, type, data));
|
||||
// }
|
||||
//
|
||||
// private void registerDefaults() {
|
||||
// VideoType.registerQueries(this);
|
||||
//
|
||||
// register("GetSize", (cb, tes, side, args) -> {
|
||||
// Vector2i size = tes.getScreen(side).size;
|
||||
// cb.success("{\"x\":" + size.x + ",\"y\":" + size.y + "}");
|
||||
// });
|
||||
//
|
||||
// register("GetRedstoneAt", (cb, tes, side, args) -> {
|
||||
// if(!tes.hasUpgrade(side, DefaultUpgrade.REDINPUT)) {
|
||||
// cb.failure(403, "Missing upgrade");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if(args.length == 2 && args[0] instanceof Double && args[1] instanceof Double) {
|
||||
// TileEntityScreen.Screen scr = tes.getScreen(side);
|
||||
// int x = ((Double) args[0]).intValue();
|
||||
// int y = ((Double) args[1]).intValue();
|
||||
//
|
||||
// if(x < 0 || x >= scr.size.x || y < 0 || y >= scr.size.y)
|
||||
// cb.failure(403, "Out of range");
|
||||
// else {
|
||||
// BlockPos bpos = (new Vector3i(tes.getBlockPos())).addMul(side.right, x).addMul(side.up, y).toBlock();
|
||||
// int level = tes.getLevel().getBlockState(bpos).getValue(BlockScreen.emitting) ? 0 : tes.getLevel().getSignal(bpos, Direction.values()[side.reverse().ordinal()]);
|
||||
// cb.success("{\"level\":" + level + "}");
|
||||
// }
|
||||
// } else
|
||||
// cb.failure(400, "Wrong arguments");
|
||||
// });
|
||||
//
|
||||
// register("GetRedstoneArray", (cb, tes, side, args) -> {
|
||||
// if(tes.hasUpgrade(side, DefaultUpgrade.REDINPUT)) {
|
||||
// final Direction facing = Direction.values()[side.reverse().ordinal()];
|
||||
// final StringJoiner resp = new StringJoiner(",", "{\"levels\":[", "]}");
|
||||
//
|
||||
// tes.forEachScreenBlocks(side, bp -> {
|
||||
// if(tes.getLevel().getBlockState(bp).getValue(BlockScreen.emitting))
|
||||
// resp.add("0");
|
||||
// else
|
||||
// resp.add("" + tes.getLevel().getSignal(bp, facing));
|
||||
// });
|
||||
//
|
||||
// cb.success(resp.toString());
|
||||
// } else
|
||||
// cb.failure(403, "Missing upgrade");
|
||||
// });
|
||||
//
|
||||
// register("ClearRedstone", (cb, tes, side, args) -> {
|
||||
// if(tes.hasUpgrade(side, DefaultUpgrade.REDOUTPUT)) {
|
||||
// if(tes.getScreen(side).owner.uuid.equals(mc.player.getGameProfile().getId()))
|
||||
// makeServerQuery(tes, side, cb, JSServerRequest.CLEAR_REDSTONE);
|
||||
// else
|
||||
// cb.success("{\"status\":\"notOwner\"}");
|
||||
// } else
|
||||
// cb.failure(403, "Missing upgrade");
|
||||
// });
|
||||
//
|
||||
// register("SetRedstoneAt", (cb, tes, side, args) -> {
|
||||
// if(args.length != 3 || !Arrays.stream(args).allMatch((obj) -> obj instanceof Double)) {
|
||||
// cb.failure(400, "Wrong arguments");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if(!tes.hasUpgrade(side, DefaultUpgrade.REDOUTPUT)) {
|
||||
// cb.failure(403, "Missing upgrade");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if(!tes.getScreen(side).owner.uuid.equals(mc.player.getGameProfile().getId())) {
|
||||
// cb.success("{\"status\":\"notOwner\"}");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// int x = ((Double) args[0]).intValue();
|
||||
// int y = ((Double) args[1]).intValue();
|
||||
// boolean state = ((Double) args[2]) > 0.0;
|
||||
//
|
||||
// Vector2i size = tes.getScreen(side).size;
|
||||
// if(x < 0 || x >= size.x || y < 0 || y >= size.y) {
|
||||
// cb.failure(403, "Out of range");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// makeServerQuery(tes, side, cb, JSServerRequest.SET_REDSTONE_AT, x, y, state);
|
||||
// });
|
||||
//
|
||||
// register("IsEmitting", (cb, tes, side, args) -> {
|
||||
// if(!tes.hasUpgrade(side, DefaultUpgrade.REDOUTPUT)) {
|
||||
// cb.failure(403, "Missing upgrade");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if(args.length == 2 && args[0] instanceof Double && args[1] instanceof Double) {
|
||||
// TileEntityScreen.Screen scr = tes.getScreen(side);
|
||||
// int x = ((Double) args[0]).intValue();
|
||||
// int y = ((Double) args[1]).intValue();
|
||||
//
|
||||
// if(x < 0 || x >= scr.size.x || y < 0 || y >= scr.size.y)
|
||||
// cb.failure(403, "Out of range");
|
||||
// else {
|
||||
// BlockPos bpos = (new Vector3i(tes.getBlockPos())).addMul(side.right, x).addMul(side.up, y).toBlock();
|
||||
// boolean e = tes.getLevel().getBlockState(bpos).getValue(BlockScreen.emitting);
|
||||
// cb.success("{\"emitting\":" + (e ? "true" : "false") + "}");
|
||||
// }
|
||||
// } else
|
||||
// cb.failure(400, "Wrong arguments");
|
||||
// });
|
||||
//
|
||||
// register("GetEmissionArray", (cb, tes, side, args) -> {
|
||||
// if(tes.hasUpgrade(side, DefaultUpgrade.REDOUTPUT)) {
|
||||
// final StringJoiner resp = new StringJoiner(",", "{\"emission\":[", "]}");
|
||||
// tes.forEachScreenBlocks(side, bp -> resp.add(tes.getLevel().getBlockState(bp).getValue(BlockScreen.emitting) ? "1" : "0"));
|
||||
// cb.success(resp.toString());
|
||||
// } else
|
||||
// cb.failure(403, "Missing upgrade");
|
||||
// });
|
||||
//
|
||||
// register("GetLocation", (cb, tes, side, args) -> {
|
||||
// if(!tes.hasUpgrade(side, DefaultUpgrade.GPS)) {
|
||||
// cb.failure(403, "Missing upgrade");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// BlockPos bp = tes.getBlockPos();
|
||||
// cb.success("{\"x\":" + bp.getX() + ",\"y\":" + bp.getY() + ",\"z\":" + bp.getZ() + ",\"side\":\"" + side + "\"}");
|
||||
// });
|
||||
//
|
||||
// register("GetUpgrades", (cb, tes, side, args) -> {
|
||||
// final StringBuilder sb = new StringBuilder("{\"upgrades\":[");
|
||||
// final ArrayList<ItemStack> upgrades = tes.getScreen(side).upgrades;
|
||||
//
|
||||
// for(int i = 0; i < upgrades.size(); i++) {
|
||||
// if(i > 0)
|
||||
// sb.append(',');
|
||||
//
|
||||
// sb.append('\"');
|
||||
// sb.append(Util.addSlashes(((IUpgrade) upgrades.get(i).getItem()).getJSName(upgrades.get(i))));
|
||||
// sb.append('\"');
|
||||
// }
|
||||
//
|
||||
// cb.success(sb.append("]}").toString());
|
||||
// });
|
||||
//
|
||||
// register("IsOwner", (cb, tes, side, args) -> {
|
||||
// boolean res = (tes.getScreen(side).owner != null && tes.getScreen(side).owner.uuid.equals(mc.player.getGameProfile().getId()));
|
||||
// cb.success("{\"isOwner\":" + (res ? "true}" : "false}"));
|
||||
// });
|
||||
//
|
||||
// register("GetRotation", (cb, tes, side, args) -> cb.success("{\"rotation\":" + tes.getScreen(side).rotation.ordinal() + "}"));
|
||||
// register("GetSide", (cb, tes, side, args) -> cb.success("{\"side\":" + tes.getScreen(side).side.ordinal() + "}"));
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ import net.montoyo.wd.utilities.Log;
|
|||
import net.montoyo.wd.utilities.TypeData;
|
||||
import net.montoyo.wd.utilities.Util;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.vivecraft.gameplay.VRPlayer;
|
||||
import org.vivecraft.gameplay.screenhandlers.KeyboardHandler;
|
||||
//import org.vivecraft.gameplay.VRPlayer;
|
||||
//import org.vivecraft.gameplay.screenhandlers.KeyboardHandler;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Method;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ package net.montoyo.wd.client.gui;
|
|||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.montoyo.mcef.api.API;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
import net.montoyo.wd.client.ClientProxy;
|
||||
import net.montoyo.wd.client.gui.controls.Button;
|
||||
|
|
@ -53,18 +52,18 @@ public class GuiRedstoneCtrl extends WDScreen {
|
|||
tfFallingEdge.setText(fallingEdgeURL);
|
||||
}
|
||||
|
||||
@GuiSubscribe
|
||||
public void onClick(Button.ClickEvent ev) {
|
||||
if(ev.getSource() == btnOk) {
|
||||
API mcef = ((ClientProxy) WebDisplays.PROXY).getMCEF();
|
||||
|
||||
String rising = mcef.punycode(Util.addProtocol(tfRisingEdge.getText()));
|
||||
String falling = mcef.punycode(Util.addProtocol(tfFallingEdge.getText()));
|
||||
WDNetworkRegistry.INSTANCE.sendToServer(new C2SMessageRedstoneCtrl(pos, rising, falling));
|
||||
}
|
||||
|
||||
minecraft.setScreen(null);
|
||||
}
|
||||
// @GuiSubscribe
|
||||
// public void onClick(Button.ClickEvent ev) {
|
||||
// if(ev.getSource() == btnOk) {
|
||||
// API mcef = ((ClientProxy) WebDisplays.PROXY).getMCEF();
|
||||
//
|
||||
// String rising = mcef.punycode(Util.addProtocol(tfRisingEdge.getText()));
|
||||
// String falling = mcef.punycode(Util.addProtocol(tfFallingEdge.getText()));
|
||||
// WDNetworkRegistry.INSTANCE.sendToServer(new C2SMessageRedstoneCtrl(pos, rising, falling));
|
||||
// }
|
||||
//
|
||||
// minecraft.setScreen(null);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public boolean isForBlock(BlockPos bp, BlockSide side) {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import com.mojang.blaze3d.pipeline.RenderTarget;
|
|||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
|
|
@ -18,9 +17,9 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
|||
import net.montoyo.wd.client.gui.WDScreen;
|
||||
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
||||
import net.montoyo.wd.utilities.Bounds;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
|
||||
import static org.lwjgl.opengl.GL11.glEnable;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract class Control {
|
||||
|
|
@ -120,7 +119,8 @@ public abstract class Control {
|
|||
int b = color & 0xFF;
|
||||
|
||||
RenderSystem.setShaderColor(((float) r) / 255.f, ((float) g) / 255.f, ((float) b) / 255.f, ((float) a) / 255.f);
|
||||
RenderSystem.disableTexture();
|
||||
// RenderSystem.disableTexture();
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
|
|
@ -132,7 +132,8 @@ public abstract class Control {
|
|||
tessellator.end();
|
||||
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.enableTexture();glEnable(GL_TEXTURE_2D);
|
||||
// RenderSystem.enableTexture();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
public void fillTexturedRect(PoseStack poseStack, int x, int y, int w, int h, double u1, double v1, double u2, double v2) {
|
||||
|
|
@ -179,7 +180,8 @@ public abstract class Control {
|
|||
int b = color & 0xFF;
|
||||
|
||||
RenderSystem.setShaderColor(((float) r) / 255.f, ((float) g) / 255.f, ((float) b) / 255.f, ((float) a) / 255.f);
|
||||
RenderSystem.enableTexture();
|
||||
// RenderSystem.enableTexture();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
|
|
@ -210,14 +212,15 @@ public abstract class Control {
|
|||
tessellator.end();
|
||||
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.enableTexture();
|
||||
// RenderSystem.enableTexture();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
public PoseStack beginFramebuffer(RenderTarget fbo, float vpW, float vpH) {
|
||||
fbo.bindWrite(true);
|
||||
|
||||
RenderSystem.backupProjectionMatrix();
|
||||
RenderSystem.setProjectionMatrix(Matrix4f.orthographic(0.0f, vpW, vpH, 0.0f, -1.0f,1.0f));
|
||||
RenderSystem.setProjectionMatrix(new Matrix4f().ortho(0.0f, vpW, vpH, 0.0f, -1.0f,1.0f), VertexSorting.ORTHOGRAPHIC_Z);
|
||||
|
||||
PoseStack poseStack = RenderSystem.getModelViewStack();
|
||||
poseStack.pushPose();
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ package net.montoyo.wd.client.renderers;
|
|||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
|
|
@ -20,6 +18,10 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
|||
import net.montoyo.wd.client.ClientProxy;
|
||||
import net.montoyo.wd.init.ItemInit;
|
||||
import net.montoyo.wd.item.ItemLaserPointer;
|
||||
import org.joml.Matrix4f;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import static com.mojang.math.Axis.*;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public final class LaserPointerRenderer implements IItemRenderer {
|
||||
|
|
@ -45,7 +47,8 @@ public final class LaserPointerRenderer implements IItemRenderer {
|
|||
@Override
|
||||
public boolean render(PoseStack poseStack, ItemStack is, float handSideSign, float swingProgress, float equipProgress, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
RenderSystem.disableCull();
|
||||
RenderSystem.disableTexture();
|
||||
// RenderSystem.disableTexture();
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.enableBlend();
|
||||
|
||||
|
|
@ -61,12 +64,12 @@ public final class LaserPointerRenderer implements IItemRenderer {
|
|||
poseStack.pushPose();
|
||||
poseStack.translate(handSideSign * -0.4f * sinSqrtSwingProg1, (float) (0.2f * Math.sin(sqrtSwingProg * PI * 2.0f)), (float) (-0.2f * Math.sin(swingProgress * PI)));
|
||||
poseStack.translate(handSideSign * 0.56f, -0.52f - equipProgress * 0.6f, -0.72f);
|
||||
poseStack.mulPose(Vector3f.YP.rotationDegrees((float) (handSideSign * (45.0f - Math.sin(swingProgress * swingProgress * PI) * 20.0f))));
|
||||
poseStack.mulPose(Vector3f.ZP.rotationDegrees(handSideSign * sinSqrtSwingProg1 * -20.0f));
|
||||
poseStack.mulPose(Vector3f.XP.rotationDegrees(sinSqrtSwingProg1 * -80.0f));
|
||||
poseStack.mulPose(Vector3f.YP.rotationDegrees(handSideSign * -30.0f));
|
||||
poseStack.mulPose(YP.rotationDegrees((float) (handSideSign * (45.0f - Math.sin(swingProgress * swingProgress * PI) * 20.0f))));
|
||||
poseStack.mulPose(ZP.rotationDegrees(handSideSign * sinSqrtSwingProg1 * -20.0f));
|
||||
poseStack.mulPose(XP.rotationDegrees(sinSqrtSwingProg1 * -80.0f));
|
||||
poseStack.mulPose(YP.rotationDegrees(handSideSign * -30.0f));
|
||||
poseStack.translate(0.0f, 0.2f, 0.0f);
|
||||
poseStack.mulPose(Vector3f.XP.rotationDegrees(10.0f));
|
||||
poseStack.mulPose(XP.rotationDegrees(10.0f));
|
||||
poseStack.scale(1.0f / 16.0f, 1.0f / 16.0f, 1.0f / 16.0f);
|
||||
var matrix = poseStack.last().pose();
|
||||
|
||||
|
|
@ -98,7 +101,8 @@ public final class LaserPointerRenderer implements IItemRenderer {
|
|||
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.enableTexture(); //Fix for shitty minecraft fire
|
||||
// RenderSystem.enableTexture(); //Fix for shitty minecraft fire
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
RenderSystem.enableCull();
|
||||
poseStack.popPose();
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ package net.montoyo.wd.client.renderers;
|
|||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
|
@ -22,6 +21,8 @@ import net.montoyo.wd.client.ClientProxy;
|
|||
import net.montoyo.wd.config.ClientConfig;
|
||||
import net.montoyo.wd.item.ItemMinePad2;
|
||||
|
||||
import static com.mojang.math.Axis.*;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public final class MinePadRenderer implements IItemRenderer {
|
||||
private static final float PI = (float) Math.PI;
|
||||
|
|
@ -76,18 +77,18 @@ public final class MinePadRenderer implements IItemRenderer {
|
|||
stack.pushPose();
|
||||
stack.translate(handSideSign * -0.4f * sinSqrtSwingProg1, 0.2f * sinSqrtSwingProg2, -0.2f * sinSwingProg1);
|
||||
stack.translate(handSideSign * 0.56f, -0.52f - equipProgress * 0.6f, -0.72f);
|
||||
stack.mulPose(Vector3f.YP.rotationDegrees(handSideSign * (45.0f - sinSwingProg2 * 20.0f)));
|
||||
stack.mulPose(Vector3f.ZP.rotationDegrees(handSideSign * sinSqrtSwingProg1 * -20.0f));
|
||||
stack.mulPose(Vector3f.XP.rotationDegrees(sinSqrtSwingProg1 * -80.0f));
|
||||
stack.mulPose(Vector3f.YP.rotationDegrees(handSideSign * -45.0f));
|
||||
stack.mulPose(YP.rotationDegrees(handSideSign * (45.0f - sinSwingProg2 * 20.0f)));
|
||||
stack.mulPose(ZP.rotationDegrees(handSideSign * sinSqrtSwingProg1 * -20.0f));
|
||||
stack.mulPose(XP.rotationDegrees(sinSqrtSwingProg1 * -80.0f));
|
||||
stack.mulPose(YP.rotationDegrees(handSideSign * -45.0f));
|
||||
|
||||
if (sideHold) {
|
||||
stack.translate(0.0f, 0.0f, -0.2f);
|
||||
stack.mulPose(Vector3f.YP.rotationDegrees(20.0f * -handSideSign));
|
||||
stack.mulPose(YP.rotationDegrees(20.0f * -handSideSign));
|
||||
float total = 0.475f;
|
||||
float off = -0.025f; // gotta love magic numbers
|
||||
stack.translate(-(total - off) + (off * handSideSign), -0.1f, 0.0f);
|
||||
stack.mulPose(Vector3f.ZP.rotationDegrees(1.0f));
|
||||
stack.mulPose(ZP.rotationDegrees(1.0f));
|
||||
} else if (handSideSign >= 0) // right hand
|
||||
stack.translate(-1.065f, 0.0f, 0.0f);
|
||||
else // left hand
|
||||
|
|
@ -113,7 +114,7 @@ public final class MinePadRenderer implements IItemRenderer {
|
|||
|
||||
stack.translate(0.063f, 0.28f, 0.001f);
|
||||
RenderSystem.setShaderTexture(0, tex);
|
||||
pd.view.draw(stack, x1, y1, x2, y2);
|
||||
// pd.view.draw(stack, x1, y1, x2, y2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -129,13 +130,13 @@ public final class MinePadRenderer implements IItemRenderer {
|
|||
float tz = -0.4f * sinSwingProg1;
|
||||
|
||||
stack.translate(handSideSign * (tx + 0.64000005f), ty - 0.6f - equipProgress * 0.6f, tz - 0.71999997f);
|
||||
stack.mulPose(Vector3f.YP.rotationDegrees(handSideSign * 45.0f));
|
||||
stack.mulPose(Vector3f.YP.rotationDegrees(handSideSign * sinSqrtSwingProg1 * 70.0f));
|
||||
stack.mulPose(Vector3f.ZP.rotationDegrees(handSideSign * sinSwingProg2 * -20.0f));
|
||||
stack.mulPose(YP.rotationDegrees(handSideSign * 45.0f));
|
||||
stack.mulPose(YP.rotationDegrees(handSideSign * sinSqrtSwingProg1 * 70.0f));
|
||||
stack.mulPose(ZP.rotationDegrees(handSideSign * sinSwingProg2 * -20.0f));
|
||||
stack.translate(-handSideSign, 3.6f, 3.5f);
|
||||
stack.mulPose(Vector3f.ZP.rotationDegrees(handSideSign * 120.0f));
|
||||
stack.mulPose(Vector3f.XP.rotationDegrees(200.0f));
|
||||
stack.mulPose(Vector3f.YP.rotationDegrees(handSideSign * -135.0f));
|
||||
stack.mulPose(ZP.rotationDegrees(handSideSign * 120.0f));
|
||||
stack.mulPose(XP.rotationDegrees(200.0f));
|
||||
stack.mulPose(YP.rotationDegrees(handSideSign * -135.0f));
|
||||
stack.translate(handSideSign * 5.6f, 0.0f, 0.0f);
|
||||
|
||||
PlayerRenderer playerRenderer = (PlayerRenderer) mc.getEntityRenderDispatcher().getRenderer(mc.player);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ package net.montoyo.wd.client.renderers;
|
|||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
|
|
@ -15,6 +14,7 @@ import net.minecraft.client.renderer.texture.OverlayTexture;
|
|||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public final class ModelMinePad {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
package net.montoyo.wd.client.renderers;
|
||||
|
||||
import com.cinemamod.mcef.MCEFBrowser;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
|
|
@ -14,8 +15,9 @@ import net.montoyo.wd.entity.TileEntityScreen;
|
|||
import net.montoyo.wd.utilities.Vector3f;
|
||||
import net.montoyo.wd.utilities.Vector3i;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import static com.mojang.math.Vector3f.*;
|
||||
import static com.mojang.math.Axis.*;
|
||||
|
||||
public class ScreenRenderer implements BlockEntityRenderer<TileEntityScreen> {
|
||||
public ScreenRenderer() {
|
||||
|
|
@ -38,7 +40,8 @@ public class ScreenRenderer implements BlockEntityRenderer<TileEntityScreen> {
|
|||
return;
|
||||
|
||||
//Disable lighting
|
||||
RenderSystem.enableTexture();
|
||||
// RenderSystem.enableTexture();
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
// RenderSystem.disableCull();
|
||||
RenderSystem.disableBlend();
|
||||
|
||||
|
|
@ -118,7 +121,7 @@ public class ScreenRenderer implements BlockEntityRenderer<TileEntityScreen> {
|
|||
//TODO: don't use tesselator
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
|
||||
RenderSystem._setShaderTexture(0, scr.browser.getTextureID());
|
||||
RenderSystem._setShaderTexture(0, ((MCEFBrowser) scr.browser).getRenderer().getTextureID());
|
||||
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
|
||||
builder.vertex(poseStack.last().pose(), -sw, -sh, 0.505f).uv(0.f, 1.f).color(1.f, 1.f, 1.f, 1.f).endVertex();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ package net.montoyo.wd.core;
|
|||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.advancements.CriterionTrigger;
|
||||
import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance;
|
||||
import net.minecraft.advancements.critereon.ContextAwarePredicate;
|
||||
import net.minecraft.advancements.critereon.DeserializationContext;
|
||||
import net.minecraft.advancements.critereon.EntityPredicate;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
|
@ -22,7 +23,7 @@ public class Criterion implements CriterionTrigger<Criterion.Instance> {
|
|||
|
||||
public static class Instance extends AbstractCriterionTriggerInstance {
|
||||
|
||||
public Instance(ResourceLocation id, EntityPredicate.Composite arg2) {
|
||||
public Instance(ResourceLocation id, ContextAwarePredicate arg2) {
|
||||
super(id, arg2);
|
||||
}
|
||||
}
|
||||
|
|
@ -60,7 +61,7 @@ public class Criterion implements CriterionTrigger<Criterion.Instance> {
|
|||
|
||||
@Override
|
||||
public @NotNull Instance createInstance(JsonObject json, DeserializationContext context) {
|
||||
return new Instance(id, EntityPredicate.Composite.fromJson(json, "instance", context));
|
||||
return new Instance(id, EntityPredicate.fromJson(json, "instance", context));
|
||||
}
|
||||
|
||||
public void trigger(PlayerAdvancements ply) {
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
* Copyright (C) 2018 BARBOTIN Nicolas
|
||||
*/
|
||||
|
||||
package net.montoyo.wd.core;
|
||||
|
||||
import net.montoyo.mcef.api.IJSQueryCallback;
|
||||
import net.montoyo.wd.entity.TileEntityScreen;
|
||||
import net.montoyo.wd.utilities.BlockSide;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public interface IScreenQueryHandler {
|
||||
|
||||
//args is an array of Doubles or Strings
|
||||
//The screen DOES exist, so scr.getScreen(side) is never null
|
||||
void handleQuery(@Nonnull IJSQueryCallback cb, @Nonnull TileEntityScreen scr, @Nonnull BlockSide side, @Nonnull Object[] args);
|
||||
|
||||
}
|
||||
///*
|
||||
// * Copyright (C) 2018 BARBOTIN Nicolas
|
||||
// */
|
||||
//
|
||||
//package net.montoyo.wd.core;
|
||||
//
|
||||
//import net.montoyo.mcef.api.IJSQueryCallback;
|
||||
//import net.montoyo.wd.entity.TileEntityScreen;
|
||||
//import net.montoyo.wd.utilities.BlockSide;
|
||||
//
|
||||
//import javax.annotation.Nonnull;
|
||||
//
|
||||
//public interface IScreenQueryHandler {
|
||||
//
|
||||
// //args is an array of Doubles or Strings
|
||||
// //The screen DOES exist, so scr.getScreen(side) is never null
|
||||
// void handleQuery(@Nonnull IJSQueryCallback cb, @Nonnull TileEntityScreen scr, @Nonnull BlockSide side, @Nonnull Object[] args);
|
||||
//
|
||||
//}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,8 +1,8 @@
|
|||
package net.montoyo.wd.init;
|
||||
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
|
@ -21,7 +21,7 @@ public class BlockInit {
|
|||
|
||||
public static DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, "webdisplays");
|
||||
|
||||
public static final RegistryObject<BlockScreen> blockScreen = BLOCKS.register("screen", () -> new BlockScreen(BlockBehaviour.Properties.of(Material.STONE)));
|
||||
public static final RegistryObject<BlockScreen> blockScreen = BLOCKS.register("screen", () -> new BlockScreen(BlockBehaviour.Properties.copy(Blocks.STONE)));
|
||||
|
||||
public static final RegistryObject<BlockKeyboardLeft> blockKeyBoard = BlockInit.BLOCKS.register("kb_left", BlockKeyboardLeft::new);
|
||||
public static final RegistryObject<BlockKeyboardRight> blockKbRight = BLOCKS.register("kb_right", BlockKeyboardRight::new);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import net.minecraft.world.phys.HitResult;
|
|||
import net.montoyo.wd.WebDisplays;
|
||||
import net.montoyo.wd.block.BlockScreen;
|
||||
import net.montoyo.wd.client.ClientProxy;
|
||||
import net.montoyo.wd.client.JSQueryDispatcher;
|
||||
import net.montoyo.wd.config.ClientConfig;
|
||||
import net.montoyo.wd.controls.builtin.ClickControl;
|
||||
import net.montoyo.wd.core.DefaultUpgrade;
|
||||
|
|
@ -79,7 +78,7 @@ public class ItemLaserPointer extends Item implements WDItem {
|
|||
}
|
||||
}
|
||||
|
||||
public static void deselect(Minecraft mc, JSQueryDispatcher jsDispatcher) {
|
||||
public static void deselect(Minecraft mc) {
|
||||
deselectScreen();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
package net.montoyo.wd.utilities;
|
||||
|
||||
import net.montoyo.wd.client.JSQueryDispatcher;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.net.MalformedURLException;
|
||||
|
|
@ -46,9 +44,9 @@ public enum VideoType {
|
|||
volumeCap = volume.prefix.length() + 5 + volume.suffix.length();
|
||||
}
|
||||
|
||||
public static void registerQueries(JSQueryDispatcher jsQueryDispatcher) {
|
||||
// TODO: register GetTime query
|
||||
}
|
||||
// public static void registerQueries(JSQueryDispatcher jsQueryDispatcher) {
|
||||
// // TODO: register GetTime query
|
||||
// }
|
||||
|
||||
protected static class Function {
|
||||
String prefix, suffix;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user