+ Added wiki F1 key

* Fixed OC interface
* Updated README
This commit is contained in:
Nicolas BARBOTIN 2018-02-13 21:05:54 +01:00
parent 3af3ea0f77
commit 2cfdb61769
24 changed files with 311 additions and 96 deletions

View File

@ -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. This is the unfinished port of the WebDisplays mod for Minecraft 1.12.2. The text below is my "TODO" list.
### Things before release ### Things before release
* Write wiki
* "Anti-9minecraft" * "Anti-9minecraft"
* Update website * Update website
* Publish * Publish

View File

@ -105,4 +105,8 @@ public class SharedProxy {
public void renderRecipes() { public void renderRecipes() {
} }
public boolean isShiftDown() {
return false;
}
} }

View File

@ -9,8 +9,8 @@ import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.AdvancementProgress; import net.minecraft.advancements.AdvancementProgress;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiIngame;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.multiplayer.ClientAdvancementManager; import net.minecraft.client.multiplayer.ClientAdvancementManager;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.texture.TextureMap; 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.IResourceManagerReloadListener;
import net.minecraft.client.resources.SimpleReloadableResourceManager; import net.minecraft.client.resources.SimpleReloadableResourceManager;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; 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.data.GuiData;
import net.montoyo.wd.entity.TileEntityScreen; import net.montoyo.wd.entity.TileEntityScreen;
import net.montoyo.wd.item.ItemMulti; import net.montoyo.wd.item.ItemMulti;
import net.montoyo.wd.item.WDItem;
import net.montoyo.wd.miniserv.client.Client; import net.montoyo.wd.miniserv.client.Client;
import net.montoyo.wd.net.server.SMessagePadCtrl; import net.montoyo.wd.net.server.SMessagePadCtrl;
import net.montoyo.wd.net.server.SMessageScreenCtrl; import net.montoyo.wd.net.server.SMessageScreenCtrl;
import net.montoyo.wd.utilities.*; import net.montoyo.wd.utilities.*;
import org.lwjgl.input.Keyboard;
import paulscode.sound.SoundSystemConfig; import paulscode.sound.SoundSystemConfig;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -88,6 +91,7 @@ public class ClientProxy extends SharedProxy implements IResourceManagerReloadLi
private JSQueryDispatcher jsDispatcher; private JSQueryDispatcher jsDispatcher;
private LaserPointerRenderer laserPointerRenderer; private LaserPointerRenderer laserPointerRenderer;
private GuiScreen nextScreen; private GuiScreen nextScreen;
private boolean isF1Down;
//Miniserv handling //Miniserv handling
private int miniservPort; private int miniservPort;
@ -352,6 +356,11 @@ public class ClientProxy extends SharedProxy implements IResourceManagerReloadLi
nextScreen = new RenderRecipe(); nextScreen = new RenderRecipe();
} }
@Override
public boolean isShiftDown() {
return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
}
/**************************************** RESOURCE MANAGER METHODS ****************************************/ /**************************************** RESOURCE MANAGER METHODS ****************************************/
@Override @Override
@ -481,6 +490,27 @@ public class ClientProxy extends SharedProxy implements IResourceManagerReloadLi
@SubscribeEvent @SubscribeEvent
public void onTick(TickEvent.ClientTickEvent ev) { public void onTick(TickEvent.ClientTickEvent ev) {
if(ev.phase == TickEvent.Phase.END) { 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 //Workaround cuz chat sux
if(nextScreen != null && mc.currentScreen == null) { if(nextScreen != null && mc.currentScreen == null) {
mc.displayGuiScreen(nextScreen); mc.displayGuiScreen(nextScreen);

View File

@ -15,6 +15,8 @@ import net.montoyo.wd.utilities.BlockSide;
import net.montoyo.wd.utilities.Util; import net.montoyo.wd.utilities.Util;
import net.montoyo.wd.utilities.Vector3i; import net.montoyo.wd.utilities.Vector3i;
import javax.annotation.Nullable;
public class GuiRedstoneCtrl extends WDScreen { public class GuiRedstoneCtrl extends WDScreen {
private int dimension; private int dimension;
@ -65,4 +67,10 @@ public class GuiRedstoneCtrl extends WDScreen {
return pos.equalsBlockPos(bp); return pos.equalsBlockPos(bp);
} }
@Nullable
@Override
public String getWikiPageName() {
return "Redstone_Controller";
}
} }

View File

@ -6,6 +6,7 @@ package net.montoyo.wd.client.gui;
import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.montoyo.wd.WebDisplays; 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.client.gui.loading.FillControl;
import net.montoyo.wd.core.ScreenRights; import net.montoyo.wd.core.ScreenRights;
import net.montoyo.wd.entity.TileEntityScreen; import net.montoyo.wd.entity.TileEntityScreen;
import net.montoyo.wd.item.WDItem;
import net.montoyo.wd.net.server.SMessageScreenCtrl; import net.montoyo.wd.net.server.SMessageScreenCtrl;
import net.montoyo.wd.utilities.*; import net.montoyo.wd.utilities.*;
import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.UUID; import java.util.UUID;
@ -473,4 +476,18 @@ public class GuiScreenConfig extends WDScreen {
return bp.equals(tes.getPos()) && side == this.side; 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";
}
} }

View File

@ -20,6 +20,7 @@ import net.montoyo.wd.miniserv.client.*;
import net.montoyo.wd.utilities.*; import net.montoyo.wd.utilities.*;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import javax.annotation.Nullable;
import javax.swing.filechooser.FileSystemView; import javax.swing.filechooser.FileSystemView;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -700,4 +701,11 @@ public class GuiServer extends WDScreen {
public boolean isForBlock(BlockPos bp, BlockSide side) { public boolean isForBlock(BlockPos bp, BlockSide side) {
return serverPos.equalsBlockPos(bp); return serverPos.equalsBlockPos(bp);
} }
@Nullable
@Override
public String getWikiPageName() {
return "Server";
}
} }

View File

@ -28,6 +28,7 @@ import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@ -353,4 +354,9 @@ public abstract class WDScreen extends GuiScreen {
public abstract boolean isForBlock(BlockPos bp, BlockSide side); public abstract boolean isForBlock(BlockPos bp, BlockSide side);
@Nullable
public String getWikiPageName() {
return null;
}
} }

