+ Added wiki F1 key
* Fixed OC interface * Updated README
This commit is contained in:
parent
3af3ea0f77
commit
2cfdb61769
|
|
@ -2,7 +2,6 @@
|
|||
This is the unfinished port of the WebDisplays mod for Minecraft 1.12.2. The text below is my "TODO" list.
|
||||
|
||||
### Things before release
|
||||
* Write wiki
|
||||
* "Anti-9minecraft"
|
||||
* Update website
|
||||
* Publish
|
||||
|
|
|
|||
|
|
@ -105,4 +105,8 @@ public class SharedProxy {
|
|||
public void renderRecipes() {
|
||||
}
|
||||
|
||||
public boolean isShiftDown() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import net.minecraft.advancements.Advancement;
|
|||
import net.minecraft.advancements.AdvancementProgress;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiIngame;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.multiplayer.ClientAdvancementManager;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
|
|
@ -18,6 +18,7 @@ import net.minecraft.client.resources.IResourceManager;
|
|||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||
import net.minecraft.client.resources.SimpleReloadableResourceManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
|
@ -51,10 +52,12 @@ import net.montoyo.wd.core.JSServerRequest;
|
|||
import net.montoyo.wd.data.GuiData;
|
||||
import net.montoyo.wd.entity.TileEntityScreen;
|
||||
import net.montoyo.wd.item.ItemMulti;
|
||||
import net.montoyo.wd.item.WDItem;
|
||||
import net.montoyo.wd.miniserv.client.Client;
|
||||
import net.montoyo.wd.net.server.SMessagePadCtrl;
|
||||
import net.montoyo.wd.net.server.SMessageScreenCtrl;
|
||||
import net.montoyo.wd.utilities.*;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import paulscode.sound.SoundSystemConfig;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
|
@ -88,6 +91,7 @@ public class ClientProxy extends SharedProxy implements IResourceManagerReloadLi
|
|||
private JSQueryDispatcher jsDispatcher;
|
||||
private LaserPointerRenderer laserPointerRenderer;
|
||||
private GuiScreen nextScreen;
|
||||
private boolean isF1Down;
|
||||
|
||||
//Miniserv handling
|
||||
private int miniservPort;
|
||||
|
|
@ -352,6 +356,11 @@ public class ClientProxy extends SharedProxy implements IResourceManagerReloadLi
|
|||
nextScreen = new RenderRecipe();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShiftDown() {
|
||||
return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
|
||||
}
|
||||
|
||||
/**************************************** RESOURCE MANAGER METHODS ****************************************/
|
||||
|
||||
@Override
|
||||
|
|
@ -481,6 +490,27 @@ public class ClientProxy extends SharedProxy implements IResourceManagerReloadLi
|
|||
@SubscribeEvent
|
||||
public void onTick(TickEvent.ClientTickEvent ev) {
|
||||
if(ev.phase == TickEvent.Phase.END) {
|
||||
//Help
|
||||
if(Keyboard.isKeyDown(Keyboard.KEY_F1)) {
|
||||
if(!isF1Down) {
|
||||
isF1Down = true;
|
||||
|
||||
String wikiName = null;
|
||||
if(mc.currentScreen instanceof WDScreen)
|
||||
wikiName = ((WDScreen) mc.currentScreen).getWikiPageName();
|
||||
else if(mc.currentScreen instanceof GuiContainer) {
|
||||
Slot slot = ((GuiContainer) mc.currentScreen).getSlotUnderMouse();
|
||||
|
||||
if(slot != null && slot.getHasStack() && slot.getStack().getItem() instanceof WDItem)
|
||||
wikiName = ((WDItem) slot.getStack().getItem()).getWikiName(slot.getStack());
|
||||
}
|
||||
|
||||
if(wikiName != null)
|
||||
mcef.openExampleBrowser("https://montoyo.net/wdwiki/index.php/" + wikiName);
|
||||
}
|
||||
} else if(isF1Down)
|
||||
isF1Down = false;
|
||||
|
||||
//Workaround cuz chat sux
|
||||
if(nextScreen != null && mc.currentScreen == null) {
|
||||
mc.displayGuiScreen(nextScreen);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ import net.montoyo.wd.utilities.BlockSide;
|
|||
import net.montoyo.wd.utilities.Util;
|
||||
import net.montoyo.wd.utilities.Vector3i;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class GuiRedstoneCtrl extends WDScreen {
|
||||
|
||||
private int dimension;
|
||||
|
|
@ -65,4 +67,10 @@ public class GuiRedstoneCtrl extends WDScreen {
|
|||
return pos.equalsBlockPos(bp);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getWikiPageName() {
|
||||
return "Redstone_Controller";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ package net.montoyo.wd.client.gui;
|
|||
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
|
|
@ -13,9 +14,11 @@ import net.montoyo.wd.client.gui.controls.*;
|
|||
import net.montoyo.wd.client.gui.loading.FillControl;
|
||||
import net.montoyo.wd.core.ScreenRights;
|
||||
import net.montoyo.wd.entity.TileEntityScreen;
|
||||
import net.montoyo.wd.item.WDItem;
|
||||
import net.montoyo.wd.net.server.SMessageScreenCtrl;
|
||||
import net.montoyo.wd.utilities.*;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
|
@ -473,4 +476,18 @@ public class GuiScreenConfig extends WDScreen {
|
|||
return bp.equals(tes.getPos()) && side == this.side;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getWikiPageName() {
|
||||
ItemStack is = ugUpgrades.getMouseOverUpgrade();
|
||||
if(is != null) {
|
||||
if(is.getItem() instanceof WDItem)
|
||||
return ((WDItem) is.getItem()).getWikiName(is);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
return "Screen_Configurator";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import net.montoyo.wd.miniserv.client.*;
|
|||
import net.montoyo.wd.utilities.*;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.swing.filechooser.FileSystemView;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
|
@ -700,4 +701,11 @@ public class GuiServer extends WDScreen {
|
|||
public boolean isForBlock(BlockPos bp, BlockSide side) {
|
||||
return serverPos.equalsBlockPos(bp);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getWikiPageName() {
|
||||
return "Server";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import org.lwjgl.input.Keyboard;
|
|||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
|
@ -353,4 +354,9 @@ public abstract class WDScreen extends GuiScreen {
|
|||
|
||||
public abstract boolean isForBlock(BlockPos bp, BlockSide side);
|
||||
|
||||
@Nullable
|
||||
public String getWikiPageName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,6 +110,10 @@ public class UpgradeGroup extends BasicControl {
|
|||
}
|
||||
}
|
||||
|
||||
public ItemStack getMouseOverUpgrade() {
|
||||
return overStack;
|
||||
}
|
||||
|
||||
public static class ClickEvent extends Event<UpgradeGroup> {
|
||||
|
||||
private final ItemStack clickStack;
|
||||
|
|
|
|||
|
|
@ -9,20 +9,22 @@ import net.montoyo.wd.WebDisplays;
|
|||
|
||||
public enum CraftComponent {
|
||||
|
||||
STONE_KEY("stonekey"),
|
||||
BLANK_UPGRADE("upgrade"),
|
||||
PERIPHERAL_BASE("peripheral"),
|
||||
BATTERY_CELL("batcell"),
|
||||
BATTERY_PACK("batpack"),
|
||||
LASER_DIODE("laserdiode"),
|
||||
BACKLIGHT("backlight"),
|
||||
EXTENSION_CARD("extcard"),
|
||||
BAD_EXTENSION_CARD("badextcard");
|
||||
STONE_KEY("stonekey", "Stone_Key"),
|
||||
BLANK_UPGRADE("upgrade", "Blank_Upgrade"),
|
||||
PERIPHERAL_BASE("peripheral", "Peripheral_Base"),
|
||||
BATTERY_CELL("batcell", "Battery_Cell"),
|
||||
BATTERY_PACK("batpack", "Battery_Pack"),
|
||||
LASER_DIODE("laserdiode", "Laser_Diode"),
|
||||
BACKLIGHT("backlight", "Backlight"),
|
||||
EXTENSION_CARD("extcard", "Blank_Upgrade"),
|
||||
BAD_EXTENSION_CARD("badextcard", "Bad_Extension_Card");
|
||||
|
||||
private final String name;
|
||||
private final String wikiName;
|
||||
|
||||
CraftComponent(String n) {
|
||||
CraftComponent(String n, String wikiName) {
|
||||
name = n;
|
||||
this.wikiName = wikiName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -30,6 +32,11 @@ public enum CraftComponent {
|
|||
return name;
|
||||
}
|
||||
|
||||
public static String getWikiName(int meta) {
|
||||
CraftComponent[] values = values();
|
||||
return (meta >= 0 && meta < values.length) ? values[meta].wikiName : null;
|
||||
}
|
||||
|
||||
public ItemStack makeItemStack() {
|
||||
return new ItemStack(WebDisplays.INSTANCE.itemCraftComp, 1, ordinal());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,18 +12,20 @@ import javax.annotation.Nonnull;
|
|||
|
||||
public enum DefaultPeripheral implements IStringSerializable {
|
||||
|
||||
KEYBOARD("keyboard", TileEntityKeyboard.class), //WITH FACING (< 3)
|
||||
CC_INTERFACE("ccinterface", null),
|
||||
OC_INTERFACE("cointerface", TileEntityOCInterface.class),
|
||||
REMOTE_CONTROLLER("remotectrl", TileEntityRCtrl.class), //WITHOUT FACING (>= 3)
|
||||
REDSTONE_CONTROLLER("redstonectrl", TileEntityRedCtrl.class),
|
||||
SERVER("server", TileEntityServer.class);
|
||||
KEYBOARD("keyboard", "Keyboard", TileEntityKeyboard.class), //WITH FACING (< 3)
|
||||
CC_INTERFACE("ccinterface", "ComputerCraft_Interface", null),
|
||||
OC_INTERFACE("cointerface", "OpenComputers_Interface", TileEntityOCInterface.class),
|
||||
REMOTE_CONTROLLER("remotectrl", "Remote_Controller", TileEntityRCtrl.class), //WITHOUT FACING (>= 3)
|
||||
REDSTONE_CONTROLLER("redstonectrl", "Redstone_Controller", TileEntityRedCtrl.class),
|
||||
SERVER("server", "Server", TileEntityServer.class);
|
||||
|
||||
private final String name;
|
||||
private final String wikiName;
|
||||
private final Class<? extends TileEntity> teClass;
|
||||
|
||||
DefaultPeripheral(String name, Class<? extends TileEntity> te) {
|
||||
DefaultPeripheral(String name, String wname, Class<? extends TileEntity> te) {
|
||||
this.name = name;
|
||||
wikiName = wname;
|
||||
teClass = te;
|
||||
}
|
||||
|
||||
|
|
@ -58,4 +60,8 @@ public enum DefaultPeripheral implements IStringSerializable {
|
|||
return ret;
|
||||
}
|
||||
|
||||
public String getWikiName() {
|
||||
return wikiName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,15 +9,17 @@ import net.montoyo.wd.WebDisplays;
|
|||
|
||||
public enum DefaultUpgrade {
|
||||
|
||||
LASER_MOUSE("lasermouse"),
|
||||
REDSTONE_INPUT("redinput"),
|
||||
REDSTONE_OUTPUT("redoutput"),
|
||||
GPS("gps");
|
||||
LASER_MOUSE("lasermouse", "Laser_Sensor"),
|
||||
REDSTONE_INPUT("redinput", "Redstone_Input_Port"),
|
||||
REDSTONE_OUTPUT("redoutput", "Redstone_Output_Port"),
|
||||
GPS("gps", "GPS_Module");
|
||||
|
||||
private final String name;
|
||||
private final String wikiName;
|
||||
|
||||
DefaultUpgrade(String n) {
|
||||
DefaultUpgrade(String n, String wn) {
|
||||
name = n;
|
||||
wikiName = wn;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -29,4 +31,9 @@ public enum DefaultUpgrade {
|
|||
return is.getItem() == WebDisplays.INSTANCE.itemUpgrade && is.getMetadata() == ordinal();
|
||||
}
|
||||
|
||||
public static String getWikiName(int meta) {
|
||||
DefaultUpgrade[] values = values();
|
||||
return (meta >= 0 && meta < values.length) ? values[meta].wikiName : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,13 +92,13 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
|
|||
switch(what) {
|
||||
case "click":
|
||||
case "type":
|
||||
case "js":
|
||||
case "javascript":
|
||||
case "runjs":
|
||||
right = ScreenRights.CLICK;
|
||||
break;
|
||||
|
||||
case "seturl":
|
||||
case "js":
|
||||
case "javascript":
|
||||
case "runjs":
|
||||
right = ScreenRights.CHANGE_URL;
|
||||
break;
|
||||
|
||||
|
|
@ -111,10 +111,11 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
|
|||
throw new IllegalArgumentException("invalid right name");
|
||||
}
|
||||
|
||||
if(owner == null || !isLinked() || !isScreenChunkLoaded())
|
||||
TileEntityScreen tes = getConnectedScreenEx();
|
||||
if(owner == null || tes == null)
|
||||
return null;
|
||||
else
|
||||
return ((getConnectedScreen().getScreen(screenSide).rightsFor(owner.uuid) & right) == 0) ? FALSE : TRUE;
|
||||
return ((tes.getScreen(screenSide).rightsFor(owner.uuid) & right) == 0) ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
@Callback
|
||||
|
|
@ -122,19 +123,22 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
|
|||
public Object[] hasUpgrade(Context ctx, Arguments args) {
|
||||
String name = args.checkString(0);
|
||||
|
||||
if(owner == null || !isLinked() || !isScreenChunkLoaded())
|
||||
TileEntityScreen tes = getConnectedScreenEx();
|
||||
if(owner == null || tes == null)
|
||||
return null;
|
||||
else
|
||||
return getConnectedScreen().getScreen(screenSide).upgrades.stream().anyMatch(is -> ((IUpgrade) is.getItem()).getJSName(is).equalsIgnoreCase(name)) ? TRUE : FALSE;
|
||||
return tes.getScreen(screenSide).upgrades.stream().anyMatch(is -> ((IUpgrade) is.getItem()).getJSName(is).equalsIgnoreCase(name)) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getSize(Context ctx, Arguments args) {
|
||||
if(owner == null || !isLinked() || !isScreenChunkLoaded())
|
||||
TileEntityScreen tes = getConnectedScreenEx();
|
||||
|
||||
if(owner == null || tes == null)
|
||||
return null;
|
||||
else {
|
||||
Vector2i sz = getConnectedScreen().getScreen(screenSide).size;
|
||||
Vector2i sz = tes.getScreen(screenSide).size;
|
||||
return new Object[] { sz.x, sz.y };
|
||||
}
|
||||
}
|
||||
|
|
@ -142,10 +146,12 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
|
|||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getResolution(Context ctx, Arguments args) {
|
||||
if(owner == null || !isLinked() || !isScreenChunkLoaded())
|
||||
TileEntityScreen tes = getConnectedScreenEx();
|
||||
|
||||
if(owner == null || tes == null)
|
||||
return null;
|
||||
else {
|
||||
Vector2i res = getConnectedScreen().getScreen(screenSide).resolution;
|
||||
Vector2i res = tes.getScreen(screenSide).resolution;
|
||||
return new Object[] { res.x, res.y };
|
||||
}
|
||||
}
|
||||
|
|
@ -153,19 +159,23 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
|
|||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getRotation(Context ctx, Arguments args) {
|
||||
if(owner == null || !isLinked() || !isScreenChunkLoaded())
|
||||
TileEntityScreen tes = getConnectedScreenEx();
|
||||
|
||||
if(owner == null || tes == null)
|
||||
return null;
|
||||
else
|
||||
return new Object[] { getConnectedScreen().getScreen(screenSide).rotation.angle };
|
||||
return new Object[] { tes.getScreen(screenSide).rotation.getAngleAsInt() };
|
||||
}
|
||||
|
||||
@Callback
|
||||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] getURL(Context ctx, Arguments args) {
|
||||
if(owner == null || !isLinked() || !isScreenChunkLoaded())
|
||||
TileEntityScreen tes = getConnectedScreenEx();
|
||||
|
||||
if(owner == null || tes == null)
|
||||
return null;
|
||||
else
|
||||
return new Object[] { getConnectedScreen().getScreen(screenSide).url };
|
||||
return new Object[] { tes.getScreen(screenSide).url };
|
||||
}
|
||||
|
||||
private static Object[] err(String str) {
|
||||
|
|
@ -205,10 +215,11 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
|
|||
throw new IllegalArgumentException("bad action name");
|
||||
}
|
||||
|
||||
if(owner == null || !isLinked() || !isScreenChunkLoaded())
|
||||
TileEntityScreen scr = getConnectedScreenEx();
|
||||
|
||||
if(owner == null || scr == null)
|
||||
return err("notlinked");
|
||||
else {
|
||||
TileEntityScreen scr = getConnectedScreen();
|
||||
TileEntityScreen.Screen scrscr = scr.getScreen(screenSide);
|
||||
|
||||
if((scrscr.rightsFor(owner.uuid) & ScreenRights.CLICK) == 0)
|
||||
|
|
@ -243,17 +254,15 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
|
|||
}
|
||||
|
||||
private Object[] realType(String what) {
|
||||
if(owner == null || !isLinked() || !isScreenChunkLoaded())
|
||||
return err("notlinked");
|
||||
else {
|
||||
TileEntityScreen scr = getConnectedScreen();
|
||||
TileEntityScreen scr = getConnectedScreenEx();
|
||||
|
||||
if((scr.getScreen(screenSide).rightsFor(owner.uuid) & ScreenRights.CLICK) == 0)
|
||||
return err("restrictions");
|
||||
else {
|
||||
scr.type(screenSide, what, null);
|
||||
return TRUE;
|
||||
}
|
||||
if(owner == null || scr == null)
|
||||
return err("notlinked");
|
||||
else if((scr.getScreen(screenSide).rightsFor(owner.uuid) & ScreenRights.CLICK) == 0)
|
||||
return err("restrictions");
|
||||
else {
|
||||
scr.type(screenSide, what, null);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -293,18 +302,15 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
|
|||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] setURL(Context ctx, Arguments args) {
|
||||
String url = args.checkString(0);
|
||||
TileEntityScreen scr = getConnectedScreenEx();
|
||||
|
||||
if(owner == null || !isLinked() || !isScreenChunkLoaded())
|
||||
if(owner == null || scr == null)
|
||||
return err("notlinked");
|
||||
else if((scr.getScreen(screenSide).rightsFor(owner.uuid) & ScreenRights.CHANGE_URL) == 0)
|
||||
return err("restrictions");
|
||||
else {
|
||||
TileEntityScreen scr = getConnectedScreen();
|
||||
|
||||
if((scr.getScreen(screenSide).rightsFor(owner.uuid) & ScreenRights.CHANGE_URL) == 0)
|
||||
return err("restrictions");
|
||||
else {
|
||||
scr.setScreenURL(screenSide, url);
|
||||
return TRUE;
|
||||
}
|
||||
scr.setScreenURL(screenSide, url);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -313,18 +319,15 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
|
|||
public Object[] setResolution(Context ctx, Arguments args) {
|
||||
int rx = args.checkInteger(0);
|
||||
int ry = args.checkInteger(1);
|
||||
TileEntityScreen scr = getConnectedScreenEx();
|
||||
|
||||
if(owner == null || !isLinked() || !isScreenChunkLoaded())
|
||||
if(owner == null || scr == null)
|
||||
return err("notlinked");
|
||||
else if((scr.getScreen(screenSide).rightsFor(owner.uuid) & ScreenRights.CHANGE_RESOLUTION) == 0)
|
||||
return err("restrictions");
|
||||
else {
|
||||
TileEntityScreen scr = getConnectedScreen();
|
||||
|
||||
if((scr.getScreen(screenSide).rightsFor(owner.uuid) & ScreenRights.CHANGE_RESOLUTION) == 0)
|
||||
return err("restrictions");
|
||||
else {
|
||||
scr.setResolution(screenSide, new Vector2i(rx, ry));
|
||||
return TRUE;
|
||||
}
|
||||
scr.setResolution(screenSide, new Vector2i(rx, ry));
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -340,17 +343,15 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
|
|||
rot /= 90;
|
||||
rot &= 3;
|
||||
|
||||
if(owner == null || !isLinked() || !isScreenChunkLoaded())
|
||||
return err("notlinked");
|
||||
else {
|
||||
TileEntityScreen scr = getConnectedScreen();
|
||||
TileEntityScreen scr = getConnectedScreenEx();
|
||||
|
||||
if((scr.getScreen(screenSide).rightsFor(owner.uuid) & ScreenRights.CHANGE_RESOLUTION) == 0)
|
||||
return err("restrictions");
|
||||
else {
|
||||
scr.setRotation(screenSide, Rotation.values()[rot]);
|
||||
return TRUE;
|
||||
}
|
||||
if(owner == null || scr == null)
|
||||
return err("notlinked");
|
||||
else if((scr.getScreen(screenSide).rightsFor(owner.uuid) & ScreenRights.CHANGE_RESOLUTION) == 0)
|
||||
return err("restrictions");
|
||||
else {
|
||||
scr.setRotation(screenSide, Rotation.values()[rot]);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -358,18 +359,15 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
|
|||
@Optional.Method(modid = "opencomputers")
|
||||
public Object[] runJS(Context ctx, Arguments args) {
|
||||
String code = args.checkString(0);
|
||||
TileEntityScreen scr = getConnectedScreenEx();
|
||||
|
||||
if(owner == null || !isLinked() || !isScreenChunkLoaded())
|
||||
if(owner == null || scr == null)
|
||||
return err("notlinked");
|
||||
else if((scr.getScreen(screenSide).rightsFor(owner.uuid) & ScreenRights.CHANGE_URL) == 0)
|
||||
return err("restrictions");
|
||||
else {
|
||||
TileEntityScreen scr = getConnectedScreen();
|
||||
|
||||
if((scr.getScreen(screenSide).rightsFor(owner.uuid) & ScreenRights.CHANGE_URL) == 0)
|
||||
return err("restrictions");
|
||||
else {
|
||||
scr.evalJS(screenSide, code);
|
||||
return TRUE;
|
||||
}
|
||||
scr.evalJS(screenSide, code);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,6 +105,18 @@ public abstract class TileEntityPeripheralBase extends TileEntity implements IPe
|
|||
return (TileEntityScreen) te;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TileEntityScreen getConnectedScreenEx() {
|
||||
if(screenPos == null || screenSide == null)
|
||||
return null;
|
||||
|
||||
TileEntity te = world.getTileEntity(screenPos.toBlock());
|
||||
if(te == null || !(te instanceof TileEntityScreen) || ((TileEntityScreen) te).getScreen(screenSide) == null)
|
||||
return null;
|
||||
|
||||
return (TileEntityScreen) te;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Vector3i getScreenPos() {
|
||||
return screenPos;
|
||||
|
|
|
|||
|
|
@ -13,10 +13,11 @@ import net.montoyo.wd.WebDisplays;
|
|||
import net.montoyo.wd.core.CraftComponent;
|
||||
import net.montoyo.wd.core.HasAdvancement;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemCraftComponent extends ItemMulti {
|
||||
public class ItemCraftComponent extends ItemMulti implements WDItem {
|
||||
|
||||
public ItemCraftComponent() {
|
||||
super(CraftComponent.class);
|
||||
|
|
@ -37,6 +38,14 @@ public class ItemCraftComponent extends ItemMulti {
|
|||
tt.add("" + ChatFormatting.RED + I18n.format("webdisplays.extcard.bad"));
|
||||
else
|
||||
tt.add("" + ChatFormatting.ITALIC + I18n.format("item.webdisplays.craftcomp.name"));
|
||||
|
||||
WDItem.addInformation(tt);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getWikiName(@Nonnull ItemStack is) {
|
||||
return CraftComponent.getWikiName(is.getMetadata());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,17 @@
|
|||
|
||||
package net.montoyo.wd.item;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
|
||||
public class ItemLaserPointer extends Item {
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemLaserPointer extends Item implements WDItem {
|
||||
|
||||
public ItemLaserPointer() {
|
||||
setUnlocalizedName("webdisplays.laserpointer");
|
||||
|
|
@ -16,4 +23,15 @@ public class ItemLaserPointer extends Item {
|
|||
setCreativeTab(WebDisplays.CREATIVE_TAB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack is, @Nullable World world, List<String> tt, ITooltipFlag ttFlags) {
|
||||
WDItem.addInformation(tt);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getWikiName(@Nonnull ItemStack is) {
|
||||
return "Laser_Pointer";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import javax.annotation.Nonnull;
|
|||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemLinker extends Item {
|
||||
public class ItemLinker extends Item implements WDItem {
|
||||
|
||||
public ItemLinker() {
|
||||
setUnlocalizedName("webdisplays.linker");
|
||||
|
|
@ -139,11 +139,19 @@ public class ItemLinker extends Item {
|
|||
tt.add(I18n.format("webdisplays.linker.selectPeripheral"));
|
||||
tt.add(I18n.format("webdisplays.linker.posInfo", tag.getInteger("ScreenX"), tag.getInteger("ScreenY"), tag.getInteger("ScreenZ")));
|
||||
tt.add(I18n.format("webdisplays.linker.sideInfo", I18n.format("webdisplays.side." + side.toString().toLowerCase())));
|
||||
WDItem.addInformation(tt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
tt.add(I18n.format("webdisplays.linker.selectScreen"));
|
||||
WDItem.addInformation(tt);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getWikiName(@Nonnull ItemStack is) {
|
||||
return "Linking_Tool";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import javax.annotation.Nullable;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ItemMinePad2 extends Item {
|
||||
public class ItemMinePad2 extends Item implements WDItem {
|
||||
|
||||
public ItemMinePad2() {
|
||||
setUnlocalizedName("webdisplays.minepad");
|
||||
|
|
@ -74,6 +74,8 @@ public class ItemMinePad2 extends Item {
|
|||
|
||||
if(is.getMetadata() > 0)
|
||||
tt.add("" + ChatFormatting.RED + I18n.format("webdisplays.minepad2.info"));
|
||||
|
||||
WDItem.addInformation(tt);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -121,4 +123,10 @@ public class ItemMinePad2 extends Item {
|
|||
return ret;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getWikiName(@Nonnull ItemStack is) {
|
||||
return "Mine_Pad";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import javax.annotation.Nonnull;
|
|||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemOwnershipThief extends Item {
|
||||
public class ItemOwnershipThief extends Item implements WDItem {
|
||||
|
||||
public ItemOwnershipThief() {
|
||||
setUnlocalizedName("webdisplays.ownerthief");
|
||||
|
|
@ -117,6 +117,7 @@ public class ItemOwnershipThief extends Item {
|
|||
if(tag.hasKey("PosX") && tag.hasKey("PosY") && tag.hasKey("PosZ") && tag.hasKey("Side")) {
|
||||
tt.add("Screen pos: " + tag.getInteger("PosX") + ", " + tag.getInteger("PosY") + ", " + tag.getInteger("PosZ"));
|
||||
tt.add("Screen side: " + BlockSide.values()[tag.getByte("Side")].toString());
|
||||
WDItem.addInformation(tt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -124,6 +125,13 @@ public class ItemOwnershipThief extends Item {
|
|||
tt.add("" + TextFormatting.RED + "WARNING: Admin tool");
|
||||
tt.add("Right click on screen");
|
||||
tt.add("and give to new owner.");
|
||||
WDItem.addInformation(tt);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getWikiName(@Nonnull ItemStack is) {
|
||||
return "Ownership_Thief";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import javax.annotation.Nonnull;
|
|||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemPeripheral extends ItemMultiTexture {
|
||||
public class ItemPeripheral extends ItemMultiTexture implements WDItem {
|
||||
|
||||
public ItemPeripheral(Block block) {
|
||||
super(block, block, (is) -> DefaultPeripheral.fromMetadata(is.getMetadata()).getName());
|
||||
|
|
@ -61,6 +61,14 @@ public class ItemPeripheral extends ItemMultiTexture {
|
|||
else if(is.getMetadata() == 11 && WebDisplays.PROXY.isMiniservDisabled()) //Server
|
||||
tt.add("" + ChatFormatting.RED + I18n.format("webdisplays.message.noMiniserv"));
|
||||
}
|
||||
|
||||
WDItem.addInformation(tt);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getWikiName(@Nonnull ItemStack is) {
|
||||
return DefaultPeripheral.fromMetadata(is.getMetadata()).getWikiName();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@
|
|||
|
||||
package net.montoyo.wd.item;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
|
@ -23,8 +25,10 @@ import net.montoyo.wd.utilities.Util;
|
|||
import net.montoyo.wd.utilities.Vector3i;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemScreenConfigurator extends Item {
|
||||
public class ItemScreenConfigurator extends Item implements WDItem {
|
||||
|
||||
public ItemScreenConfigurator() {
|
||||
setUnlocalizedName("webdisplays.screencfg");
|
||||
|
|
@ -62,4 +66,15 @@ public class ItemScreenConfigurator extends Item {
|
|||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack is, @Nullable World world, List<String> tt, ITooltipFlag ttFlags) {
|
||||
WDItem.addInformation(tt);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getWikiName(@Nonnull ItemStack is) {
|
||||
return "Screen_Configurator";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import javax.annotation.Nonnull;
|
|||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemUpgrade extends ItemMulti implements IUpgrade {
|
||||
public class ItemUpgrade extends ItemMulti implements IUpgrade, WDItem {
|
||||
|
||||
public ItemUpgrade() {
|
||||
super(DefaultUpgrade.class);
|
||||
|
|
@ -49,6 +49,7 @@ public class ItemUpgrade extends ItemMulti implements IUpgrade {
|
|||
@Override
|
||||
public void addInformation(ItemStack is, @Nullable World world, List<String> tt, ITooltipFlag ttFlags) {
|
||||
tt.add("" + ChatFormatting.ITALIC + I18n.format("item.webdisplays.upgrade.name"));
|
||||
WDItem.addInformation(tt);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -62,4 +63,10 @@ public class ItemUpgrade extends ItemMulti implements IUpgrade {
|
|||
return "webdisplays:" + upgrades[meta];
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getWikiName(@Nonnull ItemStack is) {
|
||||
return DefaultUpgrade.getWikiName(is.getMetadata());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
26
src/main/java/net/montoyo/wd/item/WDItem.java
Normal file
26
src/main/java/net/montoyo/wd/item/WDItem.java
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (C) 2018 BARBOTIN Nicolas
|
||||
*/
|
||||
|
||||
package net.montoyo.wd.item;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public interface WDItem {
|
||||
|
||||
@Nullable
|
||||
String getWikiName(@Nonnull ItemStack is);
|
||||
|
||||
static void addInformation(@Nullable List<String> tt) {
|
||||
if(tt != null && WebDisplays.PROXY.isShiftDown())
|
||||
tt.add("" + ChatFormatting.GRAY + I18n.format("item.webdisplays.wiki"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -32,6 +32,7 @@ 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
|
||||
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.
|
||||
webdisplays.message.invalid=Structure is invalid; look at %s.
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ item.webdisplays.advicon.name=Icone de progrès
|
|||
item.webdisplays.advicon.wd.name=WebDisplays
|
||||
item.webdisplays.advicon.brokenpad.name=minePad cassé
|
||||
item.webdisplays.advicon.pigeon.name=Pigeon
|
||||
item.webdisplays.wiki=Appuyez sur "F1" pour ouvrir le Wiki
|
||||
webdisplays.message.tooSmall=Trop petit ! La taille minimale est de 2x2.
|
||||
webdisplays.message.tooBig=Trop grand ! La taille maximale est de %dx%d.
|
||||
webdisplays.message.invalid=La structure est invalide; regardez vers %s.
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user