* Java fixes

+ Added README with TODO list
This commit is contained in:
Nicolas BARBOTIN 2018-01-26 19:59:41 +01:00
parent 1cf60b6bac
commit eca8c60319
24 changed files with 88 additions and 61 deletions

32
src/README.md Normal file
View File

@ -0,0 +1,32 @@
# WebDisplays for Minecraft 1.12.2
This is the unfinished port of the WebDisplays mod for Minecraft 1.12.2. The text below is my "TODO" list.
### Missing features
* Redstone interface
* Server blocks (to store some of the player's web pages)
* Screen upgrade: "laser" mouse
* Screen upgrade: redstone input
* Screen upgrade: redstone output
* Peripheral: ComputerCraft interface
* Peripheral: OpenComputers interface
* Read config (see "Config elements" below)
### TODO
* Achievements (minePad 2 and all that stuff)
* GuiSetURL2 missing buttons
* Plugin API
* Automatically add protocol to URLs
* Using the remote control tool too far away (with a chunk loader ofc) may trigger distance guard in SMessageScreenCtrl
* Recipes: why do I need to craft first to have them in my crafting book?
* French translations
* Embedded videos sound/distance
* minePad management: check GuiContainer.draggedStack for minePad
### Config elements
* Site blacklist
* minePad resolution
* Homepage
* RPMP (Real pixels per Minecraft pixels)
* Browser language
* Screen load/unload distance
* Disable ownership thief item

View File

@ -68,8 +68,8 @@ public class BlockScreen extends WDBlockContainer {
return new ExtendedBlockState(this, properties, sideFlags);
}
public static boolean isScreenBlock(IBlockAccess world, Vector3i pos) {
return world.getBlockState(pos.toBlock()).getBlock() instanceof BlockScreen;
public static boolean isntScreenBlock(IBlockAccess world, Vector3i pos) {
return world.getBlockState(pos.toBlock()).getBlock() != WebDisplays.INSTANCE.blockScreen;
}
@Override
@ -79,10 +79,10 @@ public class BlockScreen extends WDBlockContainer {
for(BlockSide side : BlockSide.values()) {
int icon = 0;
if(!isScreenBlock(world, side.up.clone().add(pos))) icon |= BAR_TOP;
if(!isScreenBlock(world, side.down.clone().add(pos))) icon |= BAR_BOT;
if(!isScreenBlock(world, side.left.clone().add(pos))) icon |= BAR_LEFT;
if(!isScreenBlock(world, side.right.clone().add(pos))) icon |= BAR_RIGHT;
if(isntScreenBlock(world, side.up.clone().add(pos))) icon |= BAR_TOP;
if(isntScreenBlock(world, side.down.clone().add(pos))) icon |= BAR_BOT;
if(isntScreenBlock(world, side.left.clone().add(pos))) icon |= BAR_LEFT;
if(isntScreenBlock(world, side.right.clone().add(pos))) icon |= BAR_RIGHT;
ret = ret.withProperty(sideFlags[side.ordinal()], icon);
}

View File

@ -30,7 +30,7 @@ public class GuiScreenConfig extends WDScreen {
private boolean waitingAC;
private int acFailTicks = -1;
private ArrayList<NameUUIDPair> acResults = new ArrayList<NameUUIDPair>();
private ArrayList<NameUUIDPair> acResults = new ArrayList<>();
private boolean adding;
//Controls

View File

@ -36,8 +36,8 @@ public abstract class WDScreen extends GuiScreen {
public static WDScreen CURRENT_SCREEN = null;
protected ArrayList<Control> controls = new ArrayList<Control>();
private HashMap<Class<? extends Event>, Method> eventMap = new HashMap<Class<? extends Event>, Method>();
protected ArrayList<Control> controls = new ArrayList<>();
private HashMap<Class<? extends Event>, Method> eventMap = new HashMap<>();
protected boolean quitOnEscape = true;
protected boolean defaultBackground = true;
protected int syncTicks = 40;
@ -265,7 +265,7 @@ public abstract class WDScreen extends GuiScreen {
if(!root.has("controls") || !root.get("controls").isJsonArray())
throw new RuntimeException("In GUI file " + resLoc.toString() + ": missing root 'controls' object.");
HashMap<String, Double> vars = new HashMap<String, Double>();
HashMap<String, Double> vars = new HashMap<>();
vars.put("width", (double) width);
vars.put("height", (double) height);
vars.put("displayWidth", (double) mc.displayWidth);

View File

@ -16,7 +16,7 @@ public abstract class Container extends BasicControl {
protected int paddingX = 0;
protected int paddingY = 0;
protected ArrayList<Control> childs = new ArrayList<Control>();
protected ArrayList<Control> childs = new ArrayList<>();
public <T extends Control> T addControl(T ctrl) {
childs.add(ctrl);

View File

@ -52,7 +52,7 @@ public class List extends BasicControl {
private int width;
private int height;
private ArrayList<Entry> content = new ArrayList<Entry>();
private ArrayList<Entry> content = new ArrayList<>();
private Framebuffer fbo;
private int selected = -1;
private boolean update;

View File

@ -20,8 +20,8 @@ import java.util.HashMap;
public class GuiLoader {
private static HashMap<String, Class<? extends Control>> controls = new HashMap<String, Class<? extends Control>>();
private static HashMap<ResourceLocation, JsonObject> resources = new HashMap<ResourceLocation, JsonObject>();
private static HashMap<String, Class<? extends Control>> controls = new HashMap<>();
private static HashMap<ResourceLocation, JsonObject> resources = new HashMap<>();
public static void register(Class<? extends Control> cls) {
if(Modifier.isAbstract(cls.getModifiers()))

View File

@ -17,7 +17,7 @@ import java.util.Map;
public class JsonOWrapper {
private static final HashMap<String, Integer> defaultColors = new HashMap<String, Integer>();
private static final HashMap<String, Integer> defaultColors = new HashMap<>();
static {
defaultColors.put("black", Control.COLOR_BLACK);
defaultColors.put("white", Control.COLOR_WHITE);
@ -219,7 +219,7 @@ public class JsonOWrapper {
}
//Parse into ops
ArrayList<VarOpPair> ops = new ArrayList<VarOpPair>();
ArrayList<VarOpPair> ops = new ArrayList<>();
StringBuilder str = new StringBuilder();
boolean negIsPartOfStr = true;
boolean strIsNumber = true;

View File

@ -94,7 +94,7 @@ public class ScreenBaker implements IModelBaker {
return noQuads;
IExtendedBlockState bs = (IExtendedBlockState) state;
List<BakedQuad> ret = new ArrayList<BakedQuad>();
List<BakedQuad> ret = new ArrayList<>();
int sid = BlockSide.reverse(side.ordinal());
BlockSide s = blockSides[sid];

View File

@ -98,13 +98,13 @@ public class ScreenRenderer extends TileEntitySpecialRenderer<TileEntityScreen>
glPopMatrix();
}
if(false) {
//Bounding box debugging
glPushMatrix();
glTranslated(-rendererDispatcher.entityX, -rendererDispatcher.entityY, -rendererDispatcher.entityZ);
renderAABB(te.getRenderBoundingBox());
glPopMatrix();
}
/*
//Bounding box debugging
glPushMatrix();
glTranslated(-rendererDispatcher.entityX, -rendererDispatcher.entityY, -rendererDispatcher.entityZ);
renderAABB(te.getRenderBoundingBox());
glPopMatrix();
*/
//Re-enable lighting
RenderHelper.enableStandardItemLighting();

View File

@ -16,7 +16,7 @@ import java.util.HashMap;
public abstract class GuiData {
private static final HashMap<String, Class<? extends GuiData>> dataTable = new HashMap<String, Class<? extends GuiData>>();
private static final HashMap<String, Class<? extends GuiData>> dataTable = new HashMap<>();
static {
dataTable.put("SetURL", SetURLData.class);
dataTable.put("ScreenConfig", ScreenConfigData.class);

View File

@ -73,7 +73,7 @@ public class TileEntityScreen extends TileEntity {
}
NBTTagList friends = tag.getTagList("Friends", 10);
ret.friends = new ArrayList<NameUUIDPair>(friends.tagCount());
ret.friends = new ArrayList<>(friends.tagCount());
for(int i = 0; i < friends.tagCount(); i++) {
NBTTagCompound nf = friends.getCompoundTagAt(i);
@ -136,7 +136,7 @@ public class TileEntityScreen extends TileEntity {
}
private ArrayList<Screen> screens = new ArrayList<Screen>();
private ArrayList<Screen> screens = new ArrayList<>();
private AxisAlignedBB renderBB = new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
private boolean loaded = true;
public float ytVolume = 100.0f;
@ -199,7 +199,7 @@ public class TileEntityScreen extends TileEntity {
ret.side = side;
ret.size = size;
ret.url = WebDisplays.INSTANCE.homePage;
ret.friends = new ArrayList<NameUUIDPair>();
ret.friends = new ArrayList<>();
ret.friendRights = ScreenRights.DEFAULTS;
ret.otherRights = ScreenRights.DEFAULTS;

View File

@ -19,12 +19,7 @@ import net.montoyo.wd.core.DefaultPeripheral;
public class ItemPeripheral extends ItemMultiTexture {
public ItemPeripheral(Block block) {
super(block, block, new ItemMultiTexture.Mapper() {
@Override
public String apply(ItemStack is) {
return DefaultPeripheral.values()[is.getMetadata()].getName();
}
});
super(block, block, (is) -> DefaultPeripheral.values()[is.getMetadata()].getName());
}
@Override

View File

@ -47,8 +47,8 @@ public class CMessageACResult implements IMessage, Runnable {
public void toBytes(ByteBuf buf) {
buf.writeByte(result.length);
for(int i = 0; i < result.length; i++)
result[i].writeTo(buf);
for(NameUUIDPair pair : result)
pair.writeTo(buf);
}
@Override

View File

@ -16,7 +16,7 @@ public class Messages {
private static DefaultHandler DEFAULT_HANDLER = new DefaultHandler();
private static Class<? extends IMessage>[] messages;
static {
ArrayList<Class<? extends IMessage>> l = new ArrayList<Class<? extends IMessage>>();
ArrayList<Class<? extends IMessage>> l = new ArrayList<>();
l.add(CMessageAddScreen.class);
l.add(SMessageRequestTEData.class);
l.add(SMessageScreenCtrl.class);

View File

@ -62,7 +62,7 @@ public class SMessageACQuery implements IMessage, Runnable {
WebDisplays.NET_HANDLER.sendTo(new CMessageACResult(new NameUUIDPair[0]), player);
}
} else {
ArrayList<NameUUIDPair> results = new ArrayList<NameUUIDPair>();
ArrayList<NameUUIDPair> results = new ArrayList<>();
for(GameProfile gp : profiles) {
if(gp.getName().toLowerCase().startsWith(beginning)) {

View File

@ -6,7 +6,7 @@ package net.montoyo.wd.utilities;
import net.minecraft.util.math.AxisAlignedBB;
public class AABB {
public final class AABB {
public final Vector3i start;
public final Vector3i end;

View File

@ -7,7 +7,7 @@ package net.montoyo.wd.utilities;
import net.minecraftforge.fml.common.FMLLog;
import org.apache.logging.log4j.Level;
public class Log {
public abstract class Log {
public static void info(String what, Object ... data) {
FMLLog.log("WebDisplays", Level.INFO, what, data);

View File

@ -8,12 +8,12 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.montoyo.wd.block.BlockScreen;
public class Multiblock {
public abstract class Multiblock {
public static enum OverrideAction {
public enum OverrideAction {
NONE,
SIMULATE,
IGNORE;
IGNORE
}
public static class BlockOverride {

View File

@ -10,7 +10,7 @@ import net.minecraftforge.fml.common.network.ByteBufUtils;
import java.util.UUID;
public class NameUUIDPair {
public final class NameUUIDPair {
public final String name;
public final UUID uuid;

View File

@ -15,7 +15,7 @@ import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
public class Util {
public abstract class Util {
public static void serialize(ByteBuf bb, Object f) {
Class<?> cls = f.getClass();
@ -38,18 +38,18 @@ public class Util {
Object[] ray = (Object[]) f;
bb.writeInt(ray.length);
for (int i = 0; i < ray.length; i++)
serialize(bb, ray[i]);
for(Object o: ray)
serialize(bb, o);
} else if(!cls.isPrimitive()) {
Field[] fields = cls.getFields();
for(int i = 0; i < fields.length; i++) {
for(Field ff: fields) {
try {
if(fields[i].getAnnotation(DontSerialize.class) == null && !Modifier.isStatic(fields[i].getModifiers()))
serialize(bb, fields[i].get(f));
if(ff.getAnnotation(DontSerialize.class) == null && !Modifier.isStatic(ff.getModifiers()))
serialize(bb, ff.get(f));
} catch(IllegalAccessException e) {
e.printStackTrace();
throw new RuntimeException(String.format("Caught IllegalAccessException for %s.%s", cls.getName(), fields[i].getName()));
throw new RuntimeException(String.format("Caught IllegalAccessException for %s.%s", cls.getName(), ff.getName()));
}
}
} else
@ -92,12 +92,12 @@ public class Util {
throw new RuntimeException(String.format("Caught IllegalAccessException for class %s", cls.getName()));
}
for(int i = 0; i < fields.length; i++) {
for(Field ff: fields) {
try {
if(fields[i].getAnnotation(DontSerialize.class) == null && !Modifier.isStatic(fields[i].getModifiers()))
fields[i].set(ret, unserialize(bb, fields[i].getType()));
if(ff.getAnnotation(DontSerialize.class) == null && !Modifier.isStatic(ff.getModifiers()))
ff.set(ret, unserialize(bb, ff.getType()));
} catch(IllegalAccessException e) {
throw new RuntimeException(String.format("Caught IllegalAccessException for %s.%s", cls.getName(), fields[i].getName()));
throw new RuntimeException(String.format("Caught IllegalAccessException for %s.%s", cls.getName(), ff.getName()));
}
}
@ -123,8 +123,8 @@ public class Util {
Object[] ray = (Object[]) f;
NBTTagList ret = new NBTTagList();
for(int i = 0; i < ray.length; i++)
ret.appendTag(serialize(ray[i]));
for(Object o: ray)
ret.appendTag(serialize(o));
return ret;
} else
@ -155,7 +155,7 @@ public class Util {
}
public static String[] commaSplit(String str) {
ArrayList<String> lst = new ArrayList<String>();
ArrayList<String> lst = new ArrayList<>();
String out = "";
boolean escape = false;

View File

@ -6,7 +6,7 @@ package net.montoyo.wd.utilities;
import io.netty.buffer.ByteBuf;
public class Vector2i {
public final class Vector2i {
public int x;
public int y;

View File

@ -4,7 +4,7 @@
package net.montoyo.wd.utilities;
public class Vector3f {
public final class Vector3f {
public float x;
public float y;

View File

@ -7,7 +7,7 @@ package net.montoyo.wd.utilities;
import io.netty.buffer.ByteBuf;
import net.minecraft.util.math.BlockPos;
public class Vector3i {
public final class Vector3i {
public int x;
public int y;