View File

@ -110,6 +110,10 @@ public class UpgradeGroup extends BasicControl {
} }
} }
public ItemStack getMouseOverUpgrade() {
return overStack;
}
public static class ClickEvent extends Event<UpgradeGroup> { public static class ClickEvent extends Event<UpgradeGroup> {
private final ItemStack clickStack; private final ItemStack clickStack;

View File

@ -9,20 +9,22 @@ import net.montoyo.wd.WebDisplays;
public enum CraftComponent { public enum CraftComponent {
STONE_KEY("stonekey"), STONE_KEY("stonekey", "Stone_Key"),
BLANK_UPGRADE("upgrade"), BLANK_UPGRADE("upgrade", "Blank_Upgrade"),
PERIPHERAL_BASE("peripheral"), PERIPHERAL_BASE("peripheral", "Peripheral_Base"),
BATTERY_CELL("batcell"), BATTERY_CELL("batcell", "Battery_Cell"),
BATTERY_PACK("batpack"), BATTERY_PACK("batpack", "Battery_Pack"),
LASER_DIODE("laserdiode"), LASER_DIODE("laserdiode", "Laser_Diode"),
BACKLIGHT("backlight"), BACKLIGHT("backlight", "Backlight"),
EXTENSION_CARD("extcard"), EXTENSION_CARD("extcard", "Blank_Upgrade"),
BAD_EXTENSION_CARD("badextcard"); BAD_EXTENSION_CARD("badextcard", "Bad_Extension_Card");
private final String name; private final String name;
private final String wikiName;
CraftComponent(String n) { CraftComponent(String n, String wikiName) {
name = n; name = n;
this.wikiName = wikiName;
} }
@Override @Override
@ -30,6 +32,11 @@ public enum CraftComponent {
return name; return name;
} }
public static String getWikiName(int meta) {
CraftComponent[] values = values();
return (meta >= 0 && meta < values.length) ? values[meta].wikiName : null;
}
public ItemStack makeItemStack() { public ItemStack makeItemStack() {
return new ItemStack(WebDisplays.INSTANCE.itemCraftComp, 1, ordinal()); return new ItemStack(WebDisplays.INSTANCE.itemCraftComp, 1, ordinal());
} }

View File

@ -12,18 +12,20 @@ import javax.annotation.Nonnull;
public enum DefaultPeripheral implements IStringSerializable { public enum DefaultPeripheral implements IStringSerializable {
KEYBOARD("keyboard", TileEntityKeyboard.class), //WITH FACING (< 3) KEYBOARD("keyboard", "Keyboard", TileEntityKeyboard.class), //WITH FACING (< 3)
CC_INTERFACE("ccinterface", null), CC_INTERFACE("ccinterface", "ComputerCraft_Interface", null),
OC_INTERFACE("cointerface", TileEntityOCInterface.class), OC_INTERFACE("cointerface", "OpenComputers_Interface", TileEntityOCInterface.class),
REMOTE_CONTROLLER("remotectrl", TileEntityRCtrl.class), //WITHOUT FACING (>= 3) REMOTE_CONTROLLER("remotectrl", "Remote_Controller", TileEntityRCtrl.class), //WITHOUT FACING (>= 3)
REDSTONE_CONTROLLER("redstonectrl", TileEntityRedCtrl.class), REDSTONE_CONTROLLER("redstonectrl", "Redstone_Controller", TileEntityRedCtrl.class),
SERVER("server", TileEntityServer.class); SERVER("server", "Server", TileEntityServer.class);
private final String name; private final String name;
private final String wikiName;
private final Class<? extends TileEntity> teClass; 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; this.name = name;
wikiName = wname;
teClass = te; teClass = te;
} }
@ -58,4 +60,8 @@ public enum DefaultPeripheral implements IStringSerializable {
return ret; return ret;
} }
public String getWikiName() {
return wikiName;
}
} }

