* Enhanced code
This commit is contained in:
parent
c6128dc065
commit
0206f18a33
|
|
@ -31,6 +31,7 @@ import net.montoyo.wd.item.ItemLinker;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
import net.montoyo.wd.utilities.Vector3i;
|
import net.montoyo.wd.utilities.Vector3i;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class BlockKeyboardRight extends Block implements IPeripheral {
|
public class BlockKeyboardRight extends Block implements IPeripheral {
|
||||||
|
|
@ -49,6 +50,7 @@ public class BlockKeyboardRight extends Block implements IPeripheral {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nonnull
|
||||||
protected BlockStateContainer createBlockState() {
|
protected BlockStateContainer createBlockState() {
|
||||||
return new BlockStateContainer(this, properties);
|
return new BlockStateContainer(this, properties);
|
||||||
}
|
}
|
||||||
|
|
@ -84,11 +86,13 @@ public class BlockKeyboardRight extends Block implements IPeripheral {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nonnull
|
||||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
|
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
|
||||||
return KEYBOARD_AABB;
|
return KEYBOARD_AABB;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nonnull
|
||||||
public IBlockState getStateFromMeta(int meta) {
|
public IBlockState getStateFromMeta(int meta) {
|
||||||
return getDefaultState().withProperty(facing, meta);
|
return getDefaultState().withProperty(facing, meta);
|
||||||
}
|
}
|
||||||
|
|
@ -99,11 +103,12 @@ public class BlockKeyboardRight extends Block implements IPeripheral {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
|
@Nonnull
|
||||||
|
public ItemStack getPickBlock(@Nonnull IBlockState state, RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos, EntityPlayer player) {
|
||||||
return new ItemStack(WebDisplays.INSTANCE.blockPeripheral, 1, 0);
|
return new ItemStack(WebDisplays.INSTANCE.blockPeripheral, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntityKeyboard getTileEntity(World world, BlockPos pos) {
|
private TileEntityKeyboard getTileEntity(World world, BlockPos pos) {
|
||||||
for(EnumFacing nf: EnumFacing.HORIZONTALS) {
|
for(EnumFacing nf: EnumFacing.HORIZONTALS) {
|
||||||
BlockPos np = pos.add(nf.getDirectionVec());
|
BlockPos np = pos.add(nf.getDirectionVec());
|
||||||
IBlockState ns = world.getBlockState(np);
|
IBlockState ns = world.getBlockState(np);
|
||||||
|
|
@ -127,6 +132,7 @@ public class BlockKeyboardRight extends Block implements IPeripheral {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nonnull
|
||||||
public EnumPushReaction getMobilityFlag(IBlockState state) {
|
public EnumPushReaction getMobilityFlag(IBlockState state) {
|
||||||
return EnumPushReaction.IGNORE;
|
return EnumPushReaction.IGNORE;
|
||||||
}
|
}
|
||||||
|
|
@ -176,7 +182,7 @@ public class BlockKeyboardRight extends Block implements IPeripheral {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer ply, boolean willHarvest) {
|
public boolean removedByPlayer(@Nonnull IBlockState state, World world, @Nonnull BlockPos pos, @Nonnull EntityPlayer ply, boolean willHarvest) {
|
||||||
if(!world.isRemote)
|
if(!world.isRemote)
|
||||||
removeLeftPiece(world, pos, !ply.isCreative());
|
removeLeftPiece(world, pos, !ply.isCreative());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -139,9 +139,10 @@ public class BlockPeripheral extends WDBlockContainer {
|
||||||
|
|
||||||
if(te instanceof TileEntityPeripheralBase)
|
if(te instanceof TileEntityPeripheralBase)
|
||||||
return ((TileEntityPeripheralBase) te).onRightClick(player, hand, BlockSide.values()[facing.ordinal()]);
|
return ((TileEntityPeripheralBase) te).onRightClick(player, hand, BlockSide.values()[facing.ordinal()]);
|
||||||
else if(te instanceof TileEntityServer)
|
else if(te instanceof TileEntityServer) {
|
||||||
return ((TileEntityServer) te).onPlayerRightClick(player);
|
((TileEntityServer) te).onPlayerRightClick(player);
|
||||||
else
|
return true;
|
||||||
|
} else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,6 @@ 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.miniserv.Constants;
|
|
||||||
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;
|
||||||
|
|
@ -71,7 +70,7 @@ public class ClientProxy extends SharedProxy implements IResourceManagerReloadLi
|
||||||
|
|
||||||
public IBrowser view;
|
public IBrowser view;
|
||||||
private boolean isInHotbar;
|
private boolean isInHotbar;
|
||||||
private int id;
|
private final int id;
|
||||||
private long lastURLSent;
|
private long lastURLSent;
|
||||||
|
|
||||||
private PadData(String url, int id) {
|
private PadData(String url, int id) {
|
||||||
|
|
@ -84,7 +83,7 @@ public class ClientProxy extends SharedProxy implements IResourceManagerReloadLi
|
||||||
}
|
}
|
||||||
|
|
||||||
private Minecraft mc;
|
private Minecraft mc;
|
||||||
private ArrayList<ResourceModelPair> modelBakers = new ArrayList<>();
|
private final ArrayList<ResourceModelPair> modelBakers = new ArrayList<>();
|
||||||
private net.montoyo.mcef.api.API mcef;
|
private net.montoyo.mcef.api.API mcef;
|
||||||
private MinePadRenderer minePadRenderer;
|
private MinePadRenderer minePadRenderer;
|
||||||
private JSQueryDispatcher jsDispatcher;
|
private JSQueryDispatcher jsDispatcher;
|
||||||
|
|
@ -105,12 +104,12 @@ public class ClientProxy extends SharedProxy implements IResourceManagerReloadLi
|
||||||
private long lastPointPacket;
|
private long lastPointPacket;
|
||||||
|
|
||||||
//Tracking
|
//Tracking
|
||||||
private ArrayList<TileEntityScreen> screenTracking = new ArrayList<>();
|
private final ArrayList<TileEntityScreen> screenTracking = new ArrayList<>();
|
||||||
private int lastTracked = 0;
|
private int lastTracked = 0;
|
||||||
|
|
||||||
//MinePads Management
|
//MinePads Management
|
||||||
private HashMap<Integer, PadData> padMap = new HashMap<>();
|
private final HashMap<Integer, PadData> padMap = new HashMap<>();
|
||||||
private ArrayList<PadData> padList = new ArrayList<>();
|
private final ArrayList<PadData> padList = new ArrayList<>();
|
||||||
private int minePadTickCounter = 0;
|
private int minePadTickCounter = 0;
|
||||||
|
|
||||||
/**************************************** INHERITED METHODS ****************************************/
|
/**************************************** INHERITED METHODS ****************************************/
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ import net.montoyo.wd.client.renderers.IModelBaker;
|
||||||
|
|
||||||
public class ResourceModelPair {
|
public class ResourceModelPair {
|
||||||
|
|
||||||
private ModelResourceLocation resLoc;
|
private final ModelResourceLocation resLoc;
|
||||||
private IModelBaker model;
|
private final IModelBaker model;
|
||||||
|
|
||||||
public ResourceModelPair(ModelResourceLocation rl, IModelBaker m) {
|
public ResourceModelPair(ModelResourceLocation rl, IModelBaker m) {
|
||||||
resLoc = rl;
|
resLoc = rl;
|
||||||
|
|
|
||||||
|
|
@ -8,16 +8,19 @@ import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class StaticStateMapper extends StateMapperBase {
|
public class StaticStateMapper extends StateMapperBase {
|
||||||
|
|
||||||
private ModelResourceLocation resLoc;
|
private final ModelResourceLocation resLoc;
|
||||||
|
|
||||||
public StaticStateMapper(ModelResourceLocation rl) {
|
public StaticStateMapper(ModelResourceLocation rl) {
|
||||||
resLoc = rl;
|
resLoc = rl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
|
@Nonnull
|
||||||
|
protected ModelResourceLocation getModelResourceLocation(@Nonnull IBlockState state) {
|
||||||
return resLoc;
|
return resLoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ import net.montoyo.wd.utilities.Util;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class WDScheme implements IScheme {
|
public class WDScheme implements IScheme {
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ import java.util.UUID;
|
||||||
public class GuiScreenConfig extends WDScreen {
|
public class GuiScreenConfig extends WDScreen {
|
||||||
|
|
||||||
//Screen data
|
//Screen data
|
||||||
private TileEntityScreen tes;
|
private final TileEntityScreen tes;
|
||||||
private BlockSide side;
|
private final BlockSide side;
|
||||||
private NameUUIDPair owner;
|
private NameUUIDPair owner;
|
||||||
private NameUUIDPair[] friends;
|
private NameUUIDPair[] friends;
|
||||||
private int friendRights;
|
private int friendRights;
|
||||||
|
|
@ -36,7 +36,7 @@ public class GuiScreenConfig extends WDScreen {
|
||||||
private boolean waitingAC;
|
private boolean waitingAC;
|
||||||
private int acFailTicks = -1;
|
private int acFailTicks = -1;
|
||||||
|
|
||||||
private ArrayList<NameUUIDPair> acResults = new ArrayList<>();
|
private final ArrayList<NameUUIDPair> acResults = new ArrayList<>();
|
||||||
private boolean adding;
|
private boolean adding;
|
||||||
|
|
||||||
//Controls
|
//Controls
|
||||||
|
|
@ -422,7 +422,7 @@ public class GuiScreenConfig extends WDScreen {
|
||||||
|
|
||||||
public void updateMyRights() {
|
public void updateMyRights() {
|
||||||
NameUUIDPair me = new NameUUIDPair(mc.player.getGameProfile());
|
NameUUIDPair me = new NameUUIDPair(mc.player.getGameProfile());
|
||||||
int myRights = 0;
|
int myRights;
|
||||||
boolean clientIsOwner = false;
|
boolean clientIsOwner = false;
|
||||||
|
|
||||||
if(me.equals(owner)) {
|
if(me.equals(owner)) {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
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.mcef.api.IBrowser;
|
|
||||||
import net.montoyo.wd.WebDisplays;
|
import net.montoyo.wd.WebDisplays;
|
||||||
import net.montoyo.wd.client.ClientProxy;
|
import net.montoyo.wd.client.ClientProxy;
|
||||||
import net.montoyo.wd.client.gui.controls.Button;
|
import net.montoyo.wd.client.gui.controls.Button;
|
||||||
|
|
@ -31,10 +30,10 @@ public class GuiSetURL2 extends WDScreen {
|
||||||
private Vector3i remoteLocation;
|
private Vector3i remoteLocation;
|
||||||
|
|
||||||
//Pad data
|
//Pad data
|
||||||
private boolean isPad;
|
private final boolean isPad;
|
||||||
|
|
||||||
//Common
|
//Common
|
||||||
private String screenURL;
|
private final String screenURL;
|
||||||
|
|
||||||
@FillControl
|
@FillControl
|
||||||
private TextField tfURL;
|
private TextField tfURL;
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,13 @@ import net.montoyo.wd.client.gui.loading.GuiLoader;
|
||||||
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
||||||
import net.montoyo.wd.net.server.SMessageACQuery;
|
import net.montoyo.wd.net.server.SMessageACQuery;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
|
import net.montoyo.wd.utilities.Bounds;
|
||||||
import net.montoyo.wd.utilities.Log;
|
import net.montoyo.wd.utilities.Log;
|
||||||
import net.montoyo.wd.utilities.NameUUIDPair;
|
import net.montoyo.wd.utilities.NameUUIDPair;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.input.Mouse;
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
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;
|
||||||
|
|
@ -39,9 +41,9 @@ public abstract class WDScreen extends GuiScreen {
|
||||||
|
|
||||||
public static WDScreen CURRENT_SCREEN = null;
|
public static WDScreen CURRENT_SCREEN = null;
|
||||||
|
|
||||||
protected ArrayList<Control> controls = new ArrayList<>();
|
protected final ArrayList<Control> controls = new ArrayList<>();
|
||||||
protected ArrayList<Control> postDrawList = new ArrayList<>();
|
protected final ArrayList<Control> postDrawList = new ArrayList<>();
|
||||||
private HashMap<Class<? extends Event>, Method> eventMap = new HashMap<>();
|
private final HashMap<Class<? extends Event>, Method> eventMap = new HashMap<>();
|
||||||
protected boolean quitOnEscape = true;
|
protected boolean quitOnEscape = true;
|
||||||
protected boolean defaultBackground = true;
|
protected boolean defaultBackground = true;
|
||||||
protected int syncTicks = 40;
|
protected int syncTicks = 40;
|
||||||
|
|
@ -91,33 +93,11 @@ public abstract class WDScreen extends GuiScreen {
|
||||||
|
|
||||||
protected void centerControls() {
|
protected void centerControls() {
|
||||||
//Determine bounding box
|
//Determine bounding box
|
||||||
int minX = Integer.MAX_VALUE;
|
Bounds bounds = Control.findBounds(controls);
|
||||||
int minY = Integer.MAX_VALUE;
|
|
||||||
int maxX = Integer.MIN_VALUE;
|
|
||||||
int maxY = Integer.MIN_VALUE;
|
|
||||||
|
|
||||||
for(Control ctrl : controls) {
|
|
||||||
int x = ctrl.getX();
|
|
||||||
int y = ctrl.getY();
|
|
||||||
if(x < minX)
|
|
||||||
minX = x;
|
|
||||||
|
|
||||||
if(y < minY)
|
|
||||||
minY = y;
|
|
||||||
|
|
||||||
x += ctrl.getWidth();
|
|
||||||
y += ctrl.getHeight();
|
|
||||||
|
|
||||||
if(x > maxX)
|
|
||||||
maxX = x;
|
|
||||||
|
|
||||||
if(y >= maxY)
|
|
||||||
maxY = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Translation vector
|
//Translation vector
|
||||||
int diffX = (width - maxX - minX) / 2;
|
int diffX = (width - bounds.maxX - bounds.minX) / 2;
|
||||||
int diffY = (height - maxY - minY) / 2;
|
int diffY = (height - bounds.maxY - bounds.minY) / 2;
|
||||||
|
|
||||||
//Translate controls
|
//Translate controls
|
||||||
for(Control ctrl : controls) {
|
for(Control ctrl : controls) {
|
||||||
|
|
@ -152,7 +132,7 @@ public abstract class WDScreen extends GuiScreen {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||||
for(Control ctrl: controls)
|
for(Control ctrl: controls)
|
||||||
ctrl.mouseClicked(mouseX, mouseY, mouseButton);
|
ctrl.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
}
|
}
|
||||||
|
|
@ -316,7 +296,7 @@ public abstract class WDScreen extends GuiScreen {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResize(Minecraft mcIn, int w, int h) {
|
public void onResize(@Nonnull Minecraft mcIn, int w, int h) {
|
||||||
for(Control ctrl : controls)
|
for(Control ctrl : controls)
|
||||||
ctrl.destroy();
|
ctrl.destroy();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,6 @@ import net.minecraft.client.gui.GuiButton;
|
||||||
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class Button extends Control {
|
public class Button extends Control {
|
||||||
|
|
||||||
protected final GuiButton btn;
|
protected final GuiButton btn;
|
||||||
|
|
@ -20,7 +18,7 @@ public class Button extends Control {
|
||||||
|
|
||||||
public static class ClickEvent extends Event<Button> {
|
public static class ClickEvent extends Event<Button> {
|
||||||
|
|
||||||
private boolean shiftDown;
|
private final boolean shiftDown;
|
||||||
|
|
||||||
private ClickEvent(Button btn) {
|
private ClickEvent(Button btn) {
|
||||||
source = btn;
|
source = btn;
|
||||||
|
|
@ -46,7 +44,7 @@ public class Button extends Control {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||||
if(mouseButton == 0 && btn.mousePressed(mc, mouseX, mouseY)) {
|
if(mouseButton == 0 && btn.mousePressed(mc, mouseX, mouseY)) {
|
||||||
selected = true;
|
selected = true;
|
||||||
btn.playPressSound(mc.getSoundHandler());
|
btn.playPressSound(mc.getSoundHandler());
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,6 @@ import net.minecraft.init.SoundEvents;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class CheckBox extends BasicControl {
|
public class CheckBox extends BasicControl {
|
||||||
|
|
||||||
private static final ResourceLocation texUnchecked = new ResourceLocation("webdisplays", "textures/gui/checkbox.png");
|
private static final ResourceLocation texUnchecked = new ResourceLocation("webdisplays", "textures/gui/checkbox.png");
|
||||||
|
|
@ -21,7 +19,7 @@ public class CheckBox extends BasicControl {
|
||||||
|
|
||||||
public static class CheckedEvent extends Event<CheckBox> {
|
public static class CheckedEvent extends Event<CheckBox> {
|
||||||
|
|
||||||
private boolean checked;
|
private final boolean checked;
|
||||||
|
|
||||||
private CheckedEvent(CheckBox cb) {
|
private CheckedEvent(CheckBox cb) {
|
||||||
source = cb;
|
source = cb;
|
||||||
|
|
@ -59,7 +57,7 @@ public class CheckBox extends BasicControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||||
if(mouseButton == 0 && !disabled) {
|
if(mouseButton == 0 && !disabled) {
|
||||||
if(mouseX >= x && mouseX <= x + WIDTH + 2 + labelW && mouseY >= y && mouseY < y + HEIGHT) {
|
if(mouseX >= x && mouseX <= x + WIDTH + 2 + labelW && mouseY >= y && mouseY < y + HEIGHT) {
|
||||||
checked = !checked;
|
checked = !checked;
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ public abstract class Container extends BasicControl {
|
||||||
|
|
||||||
protected int paddingX = 0;
|
protected int paddingX = 0;
|
||||||
protected int paddingY = 0;
|
protected int paddingY = 0;
|
||||||
protected ArrayList<Control> childs = new ArrayList<>();
|
protected final ArrayList<Control> childs = new ArrayList<>();
|
||||||
|
|
||||||
public <T extends Control> T addControl(T ctrl) {
|
public <T extends Control> T addControl(T ctrl) {
|
||||||
childs.add(ctrl);
|
childs.add(ctrl);
|
||||||
|
|
@ -48,7 +48,7 @@ public abstract class Container extends BasicControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||||
if(!disabled) {
|
if(!disabled) {
|
||||||
mouseX -= x + paddingX;
|
mouseX -= x + paddingX;
|
||||||
mouseY -= y + paddingY;
|
mouseY -= y + paddingY;
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import net.minecraft.client.shader.Framebuffer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.montoyo.wd.client.gui.WDScreen;
|
import net.montoyo.wd.client.gui.WDScreen;
|
||||||
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
||||||
|
import net.montoyo.wd.utilities.Bounds;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
@ -64,7 +65,7 @@ public abstract class Control {
|
||||||
public void keyDown(int key) {
|
public void keyDown(int key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseReleased(int mouseX, int mouseY, int state) {
|
public void mouseReleased(int mouseX, int mouseY, int state) {
|
||||||
|
|
@ -250,4 +251,32 @@ public abstract class Control {
|
||||||
name = json.getString("name", "");
|
name = json.getString("name", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Bounds findBounds(java.util.List<Control> controlList) {
|
||||||
|
int minX = Integer.MAX_VALUE;
|
||||||
|
int minY = Integer.MAX_VALUE;
|
||||||
|
int maxX = Integer.MIN_VALUE;
|
||||||
|
int maxY = Integer.MIN_VALUE;
|
||||||
|
|
||||||
|
for(Control ctrl : controlList) {
|
||||||
|
int x = ctrl.getX();
|
||||||
|
int y = ctrl.getY();
|
||||||
|
if(x < minX)
|
||||||
|
minX = x;
|
||||||
|
|
||||||
|
if(y < minY)
|
||||||
|
minY = y;
|
||||||
|
|
||||||
|
x += ctrl.getWidth();
|
||||||
|
y += ctrl.getHeight();
|
||||||
|
|
||||||
|
if(x > maxX)
|
||||||
|
maxX = x;
|
||||||
|
|
||||||
|
if(y >= maxY)
|
||||||
|
maxY = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Bounds(minX, minY, maxX, maxY);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ package net.montoyo.wd.client.gui.controls;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
||||||
|
import net.montoyo.wd.utilities.Bounds;
|
||||||
|
|
||||||
import static org.lwjgl.opengl.GL11.*;
|
import static org.lwjgl.opengl.GL11.*;
|
||||||
|
|
||||||
|
|
@ -161,37 +162,12 @@ public class ControlGroup extends Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pack() {
|
public void pack() {
|
||||||
int minX = Integer.MAX_VALUE;
|
Bounds bounds = findBounds(childs);
|
||||||
int minY = Integer.MAX_VALUE;
|
|
||||||
int maxX = Integer.MIN_VALUE;
|
|
||||||
int maxY = Integer.MIN_VALUE;
|
|
||||||
|
|
||||||
for(Control ctrl : childs) {
|
|
||||||
int x = ctrl.getX();
|
|
||||||
int y = ctrl.getY();
|
|
||||||
if(x < minX)
|
|
||||||
minX = x;
|
|
||||||
|
|
||||||
if(y < minY)
|
|
||||||
minY = y;
|
|
||||||
|
|
||||||
x += ctrl.getWidth();
|
|
||||||
y += ctrl.getHeight();
|
|
||||||
|
|
||||||
if(x > maxX)
|
|
||||||
maxX = x;
|
|
||||||
|
|
||||||
if(y >= maxY)
|
|
||||||
maxY = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(Control ctrl : childs)
|
for(Control ctrl : childs)
|
||||||
ctrl.setPos(ctrl.getX() - minX, ctrl.getY() - minY);
|
ctrl.setPos(ctrl.getX() - bounds.minX, ctrl.getY() - bounds.minY);
|
||||||
|
|
||||||
maxX -= minX;
|
width = bounds.getWidth() + paddingX * 2;
|
||||||
maxY -= minY;
|
height = bounds.getHeight() + paddingY * 2;
|
||||||
width = maxX + paddingX * 2;
|
|
||||||
height = maxY + paddingY * 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ package net.montoyo.wd.client.gui.controls;
|
||||||
import net.minecraft.client.shader.Framebuffer;
|
import net.minecraft.client.shader.Framebuffer;
|
||||||
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import static org.lwjgl.opengl.GL11.*;
|
import static org.lwjgl.opengl.GL11.*;
|
||||||
|
|
@ -15,8 +14,8 @@ import static org.lwjgl.opengl.GL11.*;
|
||||||
public class List extends BasicControl {
|
public class List extends BasicControl {
|
||||||
|
|
||||||
private static class Entry {
|
private static class Entry {
|
||||||
public String text;
|
public final String text;
|
||||||
public Object userdata;
|
public final Object userdata;
|
||||||
|
|
||||||
public Entry(String t, Object o) {
|
public Entry(String t, Object o) {
|
||||||
text = t;
|
text = t;
|
||||||
|
|
@ -27,8 +26,8 @@ public class List extends BasicControl {
|
||||||
|
|
||||||
public static class EntryClick extends Event<List> {
|
public static class EntryClick extends Event<List> {
|
||||||
|
|
||||||
private int id;
|
private final int id;
|
||||||
private Entry entry;
|
private final Entry entry;
|
||||||
|
|
||||||
private EntryClick(List lst) {
|
private EntryClick(List lst) {
|
||||||
source = lst;
|
source = lst;
|
||||||
|
|
@ -52,7 +51,7 @@ public class List extends BasicControl {
|
||||||
|
|
||||||
private int width;
|
private int width;
|
||||||
private int height;
|
private int height;
|
||||||
private ArrayList<Entry> content = new ArrayList<>();
|
private final ArrayList<Entry> content = new ArrayList<>();
|
||||||
private Framebuffer fbo;
|
private Framebuffer fbo;
|
||||||
private int selected = -1;
|
private int selected = -1;
|
||||||
private boolean update;
|
private boolean update;
|
||||||
|
|
@ -224,7 +223,7 @@ public class List extends BasicControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||||
if(!disabled && mouseButton == 0) {
|
if(!disabled && mouseButton == 0) {
|
||||||
if(isInScrollbar(mouseX, mouseY)) {
|
if(isInScrollbar(mouseX, mouseY)) {
|
||||||
scrolling = true;
|
scrolling = true;
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,13 @@ import net.minecraft.client.gui.GuiTextField;
|
||||||
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class TextField extends Control {
|
public class TextField extends Control {
|
||||||
|
|
||||||
public static class EnterPressedEvent extends Event<TextField> {
|
public static class EnterPressedEvent extends Event<TextField> {
|
||||||
|
|
||||||
private String text;
|
private final String text;
|
||||||
|
|
||||||
private EnterPressedEvent(TextField field) {
|
private EnterPressedEvent(TextField field) {
|
||||||
source = field;
|
source = field;
|
||||||
|
|
@ -30,7 +29,7 @@ public class TextField extends Control {
|
||||||
|
|
||||||
public static class TabPressedEvent extends Event<TextField> {
|
public static class TabPressedEvent extends Event<TextField> {
|
||||||
|
|
||||||
private String beginning;
|
private final String beginning;
|
||||||
|
|
||||||
private TabPressedEvent(TextField field) {
|
private TabPressedEvent(TextField field) {
|
||||||
source = field;
|
source = field;
|
||||||
|
|
@ -57,8 +56,8 @@ public class TextField extends Control {
|
||||||
|
|
||||||
public static class TextChangedEvent extends Event<TextField> {
|
public static class TextChangedEvent extends Event<TextField> {
|
||||||
|
|
||||||
private String oldContent;
|
private final String oldContent;
|
||||||
private String newContent;
|
private final String newContent;
|
||||||
|
|
||||||
private TextChangedEvent(TextField tf, String old) {
|
private TextChangedEvent(TextField tf, String old) {
|
||||||
source = tf;
|
source = tf;
|
||||||
|
|
@ -89,7 +88,7 @@ public class TextField extends Control {
|
||||||
private boolean enabled = true;
|
private boolean enabled = true;
|
||||||
private int textColor = DEFAULT_TEXT_COLOR;
|
private int textColor = DEFAULT_TEXT_COLOR;
|
||||||
private int disabledColor = DEFAULT_DISABLED_COLOR;
|
private int disabledColor = DEFAULT_DISABLED_COLOR;
|
||||||
private ArrayList<TextChangeListener> listeners = new ArrayList<>();
|
private final ArrayList<TextChangeListener> listeners = new ArrayList<>();
|
||||||
|
|
||||||
public TextField() {
|
public TextField() {
|
||||||
field = new GuiTextField(0, font, 1, 1, 198, 20);
|
field = new GuiTextField(0, font, 1, 1, 198, 20);
|
||||||
|
|
@ -105,7 +104,7 @@ public class TextField extends Control {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyTyped(char typedChar, int keyCode) throws IOException {
|
public void keyTyped(char typedChar, int keyCode) {
|
||||||
if(keyCode == Keyboard.KEY_RETURN || keyCode == Keyboard.KEY_NUMPADENTER)
|
if(keyCode == Keyboard.KEY_RETURN || keyCode == Keyboard.KEY_NUMPADENTER)
|
||||||
parent.actionPerformed(new EnterPressedEvent(this));
|
parent.actionPerformed(new EnterPressedEvent(this));
|
||||||
else if(keyCode == Keyboard.KEY_TAB)
|
else if(keyCode == Keyboard.KEY_TAB)
|
||||||
|
|
@ -129,7 +128,7 @@ public class TextField extends Control {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||||
field.mouseClicked(mouseX, mouseY, mouseButton);
|
field.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import net.minecraft.client.renderer.RenderItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class UpgradeGroup extends BasicControl {
|
public class UpgradeGroup extends BasicControl {
|
||||||
|
|
@ -96,7 +95,7 @@ public class UpgradeGroup extends BasicControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||||
if(mouseButton == 0)
|
if(mouseButton == 0)
|
||||||
clickStack = overStack;
|
clickStack = overStack;
|
||||||
}
|
}
|
||||||
|
|
@ -113,7 +112,7 @@ public class UpgradeGroup extends BasicControl {
|
||||||
|
|
||||||
public static class ClickEvent extends Event<UpgradeGroup> {
|
public static class ClickEvent extends Event<UpgradeGroup> {
|
||||||
|
|
||||||
private ItemStack clickStack;
|
private final ItemStack clickStack;
|
||||||
|
|
||||||
private ClickEvent(UpgradeGroup src) {
|
private ClickEvent(UpgradeGroup src) {
|
||||||
source = src;
|
source = src;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
package net.montoyo.wd.client.gui.loading;
|
package net.montoyo.wd.client.gui.loading;
|
||||||
|
|
||||||
import com.google.common.base.Throwables;
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
@ -20,18 +19,18 @@ import java.util.HashMap;
|
||||||
|
|
||||||
public class GuiLoader {
|
public class GuiLoader {
|
||||||
|
|
||||||
private static HashMap<String, Class<? extends Control>> controls = new HashMap<>();
|
private static final HashMap<String, Class<? extends Control>> CONTROLS = new HashMap<>();
|
||||||
private static HashMap<ResourceLocation, JsonObject> resources = new HashMap<>();
|
private static final HashMap<ResourceLocation, JsonObject> RESOURCES = new HashMap<>();
|
||||||
|
|
||||||
public static void register(Class<? extends Control> cls) {
|
public static void register(Class<? extends Control> cls) {
|
||||||
if(Modifier.isAbstract(cls.getModifiers()))
|
if(Modifier.isAbstract(cls.getModifiers()))
|
||||||
throw new RuntimeException("GG retard, you just registered an abstract class...");
|
throw new RuntimeException("GG retard, you just registered an abstract class...");
|
||||||
|
|
||||||
String name = cls.getSimpleName();
|
String name = cls.getSimpleName();
|
||||||
if(controls.containsKey(name))
|
if(CONTROLS.containsKey(name))
|
||||||
throw new RuntimeException("Control class already registered or name taken!");
|
throw new RuntimeException("Control class already registered or name taken!");
|
||||||
|
|
||||||
controls.put(name, cls);
|
CONTROLS.put(name, cls);
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
@ -50,7 +49,7 @@ public class GuiLoader {
|
||||||
Control ret;
|
Control ret;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ret = controls.get(json.getString("type", null)).newInstance();
|
ret = CONTROLS.get(json.getString("type", null)).newInstance();
|
||||||
} catch(InstantiationException e) {
|
} catch(InstantiationException e) {
|
||||||
Log.errorEx("Could not create control from JSON: instantiation exception", e);
|
Log.errorEx("Could not create control from JSON: instantiation exception", e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|
@ -64,7 +63,7 @@ public class GuiLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JsonObject getJson(ResourceLocation resLoc) {
|
public static JsonObject getJson(ResourceLocation resLoc) {
|
||||||
JsonObject ret = resources.get(resLoc);
|
JsonObject ret = RESOURCES.get(resLoc);
|
||||||
if(ret == null) {
|
if(ret == null) {
|
||||||
IResource resource;
|
IResource resource;
|
||||||
|
|
||||||
|
|
@ -82,14 +81,14 @@ public class GuiLoader {
|
||||||
resource.close();
|
resource.close();
|
||||||
} catch(IOException e) {}
|
} catch(IOException e) {}
|
||||||
|
|
||||||
resources.put(resLoc, ret);
|
RESOURCES.put(resLoc, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearCache() {
|
public static void clearCache() {
|
||||||
resources.clear();
|
RESOURCES.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
public final class ModelMinePad extends ModelBase {
|
public final class ModelMinePad extends ModelBase {
|
||||||
|
|
||||||
// fields
|
// fields
|
||||||
ModelRenderer base;
|
private final ModelRenderer base;
|
||||||
ModelRenderer left;
|
private final ModelRenderer left;
|
||||||
ModelRenderer right;
|
private final ModelRenderer right;
|
||||||
|
|
||||||
public ModelMinePad() {
|
public ModelMinePad() {
|
||||||
textureWidth = 64;
|
textureWidth = 64;
|
||||||
|
|
@ -26,19 +26,19 @@ public final class ModelMinePad extends ModelBase {
|
||||||
base.setRotationPoint(1F, 0F, 3.5F);
|
base.setRotationPoint(1F, 0F, 3.5F);
|
||||||
base.setTextureSize(64, 32);
|
base.setTextureSize(64, 32);
|
||||||
base.mirror = true;
|
base.mirror = true;
|
||||||
setRotation(base, 0F, 0F, 0F);
|
clearRotation(base);
|
||||||
left = new ModelRenderer(this, 0, 10);
|
left = new ModelRenderer(this, 0, 10);
|
||||||
left.addBox(0F, 0F, 0F, 1, 1, 7);
|
left.addBox(0F, 0F, 0F, 1, 1, 7);
|
||||||
left.setRotationPoint(0F, 0F, 4.5F);
|
left.setRotationPoint(0F, 0F, 4.5F);
|
||||||
left.setTextureSize(64, 32);
|
left.setTextureSize(64, 32);
|
||||||
left.mirror = true;
|
left.mirror = true;
|
||||||
setRotation(left, 0F, 0F, 0F);
|
clearRotation(left);
|
||||||
right = new ModelRenderer(this, 30, 10);
|
right = new ModelRenderer(this, 30, 10);
|
||||||
right.addBox(0F, 0F, 0F, 1, 1, 7);
|
right.addBox(0F, 0F, 0F, 1, 1, 7);
|
||||||
right.setRotationPoint(15F, 0F, 4.5F);
|
right.setRotationPoint(15F, 0F, 4.5F);
|
||||||
right.setTextureSize(64, 32);
|
right.setTextureSize(64, 32);
|
||||||
right.mirror = true;
|
right.mirror = true;
|
||||||
setRotation(right, 0F, 0F, 0F);
|
clearRotation(right);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void render(float f5) {
|
public final void render(float f5) {
|
||||||
|
|
@ -47,10 +47,10 @@ public final class ModelMinePad extends ModelBase {
|
||||||
right.render(f5);
|
right.render(f5);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setRotation(ModelRenderer model, float x, float y, float z) {
|
private void clearRotation(ModelRenderer model) {
|
||||||
model.rotateAngleX = x;
|
model.rotateAngleX = 0.0f;
|
||||||
model.rotateAngleY = y;
|
model.rotateAngleY = 0.0f;
|
||||||
model.rotateAngleZ = z;
|
model.rotateAngleZ = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import net.montoyo.wd.utilities.BlockSide;
|
||||||
import net.montoyo.wd.utilities.Vector3f;
|
import net.montoyo.wd.utilities.Vector3f;
|
||||||
import net.montoyo.wd.utilities.Vector3i;
|
import net.montoyo.wd.utilities.Vector3i;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -27,9 +28,9 @@ import java.util.List;
|
||||||
public class ScreenBaker implements IModelBaker {
|
public class ScreenBaker implements IModelBaker {
|
||||||
|
|
||||||
private static final List<BakedQuad> noQuads = ImmutableList.of();
|
private static final List<BakedQuad> noQuads = ImmutableList.of();
|
||||||
private TextureAtlasSprite[] texs = new TextureAtlasSprite[16];
|
private final TextureAtlasSprite[] texs = new TextureAtlasSprite[16];
|
||||||
private BlockSide[] blockSides = BlockSide.values();
|
private final BlockSide[] blockSides = BlockSide.values();
|
||||||
private EnumFacing[] blockFacings = EnumFacing.values();
|
private final EnumFacing[] blockFacings = EnumFacing.values();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadTextures(TextureMap texMap) {
|
public void loadTextures(TextureMap texMap) {
|
||||||
|
|
@ -89,6 +90,7 @@ public class ScreenBaker implements IModelBaker {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nonnull
|
||||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
|
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
|
||||||
if(side == null)
|
if(side == null)
|
||||||
return noQuads;
|
return noQuads;
|
||||||
|
|
@ -122,16 +124,19 @@ public class ScreenBaker implements IModelBaker {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nonnull
|
||||||
public TextureAtlasSprite getParticleTexture() {
|
public TextureAtlasSprite getParticleTexture() {
|
||||||
return texs[15];
|
return texs[15];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nonnull
|
||||||
public ItemCameraTransforms getItemCameraTransforms() {
|
public ItemCameraTransforms getItemCameraTransforms() {
|
||||||
return ItemCameraTransforms.DEFAULT;
|
return ItemCameraTransforms.DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nonnull
|
||||||
public ItemOverrideList getOverrides() {
|
public ItemOverrideList getOverrides() {
|
||||||
return ItemOverrideList.NONE;
|
return ItemOverrideList.NONE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.montoyo.wd.WebDisplays;
|
import net.montoyo.wd.WebDisplays;
|
||||||
import net.montoyo.wd.client.ClientProxy;
|
import net.montoyo.wd.client.ClientProxy;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.TileEntityScreen;
|
||||||
import net.montoyo.wd.utilities.Rotation;
|
|
||||||
import net.montoyo.wd.utilities.Vector3f;
|
import net.montoyo.wd.utilities.Vector3f;
|
||||||
import net.montoyo.wd.utilities.Vector3i;
|
import net.montoyo.wd.utilities.Vector3i;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.montoyo.wd.WebDisplays;
|
import net.montoyo.wd.WebDisplays;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class WDCreativeTab extends CreativeTabs {
|
public class WDCreativeTab extends CreativeTabs {
|
||||||
|
|
||||||
public WDCreativeTab() {
|
public WDCreativeTab() {
|
||||||
|
|
@ -15,6 +17,7 @@ public class WDCreativeTab extends CreativeTabs {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nonnull
|
||||||
public ItemStack getTabIconItem() {
|
public ItemStack getTabIconItem() {
|
||||||
return new ItemStack(WebDisplays.INSTANCE.blockScreen);
|
return new ItemStack(WebDisplays.INSTANCE.blockScreen);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import net.montoyo.wd.utilities.BlockSide;
|
||||||
import net.montoyo.wd.utilities.Log;
|
import net.montoyo.wd.utilities.Log;
|
||||||
import net.montoyo.wd.utilities.Vector3i;
|
import net.montoyo.wd.utilities.Vector3i;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public abstract class TileEntityPeripheralBase extends TileEntity implements IPeripheral {
|
public abstract class TileEntityPeripheralBase extends TileEntity implements IPeripheral {
|
||||||
|
|
@ -40,6 +41,7 @@ public abstract class TileEntityPeripheralBase extends TileEntity implements IPe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nonnull
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||||
super.writeToNBT(tag);
|
super.writeToNBT(tag);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ import net.montoyo.wd.data.RedstoneCtrlData;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
import net.montoyo.wd.utilities.Util;
|
import net.montoyo.wd.utilities.Util;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class TileEntityRedCtrl extends TileEntityPeripheralBase {
|
public class TileEntityRedCtrl extends TileEntityPeripheralBase {
|
||||||
|
|
||||||
private String risingEdgeURL = "";
|
private String risingEdgeURL = "";
|
||||||
|
|
@ -31,6 +33,7 @@ public class TileEntityRedCtrl extends TileEntityPeripheralBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nonnull
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||||
super.writeToNBT(tag);
|
super.writeToNBT(tag);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,7 @@ public class TileEntityScreen extends TileEntity {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<Screen> screens = new ArrayList<>();
|
private final ArrayList<Screen> screens = new ArrayList<>();
|
||||||
private AxisAlignedBB renderBB = new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
|
private AxisAlignedBB renderBB = new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
|
||||||
private boolean loaded = true;
|
private boolean loaded = true;
|
||||||
public float ytVolume = Float.POSITIVE_INFINITY;
|
public float ytVolume = Float.POSITIVE_INFINITY;
|
||||||
|
|
|
||||||
|
|
@ -37,16 +37,14 @@ public class TileEntityServer extends TileEntity {
|
||||||
markDirty();
|
markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onPlayerRightClick(EntityPlayer ply) {
|
public void onPlayerRightClick(EntityPlayer ply) {
|
||||||
if(world.isRemote)
|
if(world.isRemote)
|
||||||
return true;
|
return;
|
||||||
|
|
||||||
if(WebDisplays.INSTANCE.miniservPort == 0)
|
if(WebDisplays.INSTANCE.miniservPort == 0)
|
||||||
Util.toast(ply, "noMiniserv");
|
Util.toast(ply, "noMiniserv");
|
||||||
else if(owner != null && ply instanceof EntityPlayerMP)
|
else if(owner != null && ply instanceof EntityPlayerMP)
|
||||||
(new ServerData(pos, owner)).sendTo((EntityPlayerMP) ply);
|
(new ServerData(pos, owner)).sendTo((EntityPlayerMP) ply);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import com.mojang.realmsclient.gui.ChatFormatting;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.montoyo.wd.WebDisplays;
|
import net.montoyo.wd.WebDisplays;
|
||||||
import net.montoyo.wd.core.CraftComponent;
|
import net.montoyo.wd.core.CraftComponent;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
package net.montoyo.wd.item;
|
package net.montoyo.wd.item;
|
||||||
|
|
||||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import net.montoyo.wd.block.BlockScreen;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.TileEntityScreen;
|
||||||
import net.montoyo.wd.utilities.*;
|
import net.montoyo.wd.utilities.*;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -36,6 +37,7 @@ public class ItemOwnershipThief extends Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nonnull
|
||||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos_, EnumHand hand, EnumFacing side_, float hitX, float hitY, float hitZ) {
|
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos_, EnumHand hand, EnumFacing side_, float hitX, float hitY, float hitZ) {
|
||||||
if(player.isSneaking())
|
if(player.isSneaking())
|
||||||
return EnumActionResult.PASS;
|
return EnumActionResult.PASS;
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import net.montoyo.wd.WebDisplays;
|
||||||
import net.montoyo.wd.block.BlockKeyboardRight;
|
import net.montoyo.wd.block.BlockKeyboardRight;
|
||||||
import net.montoyo.wd.core.DefaultPeripheral;
|
import net.montoyo.wd.core.DefaultPeripheral;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -30,7 +31,7 @@ public class ItemPeripheral extends ItemMultiTexture {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceBlockOnSide(World world, BlockPos pos_, EnumFacing side, EntityPlayer player, ItemStack stack) {
|
public boolean canPlaceBlockOnSide(World world, @Nonnull BlockPos pos_, @Nonnull EnumFacing side, EntityPlayer player, ItemStack stack) {
|
||||||
if(stack.getMetadata() != 0) //Keyboard
|
if(stack.getMetadata() != 0) //Keyboard
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
@ -51,13 +52,15 @@ public class ItemPeripheral extends ItemMultiTexture {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack is, @Nullable World world, List<String> tt, ITooltipFlag ttFlags) {
|
public void addInformation(@Nullable ItemStack is, @Nullable World world, @Nullable List<String> tt, @Nullable ITooltipFlag ttFlags) {
|
||||||
if(is.getMetadata() == 1) //CC Interface
|
if(is != null && tt != null) {
|
||||||
tt.add("" + ChatFormatting.RED + I18n.format("webdisplays.message.missingCC")); //CC is not available for 1.12.2
|
if(is.getMetadata() == 1) //CC Interface
|
||||||
else if(is.getMetadata() == 2 && !WebDisplays.isOpenComputersAvailable()) //OC Interface
|
tt.add("" + ChatFormatting.RED + I18n.format("webdisplays.message.missingCC")); //CC is not available for 1.12.2
|
||||||
tt.add("" + ChatFormatting.RED + I18n.format("webdisplays.message.missingOC"));
|
else if(is.getMetadata() == 2 && !WebDisplays.isOpenComputersAvailable()) //OC Interface
|
||||||
else if(is.getMetadata() == 11 && WebDisplays.PROXY.isMiniservDisabled()) //Server
|
tt.add("" + ChatFormatting.RED + I18n.format("webdisplays.message.missingOC"));
|
||||||
tt.add("" + ChatFormatting.RED + I18n.format("webdisplays.message.noMiniserv"));
|
else if(is.getMetadata() == 11 && WebDisplays.PROXY.isMiniservDisabled()) //Server
|
||||||
|
tt.add("" + ChatFormatting.RED + I18n.format("webdisplays.message.noMiniserv"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ import net.montoyo.wd.utilities.Multiblock;
|
||||||
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.Nonnull;
|
||||||
|
|
||||||
public class ItemScreenConfigurator extends Item {
|
public class ItemScreenConfigurator extends Item {
|
||||||
|
|
||||||
public ItemScreenConfigurator() {
|
public ItemScreenConfigurator() {
|
||||||
|
|
@ -32,6 +34,7 @@ public class ItemScreenConfigurator extends Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nonnull
|
||||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side_, float hitX, float hitY, float hitZ) {
|
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side_, float hitX, float hitY, float hitZ) {
|
||||||
if(player.isSneaking() || !(world.getBlockState(pos).getBlock() instanceof BlockScreen))
|
if(player.isSneaking() || !(world.getBlockState(pos).getBlock() instanceof BlockScreen))
|
||||||
return EnumActionResult.PASS;
|
return EnumActionResult.PASS;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.channels.ClosedChannelException;
|
|
||||||
import java.nio.channels.SelectionKey;
|
import java.nio.channels.SelectionKey;
|
||||||
import java.nio.channels.Selector;
|
import java.nio.channels.Selector;
|
||||||
import java.nio.channels.SocketChannel;
|
import java.nio.channels.SocketChannel;
|
||||||
|
|
|
||||||
|
|
@ -6,23 +6,23 @@ package net.montoyo.wd.miniserv;
|
||||||
|
|
||||||
public abstract class Constants {
|
public abstract class Constants {
|
||||||
|
|
||||||
public static int FUPA_STATUS_BAD_NAME = 1;
|
public static final int FUPA_STATUS_BAD_NAME = 1;
|
||||||
public static int FUPA_STATUS_INVALID_SIZE = 2;
|
public static final int FUPA_STATUS_INVALID_SIZE = 2;
|
||||||
public static int FUPA_STATUS_EXCEEDS_QUOTA = 3;
|
public static final int FUPA_STATUS_EXCEEDS_QUOTA = 3;
|
||||||
public static int FUPA_STATUS_OCCUPIED = 4;
|
public static final int FUPA_STATUS_OCCUPIED = 4;
|
||||||
public static int FUPA_STATUS_FILE_EXISTS = 5;
|
public static final int FUPA_STATUS_FILE_EXISTS = 5;
|
||||||
public static int FUPA_STATUS_INTERNAL_ERROR = 6;
|
public static final int FUPA_STATUS_INTERNAL_ERROR = 6;
|
||||||
public static int FUPA_STATUS_USER_ABORT = 7;
|
public static final int FUPA_STATUS_USER_ABORT = 7;
|
||||||
public static int FUPA_STATUS_LIER = 8;
|
public static final int FUPA_STATUS_LIER = 8;
|
||||||
public static int FUPA_STATUS_CONNECTION_LOST = 9;
|
public static final int FUPA_STATUS_CONNECTION_LOST = 9;
|
||||||
|
|
||||||
public static int GETF_STATUS_BAD_NAME = 1;
|
public static final int GETF_STATUS_BAD_NAME = 1;
|
||||||
public static int GETF_STATUS_NOT_FOUND = 2;
|
public static final int GETF_STATUS_NOT_FOUND = 2;
|
||||||
public static int GETF_STATUS_INTERNAL_ERROR = 3;
|
public static final int GETF_STATUS_INTERNAL_ERROR = 3;
|
||||||
public static int GETF_STATUS_CONNECTION_LOST = 4;
|
public static final int GETF_STATUS_CONNECTION_LOST = 4;
|
||||||
public static int GETF_STATUS_TIMED_OUT = 5;
|
public static final int GETF_STATUS_TIMED_OUT = 5;
|
||||||
|
|
||||||
public static long CLIENT_TIMEOUT = 30000L;
|
public static final long CLIENT_TIMEOUT = 30000L;
|
||||||
public static long CLIENT_PING_PERIOD = 5000L;
|
public static final long CLIENT_PING_PERIOD = 5000L;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -337,10 +337,6 @@ public class Client extends AbstractClient implements Runnable {
|
||||||
((ClientTaskDeleteFile) currentTask).onStatusPacket(dis.readByte());
|
((ClientTaskDeleteFile) currentTask).onStatusPacket(dis.readByte());
|
||||||
}
|
}
|
||||||
|
|
||||||
@PacketHandler(PacketID.PING)
|
|
||||||
public void handlePing(DataInputStream dis) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void nextTask() {
|
public void nextTask() {
|
||||||
if(currentTask != null)
|
if(currentTask != null)
|
||||||
currentTask.onFinished();
|
currentTask.onFinished();
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,6 @@ public class Server implements Runnable {
|
||||||
|
|
||||||
clientMap.put(chan, toAdd);
|
clientMap.put(chan, toAdd);
|
||||||
clientList.add(toAdd);
|
clientList.add(toAdd);
|
||||||
toAdd.onConnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,9 +50,6 @@ public class ServerClient extends AbstractClient {
|
||||||
remove = true;
|
remove = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onConnect() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void setShouldRemove() {
|
void setShouldRemove() {
|
||||||
remove = true;
|
remove = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
public abstract class Messages {
|
public abstract class Messages {
|
||||||
|
|
||||||
private static DefaultHandler DEFAULT_HANDLER = new DefaultHandler();
|
private static final DefaultHandler DEFAULT_HANDLER = new DefaultHandler();
|
||||||
private static Class<? extends IMessage>[] messages;
|
private static final Class<? extends IMessage>[] MESSAGES;
|
||||||
static {
|
static {
|
||||||
ArrayList<Class<? extends IMessage>> l = new ArrayList<>();
|
ArrayList<Class<? extends IMessage>> l = new ArrayList<>();
|
||||||
l.add(CMessageAddScreen.class);
|
l.add(CMessageAddScreen.class);
|
||||||
|
|
@ -34,11 +34,11 @@ public abstract class Messages {
|
||||||
l.add(CMessageServerInfo.class);
|
l.add(CMessageServerInfo.class);
|
||||||
l.add(CMessageCloseGui.class);
|
l.add(CMessageCloseGui.class);
|
||||||
|
|
||||||
messages = l.toArray(new Class[0]);
|
MESSAGES = l.toArray(new Class[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerAll(SimpleNetworkWrapper wrapper) {
|
public static void registerAll(SimpleNetworkWrapper wrapper) {
|
||||||
for(Class<? extends IMessage> md: messages) {
|
for(Class<? extends IMessage> md: MESSAGES) {
|
||||||
Message data = md.getAnnotation(Message.class);
|
Message data = md.getAnnotation(Message.class);
|
||||||
if(data == null)
|
if(data == null)
|
||||||
throw new RuntimeException("Missing @Message annotation for message class " + md.getSimpleName());
|
throw new RuntimeException("Missing @Message annotation for message class " + md.getSimpleName());
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,7 @@ public class CMessageScreenUpdate implements IMessage, Runnable {
|
||||||
} else if(action == UPDATE_ROTATION)
|
} else if(action == UPDATE_ROTATION)
|
||||||
tes.setRotation(side, rotation);
|
tes.setRotation(side, rotation);
|
||||||
else
|
else
|
||||||
Log.warning("===> TODO"); //TODO
|
Log.warning("Caught invalid CMessageScreenUpdate with action ID %d", action);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ import net.montoyo.wd.net.Message;
|
||||||
import net.montoyo.wd.net.client.CMessageACResult;
|
import net.montoyo.wd.net.client.CMessageACResult;
|
||||||
import net.montoyo.wd.utilities.NameUUIDPair;
|
import net.montoyo.wd.utilities.NameUUIDPair;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@Message(messageId = 5, side = Side.SERVER)
|
@Message(messageId = 5, side = Side.SERVER)
|
||||||
|
|
|
||||||
|
|
@ -337,7 +337,7 @@ public class SMessageScreenCtrl implements IMessage, Runnable {
|
||||||
checkPermission(tes, ScreenRights.CHANGE_RESOLUTION);
|
checkPermission(tes, ScreenRights.CHANGE_RESOLUTION);
|
||||||
tes.setRotation(side, rotation);
|
tes.setRotation(side, rotation);
|
||||||
} else
|
} else
|
||||||
Log.info("SMessageScreenCtrl: TODO"); //TODO: other ctrl messages
|
Log.warning("Caught SMessageScreenCtrl with invalid control ID %d from player %s (UUID %s)", ctrl, player.getName(), player.getGameProfile().getId().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Handler implements IMessageHandler<SMessageScreenCtrl, IMessage> {
|
public static class Handler implements IMessageHandler<SMessageScreenCtrl, IMessage> {
|
||||||
|
|
|
||||||
29
src/main/java/net/montoyo/wd/utilities/Bounds.java
Normal file
29
src/main/java/net/montoyo/wd/utilities/Bounds.java
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2018 BARBOTIN Nicolas
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.montoyo.wd.utilities;
|
||||||
|
|
||||||
|
public final class Bounds {
|
||||||
|
|
||||||
|
public final int minX;
|
||||||
|
public final int minY;
|
||||||
|
public final int maxX;
|
||||||
|
public final int maxY;
|
||||||
|
|
||||||
|
public Bounds(int minX, int minY, int maxX, int maxY) {
|
||||||
|
this.minX = minX;
|
||||||
|
this.minY = minY;
|
||||||
|
this.maxX = maxX;
|
||||||
|
this.maxY = maxY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getWidth() {
|
||||||
|
return maxX - minX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getHeight() {
|
||||||
|
return maxY - minY;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -6,7 +6,7 @@ package net.montoyo.wd.utilities;
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.montoyo.wd.block.BlockScreen;
|
import net.montoyo.wd.WebDisplays;
|
||||||
|
|
||||||
public abstract class Multiblock {
|
public abstract class Multiblock {
|
||||||
|
|
||||||
|
|
@ -50,7 +50,7 @@ public abstract class Multiblock {
|
||||||
do {
|
do {
|
||||||
pos.add(side.left);
|
pos.add(side.left);
|
||||||
pos.toBlock(bp);
|
pos.toBlock(bp);
|
||||||
} while(override.apply(pos, world.getBlockState(bp).getBlock() instanceof BlockScreen));
|
} while(override.apply(pos, world.getBlockState(bp).getBlock() == WebDisplays.INSTANCE.blockScreen));
|
||||||
|
|
||||||
pos.add(side.right);
|
pos.add(side.right);
|
||||||
|
|
||||||
|
|
@ -58,7 +58,7 @@ public abstract class Multiblock {
|
||||||
do {
|
do {
|
||||||
pos.add(side.down);
|
pos.add(side.down);
|
||||||
pos.toBlock(bp);
|
pos.toBlock(bp);
|
||||||
} while(override.apply(pos, world.getBlockState(bp).getBlock() instanceof BlockScreen));
|
} while(override.apply(pos, world.getBlockState(bp).getBlock() == WebDisplays.INSTANCE.blockScreen));
|
||||||
|
|
||||||
pos.add(side.up);
|
pos.add(side.up);
|
||||||
}
|
}
|
||||||
|
|
@ -77,7 +77,7 @@ public abstract class Multiblock {
|
||||||
pos.add(side.up);
|
pos.add(side.up);
|
||||||
pos.toBlock(bp);
|
pos.toBlock(bp);
|
||||||
ret.y++;
|
ret.y++;
|
||||||
} while(world.getBlockState(bp).getBlock() instanceof BlockScreen);
|
} while(world.getBlockState(bp).getBlock() == WebDisplays.INSTANCE.blockScreen);
|
||||||
|
|
||||||
pos.add(side.down);
|
pos.add(side.down);
|
||||||
|
|
||||||
|
|
@ -86,7 +86,7 @@ public abstract class Multiblock {
|
||||||
pos.add(side.right);
|
pos.add(side.right);
|
||||||
pos.toBlock(bp);
|
pos.toBlock(bp);
|
||||||
ret.x++;
|
ret.x++;
|
||||||
} while(world.getBlockState(bp).getBlock() instanceof BlockScreen);
|
} while(world.getBlockState(bp).getBlock() == WebDisplays.INSTANCE.blockScreen);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -102,17 +102,17 @@ public abstract class Multiblock {
|
||||||
for(int y = 0; y < size.y; y++) {
|
for(int y = 0; y < size.y; y++) {
|
||||||
for(int x = 0; x < size.x; x++) {
|
for(int x = 0; x < size.x; x++) {
|
||||||
pos.toBlock(bp);
|
pos.toBlock(bp);
|
||||||
if(!(world.getBlockState(bp).getBlock() instanceof BlockScreen))
|
if(!(world.getBlockState(bp).getBlock() == WebDisplays.INSTANCE.blockScreen))
|
||||||
return pos; //Hole
|
return pos; //Hole
|
||||||
|
|
||||||
pos.add(side.forward);
|
pos.add(side.forward);
|
||||||
pos.toBlock(bp);
|
pos.toBlock(bp);
|
||||||
if(world.getBlockState(bp).getBlock() instanceof BlockScreen)
|
if(world.getBlockState(bp).getBlock() == WebDisplays.INSTANCE.blockScreen)
|
||||||
return pos; //Back should be empty
|
return pos; //Back should be empty
|
||||||
|
|
||||||
pos.addMul(side.backward, 2);
|
pos.addMul(side.backward, 2);
|
||||||
pos.toBlock(bp);
|
pos.toBlock(bp);
|
||||||
if(world.getBlockState(bp).getBlock() instanceof BlockScreen)
|
if(world.getBlockState(bp).getBlock() == WebDisplays.INSTANCE.blockScreen)
|
||||||
return pos; //Front should be empty
|
return pos; //Front should be empty
|
||||||
|
|
||||||
pos.add(side.forward);
|
pos.add(side.forward);
|
||||||
|
|
@ -129,7 +129,7 @@ public abstract class Multiblock {
|
||||||
|
|
||||||
for(int y = 0; y < size.y; y++) {
|
for(int y = 0; y < size.y; y++) {
|
||||||
pos.toBlock(bp);
|
pos.toBlock(bp);
|
||||||
if(world.getBlockState(bp).getBlock() instanceof BlockScreen)
|
if(world.getBlockState(bp).getBlock() == WebDisplays.INSTANCE.blockScreen)
|
||||||
return pos; //Left edge should be empty
|
return pos; //Left edge should be empty
|
||||||
|
|
||||||
pos.add(side.up);
|
pos.add(side.up);
|
||||||
|
|
@ -141,7 +141,7 @@ public abstract class Multiblock {
|
||||||
|
|
||||||
for(int y = 0; y < size.y; y++) {
|
for(int y = 0; y < size.y; y++) {
|
||||||
pos.toBlock(bp);
|
pos.toBlock(bp);
|
||||||
if(world.getBlockState(bp).getBlock() instanceof BlockScreen)
|
if(world.getBlockState(bp).getBlock() == WebDisplays.INSTANCE.blockScreen)
|
||||||
return pos; //Left edge should be empty
|
return pos; //Left edge should be empty
|
||||||
|
|
||||||
pos.add(side.up);
|
pos.add(side.up);
|
||||||
|
|
@ -153,7 +153,7 @@ public abstract class Multiblock {
|
||||||
|
|
||||||
for(int x = 0; x < size.x; x++) {
|
for(int x = 0; x < size.x; x++) {
|
||||||
pos.toBlock(bp);
|
pos.toBlock(bp);
|
||||||
if(world.getBlockState(bp).getBlock() instanceof BlockScreen)
|
if(world.getBlockState(bp).getBlock() == WebDisplays.INSTANCE.blockScreen)
|
||||||
return pos; //Left edge should be empty
|
return pos; //Left edge should be empty
|
||||||
|
|
||||||
pos.add(side.right);
|
pos.add(side.right);
|
||||||
|
|
@ -165,7 +165,7 @@ public abstract class Multiblock {
|
||||||
|
|
||||||
for(int x = 0; x < size.x; x++) {
|
for(int x = 0; x < size.x; x++) {
|
||||||
pos.toBlock(bp);
|
pos.toBlock(bp);
|
||||||
if(world.getBlockState(bp).getBlock() instanceof BlockScreen)
|
if(world.getBlockState(bp).getBlock() == WebDisplays.INSTANCE.blockScreen)
|
||||||
return pos; //Left edge should be empty
|
return pos; //Left edge should be empty
|
||||||
|
|
||||||
pos.add(side.right);
|
pos.add(side.right);
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
@ -108,33 +107,6 @@ public abstract class Util {
|
||||||
throw new RuntimeException(String.format("Cannot unserialize class %s!", cls.getName()));
|
throw new RuntimeException(String.format("Cannot unserialize class %s!", cls.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] commaSplit(String str) {
|
|
||||||
ArrayList<String> lst = new ArrayList<>();
|
|
||||||
String out = "";
|
|
||||||
boolean escape = false;
|
|
||||||
|
|
||||||
for(int i = 0; i < str.length(); i++) {
|
|
||||||
char c = str.charAt(i);
|
|
||||||
|
|
||||||
if(c == '\\' && !escape) {
|
|
||||||
escape = true;
|
|
||||||
continue; //Otherwise it'll set escape back to false
|
|
||||||
} else if(c == ',' && !escape) {
|
|
||||||
lst.add(out);
|
|
||||||
out = "";
|
|
||||||
} else
|
|
||||||
out += c;
|
|
||||||
|
|
||||||
if(escape)
|
|
||||||
escape = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
lst.add(out);
|
|
||||||
|
|
||||||
String[] ret = new String[lst.size()];
|
|
||||||
return lst.toArray(ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String addSlashes(String str) {
|
public static String addSlashes(String str) {
|
||||||
String out = "";
|
String out = "";
|
||||||
for(int i = 0; i < str.length(); i++) {
|
for(int i = 0; i < str.length(); i++) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user