+ Added Redstone Controller peripheral
This commit is contained in:
parent
ae2f4efd0d
commit
143e16e69b
|
|
@ -68,29 +68,35 @@ public class BlockPeripheral extends WDBlockContainer {
|
|||
@Override
|
||||
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing rrezozei, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
|
||||
int rot = MathHelper.floor(((double) (placer.rotationYaw * 4.0f / 360.0f)) + 2.5) & 3;
|
||||
return getDefaultState().withProperty(type, DefaultPeripheral.values()[meta]).withProperty(facing, rot);
|
||||
return getDefaultState().withProperty(type, DefaultPeripheral.fromMetadata(meta)).withProperty(facing, rot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
|
||||
for(DefaultPeripheral dp : DefaultPeripheral.values())
|
||||
list.add(new ItemStack(getItem(), 1, dp.ordinal()));
|
||||
list.add(new ItemStack(getItem(), 1, dp.toMetadata(0)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState().withProperty(type, DefaultPeripheral.values()[meta & 3]).withProperty(facing, (meta >> 2) & 3);
|
||||
DefaultPeripheral dp = DefaultPeripheral.fromMetadata(meta);
|
||||
IBlockState state = getDefaultState().withProperty(type, dp);
|
||||
|
||||
if(dp.hasFacing())
|
||||
state = state.withProperty(facing, (meta >> 2) & 3);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return state.getValue(type).ordinal() | (state.getValue(facing) << 2);
|
||||
return state.getValue(type).toMetadata(state.getValue(facing));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
Class<? extends TileEntityPeripheralBase> cls = DefaultPeripheral.values()[meta & 3].getTEClass();
|
||||
Class<? extends TileEntityPeripheralBase> cls = DefaultPeripheral.fromMetadata(meta).getTEClass();
|
||||
if(cls == null)
|
||||
return null;
|
||||
|
||||
|
|
@ -204,6 +210,10 @@ public class BlockPeripheral extends WDBlockContainer {
|
|||
|
||||
@Override
|
||||
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborType, BlockPos neighbor) {
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if(te != null && te instanceof TileEntityPeripheralBase)
|
||||
((TileEntityPeripheralBase) te).onNeighborChange(neighborType, neighbor);
|
||||
|
||||
if(world.isRemote || state.getValue(type) != DefaultPeripheral.KEYBOARD)
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -252,9 +252,10 @@ public class ClientProxy extends SharedProxy implements IResourceManagerReloadLi
|
|||
|
||||
registerItemModel(wd.blockScreen.getItem(), 0, "inventory");
|
||||
ModelLoader.setCustomModelResourceLocation(wd.blockPeripheral.getItem(), 0, new ModelResourceLocation("webdisplays:kb_inv", "normal"));
|
||||
registerItemModel(wd.blockPeripheral.getItem(), 1, "facing=0,type=remotectrl");
|
||||
registerItemModel(wd.blockPeripheral.getItem(), 2, "facing=2,type=ccinterface");
|
||||
registerItemModel(wd.blockPeripheral.getItem(), 3, "facing=2,type=cointerface");
|
||||
registerItemModel(wd.blockPeripheral.getItem(), 1, "facing=2,type=ccinterface");
|
||||
registerItemModel(wd.blockPeripheral.getItem(), 2, "facing=2,type=cointerface");
|
||||
registerItemModel(wd.blockPeripheral.getItem(), 3, "facing=0,type=remotectrl");
|
||||
registerItemModel(wd.blockPeripheral.getItem(), 7, "facing=0,type=redstonectrl");
|
||||
registerItemModel(wd.itemScreenCfg, 0, "normal");
|
||||
registerItemModel(wd.itemOwnerThief, 0, "normal");
|
||||
registerItemModel(wd.itemLinker, 0, "normal");
|
||||
|
|
|
|||
57
src/main/java/net/montoyo/wd/client/gui/GuiRedstoneCtrl.java
Normal file
57
src/main/java/net/montoyo/wd/client/gui/GuiRedstoneCtrl.java
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (C) 2018 BARBOTIN Nicolas
|
||||
*/
|
||||
|
||||
package net.montoyo.wd.client.gui;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
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.SMessageRedstoneCtrl;
|
||||
import net.montoyo.wd.utilities.Vector3i;
|
||||
|
||||
public class GuiRedstoneCtrl extends WDScreen {
|
||||
|
||||
private int dimension;
|
||||
private Vector3i pos;
|
||||
private String risingEdgeURL;
|
||||
private String fallingEdgeURL;
|
||||
|
||||
@FillControl
|
||||
private TextField tfRisingEdge;
|
||||
|
||||
@FillControl
|
||||
private TextField tfFallingEdge;
|
||||
|
||||
@FillControl
|
||||
private Button btnOk;
|
||||
|
||||
public GuiRedstoneCtrl() {
|
||||
}
|
||||
|
||||
public GuiRedstoneCtrl(int d, Vector3i p, String r, String f) {
|
||||
dimension = d;
|
||||
pos = p;
|
||||
risingEdgeURL = r;
|
||||
fallingEdgeURL = f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
loadFrom(new ResourceLocation("webdisplays", "gui/redstonectrl.json"));
|
||||
tfRisingEdge.setText(risingEdgeURL);
|
||||
tfFallingEdge.setText(fallingEdgeURL);
|
||||
}
|
||||
|
||||
@GuiSubscribe
|
||||
public void onClick(Button.ClickEvent ev) {
|
||||
if(ev.getSource() == btnOk)
|
||||
WebDisplays.NET_HANDLER.sendToServer(new SMessageRedstoneCtrl(dimension, pos, tfRisingEdge.getText(), tfFallingEdge.getText()));
|
||||
|
||||
mc.displayGuiScreen(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ package net.montoyo.wd.client.gui.controls;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
|
@ -144,7 +145,7 @@ public abstract class Control {
|
|||
|
||||
public void bindTexture(ResourceLocation resLoc) {
|
||||
if(resLoc == null)
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
GlStateManager.bindTexture(0); //Damn state manager
|
||||
else
|
||||
mc.renderEngine.bindTexture(resLoc);
|
||||
}
|
||||
|
|
|
|||
54
src/main/java/net/montoyo/wd/client/gui/controls/Icon.java
Normal file
54
src/main/java/net/montoyo/wd/client/gui/controls/Icon.java
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (C) 2018 BARBOTIN Nicolas
|
||||
*/
|
||||
|
||||
package net.montoyo.wd.client.gui.controls;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class Icon extends BasicControl {
|
||||
|
||||
protected int width;
|
||||
protected int height;
|
||||
protected double u1;
|
||||
protected double v1;
|
||||
protected double u2;
|
||||
protected double v2;
|
||||
protected ResourceLocation texture;
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(JsonOWrapper json) {
|
||||
super.load(json);
|
||||
|
||||
width = json.getInt("width", 16);
|
||||
height = json.getInt("height", 16);
|
||||
u1 = json.getDouble("u1", 0.0);
|
||||
v1 = json.getDouble("v1", 0.0);
|
||||
u2 = json.getDouble("u2", 1.0);
|
||||
v2 = json.getDouble("v2", 1.0);
|
||||
texture = new ResourceLocation(json.getString("resourceLocation", ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int mouseX, int mouseY, float ptt) {
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
bindTexture(texture);
|
||||
blend(true);
|
||||
fillTexturedRect(x, y, width, height, u1, v1, u2, v2);
|
||||
blend(false);
|
||||
bindTexture(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -41,6 +41,7 @@ public class GuiLoader {
|
|||
register(Label.class);
|
||||
register(List.class);
|
||||
register(TextField.class);
|
||||
register(Icon.class);
|
||||
}
|
||||
|
||||
public static Control create(JsonOWrapper json) {
|
||||
|
|
|
|||
|
|
@ -8,13 +8,15 @@ import net.minecraft.util.IStringSerializable;
|
|||
import net.montoyo.wd.entity.TileEntityKeyboard;
|
||||
import net.montoyo.wd.entity.TileEntityPeripheralBase;
|
||||
import net.montoyo.wd.entity.TileEntityRCtrl;
|
||||
import net.montoyo.wd.entity.TileEntityRedCtrl;
|
||||
|
||||
public enum DefaultPeripheral implements IStringSerializable {
|
||||
|
||||
KEYBOARD("keyboard", TileEntityKeyboard.class),
|
||||
REMOTE_CONTROLLER("remotectrl", TileEntityRCtrl.class),
|
||||
KEYBOARD("keyboard", TileEntityKeyboard.class), //WITH FACING (< 3)
|
||||
CC_INTERFACE("ccinterface", null),
|
||||
OC_INTERFACE("cointerface", null);
|
||||
OC_INTERFACE("cointerface", null),
|
||||
REMOTE_CONTROLLER("remotectrl", TileEntityRCtrl.class), //WITHOUT FACING (>= 3)
|
||||
REDSTONE_CONTROLLER("redstonectrl", TileEntityRedCtrl.class);
|
||||
|
||||
private final String name;
|
||||
private final Class<? extends TileEntityPeripheralBase> teClass;
|
||||
|
|
@ -24,6 +26,13 @@ public enum DefaultPeripheral implements IStringSerializable {
|
|||
teClass = te;
|
||||
}
|
||||
|
||||
public static DefaultPeripheral fromMetadata(int meta) {
|
||||
if((meta & 3) == 3)
|
||||
return values()[(((meta >> 2) & 3) | 4) - 1]; //Without facing
|
||||
else
|
||||
return values()[meta & 3]; //With facing
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
|
|
@ -33,4 +42,18 @@ public enum DefaultPeripheral implements IStringSerializable {
|
|||
return teClass;
|
||||
}
|
||||
|
||||
public boolean hasFacing() {
|
||||
return ordinal() < 3;
|
||||
}
|
||||
|
||||
public int toMetadata(int facing) {
|
||||
int ret = ordinal();
|
||||
if(ret < 3) //With facing
|
||||
ret |= facing << 2;
|
||||
else //Without facing
|
||||
ret = (((ret + 1) & 3) << 2) | 3;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ public abstract class GuiData {
|
|||
dataTable.put("SetURL", SetURLData.class);
|
||||
dataTable.put("ScreenConfig", ScreenConfigData.class);
|
||||
dataTable.put("Keyboard", KeyboardData.class);
|
||||
dataTable.put("RedstoneCtrl", RedstoneCtrlData.class);
|
||||
}
|
||||
|
||||
public static Class<? extends GuiData> classOf(String name) {
|
||||
|
|
|
|||
43
src/main/java/net/montoyo/wd/data/RedstoneCtrlData.java
Normal file
43
src/main/java/net/montoyo/wd/data/RedstoneCtrlData.java
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (C) 2018 BARBOTIN Nicolas
|
||||
*/
|
||||
|
||||
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.GuiRedstoneCtrl;
|
||||
import net.montoyo.wd.utilities.Vector3i;
|
||||
|
||||
public class RedstoneCtrlData extends GuiData {
|
||||
|
||||
public int dimension;
|
||||
public Vector3i pos;
|
||||
public String risingEdgeURL;
|
||||
public String fallingEdgeURL;
|
||||
|
||||
public RedstoneCtrlData() {
|
||||
}
|
||||
|
||||
public RedstoneCtrlData(int d, BlockPos p, String r, String f) {
|
||||
dimension = d;
|
||||
pos = new Vector3i(p);
|
||||
risingEdgeURL = r;
|
||||
fallingEdgeURL = f;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public GuiScreen createGui(GuiScreen old, World world) {
|
||||
return new GuiRedstoneCtrl(dimension, pos, risingEdgeURL, fallingEdgeURL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "RedstoneCtrl";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
package net.montoyo.wd.entity;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
|
@ -116,4 +117,7 @@ public abstract class TileEntityPeripheralBase extends TileEntity implements IPe
|
|||
return false;
|
||||
}
|
||||
|
||||
public void onNeighborChange(Block neighborType, BlockPos neighborPos) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
101
src/main/java/net/montoyo/wd/entity/TileEntityRedCtrl.java
Normal file
101
src/main/java/net/montoyo/wd/entity/TileEntityRedCtrl.java
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* Copyright (C) 2018 BARBOTIN Nicolas
|
||||
*/
|
||||
|
||||
package net.montoyo.wd.entity;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.montoyo.wd.core.ScreenRights;
|
||||
import net.montoyo.wd.data.RedstoneCtrlData;
|
||||
import net.montoyo.wd.utilities.BlockSide;
|
||||
import net.montoyo.wd.utilities.Util;
|
||||
|
||||
public class TileEntityRedCtrl extends TileEntityPeripheralBase {
|
||||
|
||||
private String risingEdgeURL = "";
|
||||
private String fallingEdgeURL = "";
|
||||
private boolean state = false;
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
|
||||
risingEdgeURL = tag.getString("RisingEdgeURL");
|
||||
fallingEdgeURL = tag.getString("FallingEdgeURL");
|
||||
state = tag.getBoolean("Powered");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
|
||||
tag.setString("RisingEdgeURL", risingEdgeURL);
|
||||
tag.setString("FallingEdgeURL", fallingEdgeURL);
|
||||
tag.setBoolean("Powered", state);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onRightClick(EntityPlayer player, EnumHand hand, BlockSide side) {
|
||||
if(world.isRemote)
|
||||
return true;
|
||||
|
||||
if(!isScreenChunkLoaded()) {
|
||||
Util.toast(player, "chunkUnloaded");
|
||||
return true;
|
||||
}
|
||||
|
||||
TileEntityScreen tes = getConnectedScreen();
|
||||
if(tes == null) {
|
||||
Util.toast(player, "notLinked");
|
||||
return true;
|
||||
}
|
||||
|
||||
TileEntityScreen.Screen scr = tes.getScreen(screenSide);
|
||||
if((scr.rightsFor(player) & ScreenRights.CHANGE_URL) == 0) {
|
||||
Util.toast(player, "restrictions");
|
||||
return true;
|
||||
}
|
||||
|
||||
(new RedstoneCtrlData(world.provider.getDimension(), pos, risingEdgeURL, fallingEdgeURL)).sendTo((EntityPlayerMP) player);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChange(Block neighborType, BlockPos neighborPos) {
|
||||
boolean hasPower = (world.isBlockPowered(pos) || world.isBlockPowered(pos.up())); //Same as dispenser
|
||||
|
||||
if(hasPower != state) {
|
||||
state = hasPower;
|
||||
|
||||
if(state) //Rising edge
|
||||
changeURL(risingEdgeURL);
|
||||
else //Falling edge
|
||||
changeURL(fallingEdgeURL);
|
||||
}
|
||||
}
|
||||
|
||||
public void setURLs(String r, String f) {
|
||||
risingEdgeURL = r.trim();
|
||||
fallingEdgeURL = f.trim();
|
||||
markDirty();
|
||||
}
|
||||
|
||||
private void changeURL(String url) {
|
||||
if(world.isRemote || url.isEmpty())
|
||||
return;
|
||||
|
||||
if(isScreenChunkLoaded()) {
|
||||
TileEntityScreen tes = getConnectedScreen();
|
||||
|
||||
if(tes != null)
|
||||
tes.setScreenURL(screenSide, url);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -4,7 +4,10 @@
|
|||
|
||||
package net.montoyo.wd.item;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemMultiTexture;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
|
@ -16,15 +19,18 @@ import net.minecraft.world.World;
|
|||
import net.montoyo.wd.block.BlockKeyboardRight;
|
||||
import net.montoyo.wd.core.DefaultPeripheral;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemPeripheral extends ItemMultiTexture {
|
||||
|
||||
public ItemPeripheral(Block block) {
|
||||
super(block, block, (is) -> DefaultPeripheral.values()[is.getMetadata()].getName());
|
||||
super(block, block, (is) -> DefaultPeripheral.fromMetadata(is.getMetadata()).getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockOnSide(World world, BlockPos pos_, EnumFacing side, EntityPlayer player, ItemStack stack) {
|
||||
if(stack.getMetadata() != 0)
|
||||
if(stack.getMetadata() != 0) //Keyboard
|
||||
return true;
|
||||
|
||||
//Special checks for the keyboard
|
||||
|
|
@ -43,4 +49,10 @@ public class ItemPeripheral extends ItemMultiTexture {
|
|||
return world.isAirBlock(left) && !world.isAirBlock(left.down()) && BlockKeyboardRight.checkNeighborhood(world, left, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack is, @Nullable World world, List<String> tt, ITooltipFlag ttFlags) {
|
||||
if(is.getMetadata() == 1) //CC Interface
|
||||
tt.add("" + ChatFormatting.RED + I18n.format("webdisplays.message.missingCC")); //CC is not available for 1.12.2
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ public class Messages {
|
|||
l.add(SMessageACQuery.class);
|
||||
l.add(CMessageACResult.class);
|
||||
l.add(SMessagePadCtrl.class);
|
||||
l.add(SMessageRedstoneCtrl.class);
|
||||
|
||||
messages = l.toArray(new Class[0]);
|
||||
}
|
||||
|
|
|
|||
98
src/main/java/net/montoyo/wd/net/SMessageRedstoneCtrl.java
Normal file
98
src/main/java/net/montoyo/wd/net/SMessageRedstoneCtrl.java
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Copyright (C) 2018 BARBOTIN Nicolas
|
||||
*/
|
||||
|
||||
package net.montoyo.wd.net;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.montoyo.wd.core.ScreenRights;
|
||||
import net.montoyo.wd.entity.TileEntityRedCtrl;
|
||||
import net.montoyo.wd.entity.TileEntityScreen;
|
||||
import net.montoyo.wd.utilities.Util;
|
||||
import net.montoyo.wd.utilities.Vector3i;
|
||||
|
||||
@Message(messageId = 8, side = Side.SERVER)
|
||||
public class SMessageRedstoneCtrl implements IMessage, Runnable {
|
||||
|
||||
private EntityPlayer player;
|
||||
private int dimension;
|
||||
private Vector3i pos;
|
||||
private String risingEdgeURL;
|
||||
private String fallingEdgeURL;
|
||||
|
||||
public SMessageRedstoneCtrl() {
|
||||
}
|
||||
|
||||
public SMessageRedstoneCtrl(int d, Vector3i p, String r, String f) {
|
||||
dimension = d;
|
||||
pos = p;
|
||||
risingEdgeURL = r;
|
||||
fallingEdgeURL = f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
World world = player.world;
|
||||
BlockPos blockPos = pos.toBlock();
|
||||
final double maxRange = player.getEntityAttribute(EntityPlayer.REACH_DISTANCE).getAttributeValue();
|
||||
|
||||
if(world.provider.getDimension() != dimension || player.getDistanceSq(blockPos) > maxRange * maxRange)
|
||||
return;
|
||||
|
||||
TileEntity te = player.world.getTileEntity(blockPos);
|
||||
if(te == null || !(te instanceof TileEntityRedCtrl))
|
||||
return;
|
||||
|
||||
TileEntityRedCtrl redCtrl = (TileEntityRedCtrl) te;
|
||||
if(!redCtrl.isScreenChunkLoaded()) {
|
||||
Util.toast(player, "chunkUnloaded");
|
||||
return;
|
||||
}
|
||||
|
||||
TileEntityScreen tes = redCtrl.getConnectedScreen();
|
||||
if(tes == null)
|
||||
return;
|
||||
|
||||
if((tes.getScreen(redCtrl.getScreenSide()).rightsFor(player) & ScreenRights.CHANGE_URL) == 0)
|
||||
return;
|
||||
|
||||
redCtrl.setURLs(risingEdgeURL, fallingEdgeURL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
dimension = buf.readInt();
|
||||
pos = new Vector3i(buf);
|
||||
risingEdgeURL = ByteBufUtils.readUTF8String(buf);
|
||||
fallingEdgeURL = ByteBufUtils.readUTF8String(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(dimension);
|
||||
pos.writeTo(buf);
|
||||
ByteBufUtils.writeUTF8String(buf, risingEdgeURL);
|
||||
ByteBufUtils.writeUTF8String(buf, fallingEdgeURL);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<SMessageRedstoneCtrl, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(SMessageRedstoneCtrl msg, MessageContext ctx) {
|
||||
msg.player = ctx.getServerHandler().player;
|
||||
((WorldServer) msg.player.world).addScheduledTask(msg);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -5,11 +5,6 @@
|
|||
"facing=2,type=keyboard": { "model": "webdisplays:kb_left", "y": 180.0 },
|
||||
"facing=3,type=keyboard": { "model": "webdisplays:kb_left", "y": 270.0 },
|
||||
|
||||
"facing=0,type=remotectrl": { "model": "webdisplays:rctrl" },
|
||||
"facing=1,type=remotectrl": { "model": "webdisplays:rctrl" },
|
||||
"facing=2,type=remotectrl": { "model": "webdisplays:rctrl" },
|
||||
"facing=3,type=remotectrl": { "model": "webdisplays:rctrl" },
|
||||
|
||||
"facing=0,type=ccinterface": { "model": "webdisplays:ccinterface", "y": 180.0 },
|
||||
"facing=1,type=ccinterface": { "model": "webdisplays:ccinterface", "y": 270.0 },
|
||||
"facing=2,type=ccinterface": { "model": "webdisplays:ccinterface" },
|
||||
|
|
@ -18,6 +13,16 @@
|
|||
"facing=0,type=cointerface": { "model": "webdisplays:ocinterface", "y": 180.0 },
|
||||
"facing=1,type=cointerface": { "model": "webdisplays:ocinterface", "y": 270.0 },
|
||||
"facing=2,type=cointerface": { "model": "webdisplays:ocinterface" },
|
||||
"facing=3,type=cointerface": { "model": "webdisplays:ocinterface", "y": 90.0 }
|
||||
"facing=3,type=cointerface": { "model": "webdisplays:ocinterface", "y": 90.0 },
|
||||
|
||||
"facing=0,type=remotectrl": { "model": "webdisplays:rctrl" },
|
||||
"facing=1,type=remotectrl": { "model": "webdisplays:rctrl" },
|
||||
"facing=2,type=remotectrl": { "model": "webdisplays:rctrl" },
|
||||
"facing=3,type=remotectrl": { "model": "webdisplays:rctrl" },
|
||||
|
||||
"facing=0,type=redstonectrl": { "model": "webdisplays:redctrl" },
|
||||
"facing=1,type=redstonectrl": { "model": "webdisplays:redctrl" },
|
||||
"facing=2,type=redstonectrl": { "model": "webdisplays:redctrl" },
|
||||
"facing=3,type=redstonectrl": { "model": "webdisplays:redctrl" }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
56
src/main/resources/assets/webdisplays/gui/redstonectrl.json
Normal file
56
src/main/resources/assets/webdisplays/gui/redstonectrl.json
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
{
|
||||
"controls": [
|
||||
{
|
||||
"type": "Icon",
|
||||
"resourceLocation": "webdisplays:textures/gui/edges.png",
|
||||
"x": 0,
|
||||
"y": 1,
|
||||
"width": 16,
|
||||
"height": 16,
|
||||
"v1": 0.0,
|
||||
"v2": 0.5
|
||||
},
|
||||
{
|
||||
"type": "TextField",
|
||||
"name": "tfRisingEdge",
|
||||
"x": 20,
|
||||
"y": 0,
|
||||
"width": 280
|
||||
},
|
||||
{
|
||||
"type": "Icon",
|
||||
"resourceLocation": "webdisplays:textures/gui/edges.png",
|
||||
"x": 0,
|
||||
"y": 26,
|
||||
"width": 16,
|
||||
"height": 16,
|
||||
"v1": 0.5,
|
||||
"v2": 1.0
|
||||
},
|
||||
{
|
||||
"type": "TextField",
|
||||
"name": "tfFallingEdge",
|
||||
"x": 20,
|
||||
"y": 24,
|
||||
"width": 280
|
||||
},
|
||||
{
|
||||
"type": "Button",
|
||||
"name": "btnOk",
|
||||
"label": "$webdisplays.gui.seturl.ok",
|
||||
"x": 20,
|
||||
"y": 48,
|
||||
"width": 137
|
||||
},
|
||||
{
|
||||
"type": "Button",
|
||||
"name": "btnCancel",
|
||||
"label": "$webdisplays.gui.seturl.cancel",
|
||||
"x": 163,
|
||||
"y": 48,
|
||||
"width": 137
|
||||
}
|
||||
],
|
||||
|
||||
"center": true
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ tile.webdisplays.peripheral.keyboard.name=Keyboard
|
|||
tile.webdisplays.peripheral.remotectrl.name=Remote Controller
|
||||
tile.webdisplays.peripheral.ccinterface.name=ComputerCraft Interface
|
||||
tile.webdisplays.peripheral.cointerface.name=OpenComputers Interface
|
||||
tile.webdisplays.peripheral.redstonectrl.name=Redstone Controller
|
||||
item.webdisplays.screencfg.name=Screen Configurator
|
||||
item.webdisplays.ownerthief.name=Ownership Thief [ADMIN]
|
||||
item.webdisplays.linker.name=Linking Tool
|
||||
|
|
@ -20,8 +21,10 @@ webdisplays.message.linked=Linked!
|
|||
webdisplays.message.linkError=Link error :( Check logs...
|
||||
webdisplays.message.notAScreen=Please right click on the screen first...
|
||||
webdisplays.message.screenSet2=Screen set! Now right click on the peripheral...
|
||||
webdisplays.message.chunkUnloaded=The chunk the screen in placed it is not loaded!
|
||||
webdisplays.message.chunkUnloaded=The chunk the screen is placed in is not loaded!
|
||||
webdisplays.message.notLinked=This peripheral has not been linked yet.
|
||||
webdisplays.message.missingCC=ComputerCraft is not available.
|
||||
webdisplays.message.missingOC=OpenComputers is not available.
|
||||
webdisplays.gui.screencfg.owner=Screen owner:
|
||||
webdisplays.gui.screencfg.friends=Friends:
|
||||
webdisplays.gui.screencfg.permissions=Permissions:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "webdisplays:blocks/redctrl"
|
||||
}
|
||||
}
|
||||
|
|
@ -16,6 +16,6 @@
|
|||
},
|
||||
"result": {
|
||||
"item": "webdisplays:peripheral",
|
||||
"data": 2
|
||||
"data": 1
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,6 @@
|
|||
},
|
||||
"result": {
|
||||
"item": "webdisplays:peripheral",
|
||||
"data": 3
|
||||
"data": 2
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,6 @@
|
|||
},
|
||||
"result": {
|
||||
"item": "webdisplays:peripheral",
|
||||
"data": 1
|
||||
"data": 3
|
||||
}
|
||||
}
|
||||
|
|
|
|||
23
src/main/resources/assets/webdisplays/recipes/redctrl1.json
Normal file
23
src/main/resources/assets/webdisplays/recipes/redctrl1.json
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"RRR",
|
||||
"RER",
|
||||
"BBB"
|
||||
],
|
||||
"key": {
|
||||
"R": {
|
||||
"item": "minecraft:redstone"
|
||||
},
|
||||
"E": {
|
||||
"item": "minecraft:ender_pearl"
|
||||
},
|
||||
"B": {
|
||||
"item": "minecraft:wooden_button"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "webdisplays:peripheral",
|
||||
"data": 7
|
||||
}
|
||||
}
|
||||
20
src/main/resources/assets/webdisplays/recipes/redctrl2.json
Normal file
20
src/main/resources/assets/webdisplays/recipes/redctrl2.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"RRR",
|
||||
"RPR"
|
||||
],
|
||||
"key": {
|
||||
"R": {
|
||||
"item": "minecraft:redstone"
|
||||
},
|
||||
"P": {
|
||||
"item": "webdisplays:peripheral",
|
||||
"data": 3
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "webdisplays:peripheral",
|
||||
"data": 7
|
||||
}
|
||||
}
|
||||
BIN
src/main/resources/assets/webdisplays/textures/gui/edges.png
Normal file
BIN
src/main/resources/assets/webdisplays/textures/gui/edges.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 257 B |
Loading…
Reference in New Issue
Block a user