View File

@ -9,15 +9,17 @@ import net.montoyo.wd.WebDisplays;
public enum DefaultUpgrade { public enum DefaultUpgrade {
LASER_MOUSE("lasermouse"), LASER_MOUSE("lasermouse", "Laser_Sensor"),
REDSTONE_INPUT("redinput"), REDSTONE_INPUT("redinput", "Redstone_Input_Port"),
REDSTONE_OUTPUT("redoutput"), REDSTONE_OUTPUT("redoutput", "Redstone_Output_Port"),
GPS("gps"); GPS("gps", "GPS_Module");
private final String name; private final String name;
private final String wikiName;
DefaultUpgrade(String n) { DefaultUpgrade(String n, String wn) {
name = n; name = n;
wikiName = wn;
} }
@Override @Override
@ -29,4 +31,9 @@ public enum DefaultUpgrade {
return is.getItem() == WebDisplays.INSTANCE.itemUpgrade && is.getMetadata() == ordinal(); 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;
}
} }

View File

@ -92,13 +92,13 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
switch(what) { switch(what) {
case "click": case "click":
case "type": case "type":
case "js":
case "javascript":
case "runjs":
right = ScreenRights.CLICK; right = ScreenRights.CLICK;
break; break;
case "seturl": case "seturl":
case "js":
case "javascript":
case "runjs":
right = ScreenRights.CHANGE_URL; right = ScreenRights.CHANGE_URL;
break; break;
@ -111,10 +111,11 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
throw new IllegalArgumentException("invalid right name"); throw new IllegalArgumentException("invalid right name");
} }
if(owner == null || !isLinked() || !isScreenChunkLoaded()) TileEntityScreen tes = getConnectedScreenEx();
if(owner == null || tes == null)
return null; return null;
else else
return ((getConnectedScreen().getScreen(screenSide).rightsFor(owner.uuid) & right) == 0) ? FALSE : TRUE; return ((tes.getScreen(screenSide).rightsFor(owner.uuid) & right) == 0) ? FALSE : TRUE;
} }
@Callback @Callback
@ -122,19 +123,22 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
public Object[] hasUpgrade(Context ctx, Arguments args) { public Object[] hasUpgrade(Context ctx, Arguments args) {
String name = args.checkString(0); String name = args.checkString(0);
if(owner == null || !isLinked() || !isScreenChunkLoaded()) TileEntityScreen tes = getConnectedScreenEx();
if(owner == null || tes == null)
return null; return null;
else 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 @Callback
@Optional.Method(modid = "opencomputers") @Optional.Method(modid = "opencomputers")
public Object[] getSize(Context ctx, Arguments args) { public Object[] getSize(Context ctx, Arguments args) {
if(owner == null || !isLinked() || !isScreenChunkLoaded()) TileEntityScreen tes = getConnectedScreenEx();
if(owner == null || tes == null)
return null; return null;
else { else {
Vector2i sz = getConnectedScreen().getScreen(screenSide).size; Vector2i sz = tes.getScreen(screenSide).size;
return new Object[] { sz.x, sz.y }; return new Object[] { sz.x, sz.y };
} }
} }
@ -142,10 +146,12 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
@Callback @Callback
@Optional.Method(modid = "opencomputers") @Optional.Method(modid = "opencomputers")
public Object[] getResolution(Context ctx, Arguments args) { public Object[] getResolution(Context ctx, Arguments args) {
if(owner == null || !isLinked() || !isScreenChunkLoaded()) TileEntityScreen tes = getConnectedScreenEx();
if(owner == null || tes == null)
return null; return null;
else { else {
Vector2i res = getConnectedScreen().getScreen(screenSide).resolution; Vector2i res = tes.getScreen(screenSide).resolution;
return new Object[] { res.x, res.y }; return new Object[] { res.x, res.y };
} }
} }
@ -153,19 +159,23 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
@Callback @Callback
@Optional.Method(modid = "opencomputers") @Optional.Method(modid = "opencomputers")
public Object[] getRotation(Context ctx, Arguments args) { public Object[] getRotation(Context ctx, Arguments args) {
if(owner == null || !isLinked() || !isScreenChunkLoaded()) TileEntityScreen tes = getConnectedScreenEx();
if(owner == null || tes == null)
return null; return null;
else else
return new Object[] { getConnectedScreen().getScreen(screenSide).rotation.angle }; return new Object[] { tes.getScreen(screenSide).rotation.getAngleAsInt() };
} }
@Callback @Callback
@Optional.Method(modid = "opencomputers") @Optional.Method(modid = "opencomputers")
public Object[] getURL(Context ctx, Arguments args) { public Object[] getURL(Context ctx, Arguments args) {
if(owner == null || !isLinked() || !isScreenChunkLoaded()) TileEntityScreen tes = getConnectedScreenEx();
if(owner == null || tes == null)
return null; return null;
else else
return new Object[] { getConnectedScreen().getScreen(screenSide).url }; return new Object[] { tes.getScreen(screenSide).url };
} }
private static Object[] err(String str) { private static Object[] err(String str) {
@ -205,10 +215,11 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
throw new IllegalArgumentException("bad action name"); throw new IllegalArgumentException("bad action name");
} }
if(owner == null || !isLinked() || !isScreenChunkLoaded()) TileEntityScreen scr = getConnectedScreenEx();
if(owner == null || scr == null)
return err("notlinked"); return err("notlinked");
else { else {
TileEntityScreen scr = getConnectedScreen();
TileEntityScreen.Screen scrscr = scr.getScreen(screenSide); TileEntityScreen.Screen scrscr = scr.getScreen(screenSide);
if((scrscr.rightsFor(owner.uuid) & ScreenRights.CLICK) == 0) if((scrscr.rightsFor(owner.uuid) & ScreenRights.CLICK) == 0)
@ -243,17 +254,15 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
} }
private Object[] realType(String what) { private Object[] realType(String what) {
if(owner == null || !isLinked() || !isScreenChunkLoaded()) TileEntityScreen scr = getConnectedScreenEx();
return err("notlinked");
else {
TileEntityScreen scr = getConnectedScreen();
if((scr.getScreen(screenSide).rightsFor(owner.uuid) & ScreenRights.CLICK) == 0) if(owner == null || scr == null)
return err("restrictions"); return err("notlinked");
else { else if((scr.getScreen(screenSide).rightsFor(owner.uuid) & ScreenRights.CLICK) == 0)
scr.type(screenSide, what, null); return err("restrictions");
return TRUE; else {
} scr.type(screenSide, what, null);
return TRUE;
} }
} }
@ -293,18 +302,15 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
@Optional.Method(modid = "opencomputers") @Optional.Method(modid = "opencomputers")
public Object[] setURL(Context ctx, Arguments args) { public Object[] setURL(Context ctx, Arguments args) {
String url = args.checkString(0); String url = args.checkString(0);
TileEntityScreen scr = getConnectedScreenEx();
if(owner == null || !isLinked() || !isScreenChunkLoaded()) if(owner == null || scr == null)
return err("notlinked"); return err("notlinked");
else if((scr.getScreen(screenSide).rightsFor(owner.uuid) & ScreenRights.CHANGE_URL) == 0)
return err("restrictions");
else { else {
TileEntityScreen scr = getConnectedScreen(); scr.setScreenURL(screenSide, url);
return TRUE;
if((scr.getScreen(screenSide).rightsFor(owner.uuid) & ScreenRights.CHANGE_URL) == 0)
return err("restrictions");
else {
scr.setScreenURL(screenSide, url);
return TRUE;
}
} }
} }
@ -313,18 +319,15 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
public Object[] setResolution(Context ctx, Arguments args) { public Object[] setResolution(Context ctx, Arguments args) {
int rx = args.checkInteger(0); int rx = args.checkInteger(0);
int ry = args.checkInteger(1); int ry = args.checkInteger(1);
TileEntityScreen scr = getConnectedScreenEx();
if(owner == null || !isLinked() || !isScreenChunkLoaded()) if(owner == null || scr == null)
return err("notlinked"); return err("notlinked");
else if((scr.getScreen(screenSide).rightsFor(owner.uuid) & ScreenRights.CHANGE_RESOLUTION) == 0)
return err("restrictions");
else { else {
TileEntityScreen scr = getConnectedScreen(); scr.setResolution(screenSide, new Vector2i(rx, ry));
return TRUE;
if((scr.getScreen(screenSide).rightsFor(owner.uuid) & ScreenRights.CHANGE_RESOLUTION) == 0)
return err("restrictions");
else {
scr.setResolution(screenSide, new Vector2i(rx, ry));
return TRUE;
}
} }
} }
@ -340,17 +343,15 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
rot /= 90; rot /= 90;
rot &= 3; rot &= 3;
if(owner == null || !isLinked() || !isScreenChunkLoaded()) TileEntityScreen scr = getConnectedScreenEx();
return err("notlinked");
else {
TileEntityScreen scr = getConnectedScreen();
if((scr.getScreen(screenSide).rightsFor(owner.uuid) & ScreenRights.CHANGE_RESOLUTION) == 0) if(owner == null || scr == null)
return err("restrictions"); return err("notlinked");
else { else if((scr.getScreen(screenSide).rightsFor(owner.uuid) & ScreenRights.CHANGE_RESOLUTION) == 0)
scr.setRotation(screenSide, Rotation.values()[rot]); return err("restrictions");
return TRUE; else {
} scr.setRotation(screenSide, Rotation.values()[rot]);
return TRUE;
} }
} }
@ -358,18 +359,15 @@ public class TileEntityOCInterface extends TileEntityPeripheralBase implements S
@Optional.Method(modid = "opencomputers") @Optional.Method(modid = "opencomputers")
public Object[] runJS(Context ctx, Arguments args) { public Object[] runJS(Context ctx, Arguments args) {
String code = args.checkString(0); String code = args.checkString(0);
TileEntityScreen scr = getConnectedScreenEx();
if(owner == null || !isLinked() || !isScreenChunkLoaded()) if(owner == null || scr == null)
return err("notlinked"); return err("notlinked");
else if((scr.getScreen(screenSide).rightsFor(owner.uuid) & ScreenRights.CHANGE_URL) == 0)
return err("restrictions");
else { else {
TileEntityScreen scr = getConnectedScreen(); scr.evalJS(screenSide, code);
return TRUE;
if((scr.getScreen(screenSide).rightsFor(owner.uuid) & ScreenRights.CHANGE_URL) == 0)
return err("restrictions");
else {
scr.evalJS(screenSide, code);
return TRUE;
}
} }
} }

