* Updated MCEF API to latest version
* Fixed GUIs-not-closing-on-destruction bug
This commit is contained in:
parent
6d6a64e2de
commit
c6128dc065
|
|
@ -2,8 +2,6 @@
|
|||
This is the unfinished port of the WebDisplays mod for Minecraft 1.12.2. The text below is my "TODO" list.
|
||||
|
||||
### Bugs to fix
|
||||
* Memory leak (screens aren't deleted?!?)
|
||||
* GUIs are not closed blocks gets destroyed
|
||||
* Remove remaining printed debug infos and check for TODOs
|
||||
|
||||
### Things before release
|
||||
|
|
@ -21,3 +19,4 @@ This is the unfinished port of the WebDisplays mod for Minecraft 1.12.2. The tex
|
|||
* minePad management: check GuiContainer.draggedStack for minePad
|
||||
* In-game command to add/remove blacklisted domains
|
||||
* Config: RPMP (Real pixels per Minecraft pixels)
|
||||
* Disable miniserv in solo
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -7,6 +7,7 @@ package net.montoyo.wd;
|
|||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.fml.server.FMLServerHandler;
|
||||
|
|
@ -98,4 +99,7 @@ public class SharedProxy {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void closeGui(BlockPos bp, BlockSide bs) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import net.minecraft.util.math.Vec3i;
|
|||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
import net.montoyo.wd.core.DefaultPeripheral;
|
||||
import net.montoyo.wd.entity.TileEntityKeyboard;
|
||||
|
|
@ -38,6 +39,7 @@ import net.montoyo.wd.entity.TileEntityPeripheralBase;
|
|||
import net.montoyo.wd.entity.TileEntityServer;
|
||||
import net.montoyo.wd.item.ItemLinker;
|
||||
import net.montoyo.wd.item.ItemPeripheral;
|
||||
import net.montoyo.wd.net.client.CMessageCloseGui;
|
||||
import net.montoyo.wd.utilities.BlockSide;
|
||||
import net.montoyo.wd.utilities.Log;
|
||||
|
||||
|
|
@ -241,19 +243,23 @@ public class BlockPeripheral extends WDBlockContainer {
|
|||
removeRightPiece(world, pos);
|
||||
world.setBlockToAir(pos);
|
||||
dropBlockAsItem(world, pos, state, 0);
|
||||
WebDisplays.NET_HANDLER.sendToAllAround(new CMessageCloseGui(pos), point(world, pos));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockDestroyedByPlayer(World world, BlockPos pos, IBlockState state) {
|
||||
if(!world.isRemote && state.getValue(type) == DefaultPeripheral.KEYBOARD)
|
||||
removeRightPiece(world, pos);
|
||||
if(!world.isRemote) {
|
||||
if(state.getBlock() == this && state.getValue(type) == DefaultPeripheral.KEYBOARD)
|
||||
removeRightPiece(world, pos);
|
||||
|
||||
WebDisplays.NET_HANDLER.sendToAllAround(new CMessageCloseGui(pos), point(world, pos));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockDestroyedByExplosion(World world, BlockPos pos, Explosion explosion) {
|
||||
if(!world.isRemote && world.getBlockState(pos).getValue(type) == DefaultPeripheral.KEYBOARD)
|
||||
removeRightPiece(world, pos);
|
||||
onBlockDestroyedByPlayer(world, pos, world.getBlockState(pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -270,4 +276,8 @@ public class BlockPeripheral extends WDBlockContainer {
|
|||
}
|
||||
}
|
||||
|
||||
private static NetworkRegistry.TargetPoint point(World world, BlockPos bp) {
|
||||
return new NetworkRegistry.TargetPoint(world.provider.getDimension(), (double) bp.getX(), (double) bp.getY(), (double) bp.getZ(), 64.0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ public class BlockScreen extends WDBlockContainer {
|
|||
}
|
||||
|
||||
boolean created = false;
|
||||
Log.info("Structure at %s of size %dx%d", pos.toString(), size.x, size.y);
|
||||
Log.info("Player %s (UUID %s) created a screen at %s of size %dx%d", player.getName(), player.getGameProfile().getId().toString(), pos.toString(), size.x, size.y);
|
||||
|
||||
if(te == null) {
|
||||
BlockPos bp = pos.toBlock();
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ public class ClientProxy extends SharedProxy implements IResourceManagerReloadLi
|
|||
if(mc.currentScreen != null && mc.currentScreen instanceof GuiScreenConfig) {
|
||||
GuiScreenConfig gsc = (GuiScreenConfig) mc.currentScreen;
|
||||
|
||||
if(gsc.isScreen(pos, side))
|
||||
if(gsc.isForBlock(pos.toBlock(), side))
|
||||
gsc.updateResolution(res);
|
||||
}
|
||||
}
|
||||
|
|
@ -217,7 +217,7 @@ public class ClientProxy extends SharedProxy implements IResourceManagerReloadLi
|
|||
if(mc.currentScreen != null && mc.currentScreen instanceof GuiScreenConfig) {
|
||||
GuiScreenConfig gsc = (GuiScreenConfig) mc.currentScreen;
|
||||
|
||||
if(gsc.isScreen(pos, side))
|
||||
if(gsc.isForBlock(pos.toBlock(), side))
|
||||
gsc.updateRotation(rot);
|
||||
}
|
||||
}
|
||||
|
|
@ -338,6 +338,16 @@ public class ClientProxy extends SharedProxy implements IResourceManagerReloadLi
|
|||
return miniservPort <= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeGui(BlockPos bp, BlockSide bs) {
|
||||
if(mc.currentScreen instanceof WDScreen) {
|
||||
WDScreen scr = (WDScreen) mc.currentScreen;
|
||||
|
||||
if(scr.isForBlock(bp, bs))
|
||||
mc.displayGuiScreen(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************** RESOURCE MANAGER METHODS ****************************************/
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -152,11 +152,6 @@ public class GuiKeyboard extends WDScreen {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sync() {
|
||||
if(!eventStack.isEmpty()) {
|
||||
|
|
@ -217,4 +212,9 @@ public class GuiKeyboard extends WDScreen {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForBlock(BlockPos bp, BlockSide side) {
|
||||
return bp.equals(kbPos) || (bp.equals(tes.getPos()) && side == this.side);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,10 +7,12 @@ package net.montoyo.wd.client.gui;
|
|||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
import net.montoyo.wd.client.ClientProxy;
|
||||
import net.montoyo.wd.utilities.BlockSide;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
|
|
@ -135,8 +137,7 @@ public class GuiMinePad extends WDScreen {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame() {
|
||||
//TODO: Is this necessary??
|
||||
public boolean isForBlock(BlockPos bp, BlockSide side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,13 @@
|
|||
package net.montoyo.wd.client.gui;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
import net.montoyo.wd.client.gui.controls.Button;
|
||||
import net.montoyo.wd.client.gui.controls.TextField;
|
||||
import net.montoyo.wd.client.gui.loading.FillControl;
|
||||
import net.montoyo.wd.net.server.SMessageRedstoneCtrl;
|
||||
import net.montoyo.wd.utilities.BlockSide;
|
||||
import net.montoyo.wd.utilities.Util;
|
||||
import net.montoyo.wd.utilities.Vector3i;
|
||||
|
||||
|
|
@ -58,4 +60,9 @@ public class GuiRedstoneCtrl extends WDScreen {
|
|||
mc.displayGuiScreen(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForBlock(BlockPos bp, BlockSide side) {
|
||||
return pos.equalsBlockPos(bp);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ package net.montoyo.wd.client.gui;
|
|||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
import net.montoyo.wd.client.gui.controls.*;
|
||||
import net.montoyo.wd.client.gui.loading.FillControl;
|
||||
|
|
@ -413,10 +414,6 @@ public class GuiScreenConfig extends WDScreen {
|
|||
otherRights = updateRights(otherRights, rights, otherBoxes, false);
|
||||
}
|
||||
|
||||
public boolean isScreen(Vector3i pos, BlockSide side) {
|
||||
return pos.x == tes.getPos().getX() && pos.y == tes.getPos().getY() && pos.z == tes.getPos().getZ() && side == this.side;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sync() {
|
||||
WebDisplays.NET_HANDLER.sendToServer(new SMessageScreenCtrl(tes, side, friendRights, otherRights));
|
||||
|
|
@ -471,4 +468,9 @@ public class GuiScreenConfig extends WDScreen {
|
|||
updateRotationStr();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForBlock(BlockPos bp, BlockSide side) {
|
||||
return bp.equals(tes.getPos()) && side == this.side;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,12 +13,11 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
|||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
import net.montoyo.wd.miniserv.Constants;
|
||||
import net.montoyo.wd.miniserv.client.*;
|
||||
import net.montoyo.wd.utilities.Log;
|
||||
import net.montoyo.wd.utilities.NameUUIDPair;
|
||||
import net.montoyo.wd.utilities.Util;
|
||||
import net.montoyo.wd.utilities.*;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import javax.swing.filechooser.FileSystemView;
|
||||
|
|
@ -42,6 +41,7 @@ public class GuiServer extends WDScreen {
|
|||
private static final int MAX_LINE_LEN = 32;
|
||||
private static final int MAX_LINES = 12;
|
||||
|
||||
private final Vector3i serverPos;
|
||||
private final NameUUIDPair owner;
|
||||
private final ArrayList<String> lines = new ArrayList<>();
|
||||
private String prompt = "";
|
||||
|
|
@ -68,7 +68,8 @@ public class GuiServer extends WDScreen {
|
|||
private String uploadFilter = "";
|
||||
private long uploadFilterTime;
|
||||
|
||||
public GuiServer(NameUUIDPair owner) {
|
||||
public GuiServer(Vector3i vec, NameUUIDPair owner) {
|
||||
serverPos = vec;
|
||||
this.owner = owner;
|
||||
//userPrompt = owner.name + "@miniserv$ ";
|
||||
userPrompt = "> ";
|
||||
|
|
@ -695,4 +696,8 @@ public class GuiServer extends WDScreen {
|
|||
writeLine(tr("upload.uploading"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForBlock(BlockPos bp, BlockSide side) {
|
||||
return serverPos.equalsBlockPos(bp);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ package net.montoyo.wd.client.gui;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.montoyo.mcef.api.IBrowser;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
import net.montoyo.wd.client.ClientProxy;
|
||||
|
|
@ -112,4 +113,9 @@ public class GuiSetURL2 extends WDScreen {
|
|||
mc.displayGuiScreen(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForBlock(BlockPos bp, BlockSide side) {
|
||||
return (remoteLocation != null && remoteLocation.equalsBlockPos(bp)) || (bp.equals(tileEntity.getPos()) && side == screenSide);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
import net.montoyo.wd.client.gui.controls.Container;
|
||||
import net.montoyo.wd.client.gui.controls.Control;
|
||||
|
|
@ -19,6 +20,7 @@ import net.montoyo.wd.client.gui.loading.FillControl;
|
|||
import net.montoyo.wd.client.gui.loading.GuiLoader;
|
||||
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
||||
import net.montoyo.wd.net.server.SMessageACQuery;
|
||||
import net.montoyo.wd.utilities.BlockSide;
|
||||
import net.montoyo.wd.utilities.Log;
|
||||
import net.montoyo.wd.utilities.NameUUIDPair;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
|
@ -364,4 +366,11 @@ public abstract class WDScreen extends GuiScreen {
|
|||
postDrawList.add(ctrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract boolean isForBlock(BlockPos bp, BlockSide side);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class ScreenConfigData extends GuiData {
|
|||
if(old != null && old instanceof GuiScreenConfig) {
|
||||
GuiScreenConfig gsc = (GuiScreenConfig) old;
|
||||
|
||||
if(gsc.isScreen(pos, side)) {
|
||||
if(gsc.isForBlock(pos.toBlock(), side)) {
|
||||
gsc.updateFriends(friends);
|
||||
gsc.updateFriendRights(friendRights);
|
||||
gsc.updateOtherRights(otherRights);
|
||||
|
|
|
|||
|
|
@ -5,27 +5,31 @@
|
|||
package net.montoyo.wd.data;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.montoyo.wd.client.gui.GuiServer;
|
||||
import net.montoyo.wd.utilities.NameUUIDPair;
|
||||
import net.montoyo.wd.utilities.Vector3i;
|
||||
|
||||
public class ServerData extends GuiData {
|
||||
|
||||
public Vector3i pos;
|
||||
public NameUUIDPair owner;
|
||||
|
||||
public ServerData() {
|
||||
}
|
||||
|
||||
public ServerData(NameUUIDPair owner) {
|
||||
public ServerData(BlockPos bp, NameUUIDPair owner) {
|
||||
pos = new Vector3i(bp);
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public GuiScreen createGui(GuiScreen old, World world) {
|
||||
return new GuiServer(owner);
|
||||
return new GuiServer(pos, owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import net.montoyo.wd.core.JSServerRequest;
|
|||
import net.montoyo.wd.core.ScreenRights;
|
||||
import net.montoyo.wd.data.ScreenConfigData;
|
||||
import net.montoyo.wd.net.client.CMessageAddScreen;
|
||||
import net.montoyo.wd.net.client.CMessageCloseGui;
|
||||
import net.montoyo.wd.net.client.CMessageJSResponse;
|
||||
import net.montoyo.wd.net.client.CMessageScreenUpdate;
|
||||
import net.montoyo.wd.net.server.SMessageRequestTEData;
|
||||
|
|
@ -688,14 +689,6 @@ public class TileEntityScreen extends TileEntity {
|
|||
}
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public void validate() {
|
||||
super.validate();
|
||||
|
||||
if(world.isRemote)
|
||||
Log.info("===> TES( VALIDATE) %s", pos.toString());
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
|
|
@ -844,7 +837,7 @@ public class TileEntityScreen extends TileEntity {
|
|||
}
|
||||
|
||||
IUpgrade itemAsUpgrade = (IUpgrade) is.getItem();
|
||||
if(abortIfExisting && scr.upgrades.stream().anyMatch((otherStack) -> itemAsUpgrade.isSameUpgrade(is, otherStack)))
|
||||
if(abortIfExisting && scr.upgrades.stream().anyMatch(otherStack -> itemAsUpgrade.isSameUpgrade(is, otherStack)))
|
||||
return false; //Upgrade already exists
|
||||
|
||||
ItemStack isCopy = is.copy(); //FIXME: Duct tape fix, because the original stack will be shrinked
|
||||
|
|
@ -867,7 +860,7 @@ public class TileEntityScreen extends TileEntity {
|
|||
return false;
|
||||
|
||||
IUpgrade itemAsUpgrade = (IUpgrade) is.getItem();
|
||||
return scr.upgrades.stream().anyMatch((otherStack) -> itemAsUpgrade.isSameUpgrade(is, otherStack));
|
||||
return scr.upgrades.stream().anyMatch(otherStack -> itemAsUpgrade.isSameUpgrade(is, otherStack));
|
||||
}
|
||||
|
||||
public boolean hasUpgrade(BlockSide side, DefaultUpgrade du) {
|
||||
|
|
@ -950,10 +943,6 @@ public class TileEntityScreen extends TileEntity {
|
|||
}
|
||||
|
||||
public void laserDownMove(BlockSide side, EntityPlayer ply, Vector2i pos, boolean down) {
|
||||
//System.out.println("called laser" + (down ? "Down" : "Move"));
|
||||
if(down)
|
||||
System.out.println("called laserDown");
|
||||
|
||||
Screen scr = getScreenForLaserOp(side, ply);
|
||||
|
||||
if(scr != null) {
|
||||
|
|
@ -969,7 +958,6 @@ public class TileEntityScreen extends TileEntity {
|
|||
}
|
||||
|
||||
public void laserUp(BlockSide side, EntityPlayer ply) {
|
||||
System.out.println("called laserUp");
|
||||
Screen scr = getScreenForLaserOp(side, ply);
|
||||
|
||||
if(scr != null) {
|
||||
|
|
@ -982,11 +970,11 @@ public class TileEntityScreen extends TileEntity {
|
|||
|
||||
public void onDestroy(@Nullable EntityPlayer ply) {
|
||||
for(Screen scr: screens) {
|
||||
for(ItemStack is: scr.upgrades)
|
||||
dropUpgrade(is, scr.side, ply);
|
||||
|
||||
scr.upgrades.forEach(is -> dropUpgrade(is, scr.side, ply));
|
||||
scr.upgrades.clear();
|
||||
}
|
||||
|
||||
WebDisplays.NET_HANDLER.sendToAllAround(new CMessageCloseGui(pos), point());
|
||||
}
|
||||
|
||||
public void setOwner(BlockSide side, EntityPlayer newOwner) {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class TileEntityServer extends TileEntity {
|
|||
if(WebDisplays.INSTANCE.miniservPort == 0)
|
||||
Util.toast(ply, "noMiniserv");
|
||||
else if(owner != null && ply instanceof EntityPlayerMP)
|
||||
(new ServerData(owner)).sendTo((EntityPlayerMP) ply);
|
||||
(new ServerData(pos, owner)).sendTo((EntityPlayerMP) ply);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ public abstract class Messages {
|
|||
l.add(SMessageMiniservConnect.class);
|
||||
l.add(CMessageMiniservKey.class);
|
||||
l.add(CMessageServerInfo.class);
|
||||
l.add(CMessageCloseGui.class);
|
||||
|
||||
messages = l.toArray(new Class[0]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright (C) 2018 BARBOTIN Nicolas
|
||||
*/
|
||||
|
||||
package net.montoyo.wd.net.client;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
import net.montoyo.wd.net.Message;
|
||||
import net.montoyo.wd.utilities.BlockSide;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Message(messageId = 13, side = Side.CLIENT)
|
||||
public class CMessageCloseGui implements IMessage, Runnable {
|
||||
|
||||
private BlockPos blockPos;
|
||||
private BlockSide blockSide;
|
||||
|
||||
public CMessageCloseGui() {
|
||||
}
|
||||
|
||||
public CMessageCloseGui(BlockPos bp) {
|
||||
blockPos = bp;
|
||||
blockSide = null;
|
||||
}
|
||||
|
||||
public CMessageCloseGui(BlockPos bp, BlockSide side) {
|
||||
blockPos = bp;
|
||||
blockSide = side;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
int x, y, z, side;
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
side = buf.readByte();
|
||||
|
||||
blockPos = new BlockPos(x, y, z);
|
||||
if(side <= 0)
|
||||
blockSide = null;
|
||||
else
|
||||
blockSide = BlockSide.values()[side - 1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(blockPos.getX());
|
||||
buf.writeInt(blockPos.getY());
|
||||
buf.writeInt(blockPos.getZ());
|
||||
|
||||
if(blockSide == null)
|
||||
buf.writeByte(0);
|
||||
else
|
||||
buf.writeByte(blockSide.ordinal() + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if(blockSide == null)
|
||||
Arrays.stream(BlockSide.values()).forEach(s -> WebDisplays.PROXY.closeGui(blockPos, s));
|
||||
else
|
||||
WebDisplays.PROXY.closeGui(blockPos, blockSide);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -63,6 +63,10 @@ public final class Vector3i {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean equalsBlockPos(BlockPos bp) {
|
||||
return bp.getX() == x && bp.getY() == y && bp.getZ() == z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "X: " + x + ", Y: " + y + ", Z: " + z;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user