View File

@ -105,6 +105,18 @@ public abstract class TileEntityPeripheralBase extends TileEntity implements IPe
return (TileEntityScreen) te; 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 @Nullable
public Vector3i getScreenPos() { public Vector3i getScreenPos() {
return screenPos; return screenPos;

View File

@ -13,10 +13,11 @@ import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.core.CraftComponent; import net.montoyo.wd.core.CraftComponent;
import net.montoyo.wd.core.HasAdvancement; import net.montoyo.wd.core.HasAdvancement;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List; import java.util.List;
public class ItemCraftComponent extends ItemMulti { public class ItemCraftComponent extends ItemMulti implements WDItem {
public ItemCraftComponent() { public ItemCraftComponent() {
super(CraftComponent.class); super(CraftComponent.class);
@ -37,6 +38,14 @@ public class ItemCraftComponent extends ItemMulti {
tt.add("" + ChatFormatting.RED + I18n.format("webdisplays.extcard.bad")); tt.add("" + ChatFormatting.RED + I18n.format("webdisplays.extcard.bad"));
else else
tt.add("" + ChatFormatting.ITALIC + I18n.format("item.webdisplays.craftcomp.name")); 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());
} }
} }

View File

@ -4,10 +4,17 @@
package net.montoyo.wd.item; package net.montoyo.wd.item;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.montoyo.wd.WebDisplays; 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() { public ItemLaserPointer() {
setUnlocalizedName("webdisplays.laserpointer"); setUnlocalizedName("webdisplays.laserpointer");
@ -16,4 +23,15 @@ public class ItemLaserPointer extends Item {
setCreativeTab(WebDisplays.CREATIVE_TAB); 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";
}
} }

View File

@ -35,7 +35,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List; import java.util.List;
public class ItemLinker extends Item { public class ItemLinker extends Item implements WDItem {
public ItemLinker() { public ItemLinker() {
setUnlocalizedName("webdisplays.linker"); 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.selectPeripheral"));
tt.add(I18n.format("webdisplays.linker.posInfo", tag.getInteger("ScreenX"), tag.getInteger("ScreenY"), tag.getInteger("ScreenZ"))); 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()))); tt.add(I18n.format("webdisplays.linker.sideInfo", I18n.format("webdisplays.side." + side.toString().toLowerCase())));
WDItem.addInformation(tt);
return; return;
} }
} }
tt.add(I18n.format("webdisplays.linker.selectScreen")); tt.add(I18n.format("webdisplays.linker.selectScreen"));
WDItem.addInformation(tt);
}
@Nullable
@Override
public String getWikiName(@Nonnull ItemStack is) {
return "Linking_Tool";
} }
} }

View File

@ -27,7 +27,7 @@ import javax.annotation.Nullable;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
public class ItemMinePad2 extends Item { public class ItemMinePad2 extends Item implements WDItem {
public ItemMinePad2() { public ItemMinePad2() {
setUnlocalizedName("webdisplays.minepad"); setUnlocalizedName("webdisplays.minepad");
@ -74,6 +74,8 @@ public class ItemMinePad2 extends Item {
if(is.getMetadata() > 0) if(is.getMetadata() > 0)
tt.add("" + ChatFormatting.RED + I18n.format("webdisplays.minepad2.info")); tt.add("" + ChatFormatting.RED + I18n.format("webdisplays.minepad2.info"));
WDItem.addInformation(tt);
} }
@Override @Override
@ -121,4 +123,10 @@ public class ItemMinePad2 extends Item {
return ret; return ret;
} }
@Nullable
@Override
public String getWikiName(@Nonnull ItemStack is) {
return "Mine_Pad";
}
} }

View File

@ -27,7 +27,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List; import java.util.List;
public class ItemOwnershipThief extends Item { public class ItemOwnershipThief extends Item implements WDItem {
public ItemOwnershipThief() { public ItemOwnershipThief() {
setUnlocalizedName("webdisplays.ownerthief"); 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")) { 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 pos: " + tag.getInteger("PosX") + ", " + tag.getInteger("PosY") + ", " + tag.getInteger("PosZ"));
tt.add("Screen side: " + BlockSide.values()[tag.getByte("Side")].toString()); tt.add("Screen side: " + BlockSide.values()[tag.getByte("Side")].toString());
WDItem.addInformation(tt);
return; return;
} }
} }
@ -124,6 +125,13 @@ public class ItemOwnershipThief extends Item {
tt.add("" + TextFormatting.RED + "WARNING: Admin tool"); tt.add("" + TextFormatting.RED + "WARNING: Admin tool");
tt.add("Right click on screen"); tt.add("Right click on screen");
tt.add("and give to new owner."); tt.add("and give to new owner.");
WDItem.addInformation(tt);
}
@Nullable
@Override
public String getWikiName(@Nonnull ItemStack is) {
return "Ownership_Thief";
} }
} }

View File

@ -24,7 +24,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List; import java.util.List;
public class ItemPeripheral extends ItemMultiTexture { public class ItemPeripheral extends ItemMultiTexture implements WDItem {
public ItemPeripheral(Block block) { public ItemPeripheral(Block block) {
super(block, block, (is) -> DefaultPeripheral.fromMetadata(is.getMetadata()).getName()); 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 else if(is.getMetadata() == 11 && WebDisplays.PROXY.isMiniservDisabled()) //Server
tt.add("" + ChatFormatting.RED + I18n.format("webdisplays.message.noMiniserv")); 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();
} }
} }

View File

@ -4,9 +4,11 @@
package net.montoyo.wd.item; package net.montoyo.wd.item;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
@ -23,8 +25,10 @@ import net.montoyo.wd.utilities.Util;
import net.montoyo.wd.utilities.Vector3i; import net.montoyo.wd.utilities.Vector3i;
import javax.annotation.Nonnull; 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() { public ItemScreenConfigurator() {
setUnlocalizedName("webdisplays.screencfg"); setUnlocalizedName("webdisplays.screencfg");
@ -62,4 +66,15 @@ public class ItemScreenConfigurator extends Item {
return EnumActionResult.SUCCESS; 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";
}
} }

View File

@ -20,7 +20,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List; import java.util.List;
public class ItemUpgrade extends ItemMulti implements IUpgrade { public class ItemUpgrade extends ItemMulti implements IUpgrade, WDItem {
public ItemUpgrade() { public ItemUpgrade() {
super(DefaultUpgrade.class); super(DefaultUpgrade.class);
@ -49,6 +49,7 @@ public class ItemUpgrade extends ItemMulti implements IUpgrade {
@Override @Override
public void addInformation(ItemStack is, @Nullable World world, List<String> tt, ITooltipFlag ttFlags) { public void addInformation(ItemStack is, @Nullable World world, List<String> tt, ITooltipFlag ttFlags) {
tt.add("" + ChatFormatting.ITALIC + I18n.format("item.webdisplays.upgrade.name")); tt.add("" + ChatFormatting.ITALIC + I18n.format("item.webdisplays.upgrade.name"));
WDItem.addInformation(tt);
} }
@Override @Override
@ -62,4 +63,10 @@ public class ItemUpgrade extends ItemMulti implements IUpgrade {
return "webdisplays:" + upgrades[meta]; return "webdisplays:" + upgrades[meta];
} }
@Nullable
@Override
public String getWikiName(@Nonnull ItemStack is) {
return DefaultUpgrade.getWikiName(is.getMetadata());
}
} }

View 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"));
}
}

View File

@ -32,6 +32,7 @@ item.webdisplays.advicon.name=Advancement Icon
item.webdisplays.advicon.wd.name=WebDisplays item.webdisplays.advicon.wd.name=WebDisplays
item.webdisplays.advicon.brokenpad.name=Broken minePad item.webdisplays.advicon.brokenpad.name=Broken minePad
item.webdisplays.advicon.pigeon.name=Pigeon 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.tooSmall=Too small! Minimum size is 2x2.
webdisplays.message.tooBig=Too big! Maximum size is %dx%d. webdisplays.message.tooBig=Too big! Maximum size is %dx%d.
webdisplays.message.invalid=Structure is invalid; look at %s. webdisplays.message.invalid=Structure is invalid; look at %s.

View File

@ -32,6 +32,7 @@ item.webdisplays.advicon.name=Icone de progrès
item.webdisplays.advicon.wd.name=WebDisplays item.webdisplays.advicon.wd.name=WebDisplays
item.webdisplays.advicon.brokenpad.name=minePad cassé item.webdisplays.advicon.brokenpad.name=minePad cassé
item.webdisplays.advicon.pigeon.name=Pigeon 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.tooSmall=Trop petit ! La taille minimale est de 2x2.
webdisplays.message.tooBig=Trop grand ! La taille maximale est de %dx%d. webdisplays.message.tooBig=Trop grand ! La taille maximale est de %dx%d.
webdisplays.message.invalid=La structure est invalide; regardez vers %s. webdisplays.message.invalid=La structure est invalide; regardez vers %s.