From 68801079b0980365ca26e296e57f75627627a6cb Mon Sep 17 00:00:00 2001 From: eisental Date: Mon, 4 May 2020 01:31:19 -0400 Subject: [PATCH 01/12] Updated for Spigot 1.15.2 Updated playerid Updated vehicleid Updated Beacon --- src/main/resources/plugin.yml => plugin.yml | 1 + .../sensorlibrary/SensorLibrary.java | 2 +- .../redstonechips/sensorlibrary/beacon.java | 2 +- .../sensorlibrary/liquidlevel.java | 7 +- .../redstonechips/sensorlibrary/playerid.java | 85 ++++++++++++------- .../sensorlibrary/rangefinder.java | 2 +- .../sensorlibrary/vehicleid.java | 76 +++++++++-------- 7 files changed, 103 insertions(+), 72 deletions(-) rename src/main/resources/plugin.yml => plugin.yml (93%) diff --git a/src/main/resources/plugin.yml b/plugin.yml similarity index 93% rename from src/main/resources/plugin.yml rename to plugin.yml index f7be7e8..1f3d9df 100755 --- a/src/main/resources/plugin.yml +++ b/plugin.yml @@ -1,6 +1,7 @@ name: SensorLibrary main: org.redstonechips.sensorlibrary.SensorLibrary version: 0.34 +api-version: 1.15 author: eisental description: Sensor library for RedstoneChips integrated circuits plugin. website: eisental.github.com/RedstoneChips diff --git a/src/main/java/org/redstonechips/sensorlibrary/SensorLibrary.java b/src/main/java/org/redstonechips/sensorlibrary/SensorLibrary.java index d617e0a..d29eb4b 100755 --- a/src/main/java/org/redstonechips/sensorlibrary/SensorLibrary.java +++ b/src/main/java/org/redstonechips/sensorlibrary/SensorLibrary.java @@ -14,7 +14,7 @@ public class SensorLibrary extends CircuitLibrary { @Override public Class[] getCircuitClasses() { return new Class[] {photocell.class, pirsensor.class, rangefinder.class, daytime.class, slotinput.class, - beacon.class, spark.class, liquidlevel.class}; + beacon.class, spark.class, liquidlevel.class, playerid.class, vehicleid.class}; } @Override diff --git a/src/main/java/org/redstonechips/sensorlibrary/beacon.java b/src/main/java/org/redstonechips/sensorlibrary/beacon.java index 0177382..9741f92 100755 --- a/src/main/java/org/redstonechips/sensorlibrary/beacon.java +++ b/src/main/java/org/redstonechips/sensorlibrary/beacon.java @@ -91,7 +91,7 @@ public void onEvent(Event e) { Chunk chunk = event.getChunk(); if (keepalive) { if (chip.hasListeners()) debug("Chunk (" + chunk.getX() + ", " + chunk.getZ() + ") in " + chip.world.getName()+ " is kept alive."); - event.setCancelled(true); + chunk.setForceLoaded(true); } else { loadCount--; sendBit(); diff --git a/src/main/java/org/redstonechips/sensorlibrary/liquidlevel.java b/src/main/java/org/redstonechips/sensorlibrary/liquidlevel.java index 4bca762..a475754 100644 --- a/src/main/java/org/redstonechips/sensorlibrary/liquidlevel.java +++ b/src/main/java/org/redstonechips/sensorlibrary/liquidlevel.java @@ -8,6 +8,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.data.Levelled; import org.bukkit.block.BlockState; import org.bukkit.event.Event; import org.bukkit.event.block.BlockBreakEvent; @@ -32,9 +33,9 @@ public class liquidlevel extends Circuit { private static final Set liquids = new HashSet<>(); static { liquids.add(Material.WATER); - liquids.add(Material.STATIONARY_WATER); + //liquids.add(Material.STATIONARY_WATER); liquids.add(Material.LAVA); - liquids.add(Material.STATIONARY_LAVA); + //liquids.add(Material.STATIONARY_LAVA); } Map sides = new HashMap<>(); @@ -155,6 +156,8 @@ private byte findWaterLevel(Location l) { BlockState b = l.getBlock().getState(); if (liquids.contains(b.getType())) { byte data = b.getData().getData(); + System.out.println("old = " + b); + //System.out.println("new = " + b.getBlockData().getLevel()); if (data>7) // falling liquid. full water block. return 8; else diff --git a/src/main/java/org/redstonechips/sensorlibrary/playerid.java b/src/main/java/org/redstonechips/sensorlibrary/playerid.java index a32c1a8..11e6d7e 100755 --- a/src/main/java/org/redstonechips/sensorlibrary/playerid.java +++ b/src/main/java/org/redstonechips/sensorlibrary/playerid.java @@ -1,14 +1,16 @@ -/* + package org.redstonechips.sensorlibrary; import org.bukkit.Location; +import org.bukkit.event.Event; import org.bukkit.event.player.PlayerMoveEvent; import org.redstonechips.circuit.Circuit; +import org.redstonechips.event.EventListener; -/** +/* * * @author Tal Eisenberg - *//* + */ public class playerid extends Circuit { private final int resetPin = 1; private final int disablePin = 0; @@ -23,57 +25,78 @@ public void input(boolean state, int inIdx) { pinDisabled = state; if (pinDisabled) { for (int i=0; i Date: Mon, 4 May 2020 01:31:50 -0400 Subject: [PATCH 02/12] Updated to work with Spigot 1.15.2 --- .../org/redstonechips/sensorlibrary/playerid.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/redstonechips/sensorlibrary/playerid.java b/src/main/java/org/redstonechips/sensorlibrary/playerid.java index 11e6d7e..5fb11cd 100755 --- a/src/main/java/org/redstonechips/sensorlibrary/playerid.java +++ b/src/main/java/org/redstonechips/sensorlibrary/playerid.java @@ -34,13 +34,10 @@ public void input(boolean state, int inIdx) { @Override public Circuit init(String[] args) { - System.out.println("init ran"); - if (outputlen==0 || chip.interfaceBlocks.length==0) { + if (outputlen==0 || chip.interfaceBlocks.length==0) { return error("Expecting at least 2 output pins and at least 1 interface block."); } else { - //SensorLibrary.eventDispatcher.registerPlayerListener(PlayerMoveEvent.class, playerListener); - SensorLibrary.eventDispatcher.registerListener(PlayerMoveEvent.class, moveListener); - //SensorLibrary.registerPlayeridCircuit(this); + SensorLibrary.eventDispatcher.registerListener(PlayerMoveEvent.class, moveListener); return this; } } @@ -64,7 +61,7 @@ public void onEvent(Event e) { boolean distanceCheckAbove = (to.getBlockY()-in.getBlockY()==1 && to.getBlockX()-in.getBlockX()==0 && to.getBlockZ()-in.getBlockZ()==0); boolean distanceCheckBelow = (in.getBlockY()-to.getBlockY()==1 && to.getBlockX()-in.getBlockX()==0 && to.getBlockZ()-in.getBlockZ()==0); boolean withinDistance = distanceCheckRight || distanceCheckLeft || distanceCheckFront || distanceCheckBack || distanceCheckAbove || distanceCheckBelow; - System.out.println("withinDistance = " + withinDistance); + if (withinDistance) { found = true; if (i!=lastInterface) { @@ -80,11 +77,7 @@ public void onEvent(Event e) { lastInterface = i; return; } - } - else { - writeInt(0, 1, outputlen-1); - - } + } } if (!found) lastInterface = -1; From 6b406beb3df1bff2103dad5d1d8b1eae06a9d239 Mon Sep 17 00:00:00 2001 From: eisental Date: Mon, 4 May 2020 19:29:09 -0400 Subject: [PATCH 03/12] Added Features Added detection along multiple axes Added sign arg d{} for distance away from interface block Added sign args sphere and axis to determine the direction of detection --- .../redstonechips/sensorlibrary/playerid.java | 91 ++++++++++++++----- .../sensorlibrary/vehicleid.java | 74 +++++++++++++-- 2 files changed, 134 insertions(+), 31 deletions(-) diff --git a/src/main/java/org/redstonechips/sensorlibrary/playerid.java b/src/main/java/org/redstonechips/sensorlibrary/playerid.java index 5fb11cd..0fe6f7b 100755 --- a/src/main/java/org/redstonechips/sensorlibrary/playerid.java +++ b/src/main/java/org/redstonechips/sensorlibrary/playerid.java @@ -4,6 +4,7 @@ import org.bukkit.Location; import org.bukkit.event.Event; import org.bukkit.event.player.PlayerMoveEvent; +import org.redstonechips.RCPrefs; import org.redstonechips.circuit.Circuit; import org.redstonechips.event.EventListener; @@ -16,17 +17,22 @@ public class playerid extends Circuit { private final int disablePin = 0; private boolean pinDisabled = false; private int lastInterface = -1; + private byte distance = 1; + private boolean sphere = false; @Override public void input(boolean state, int inIdx) { if (inIdx==resetPin && state) { for (int i=0; i0) { + for (byte i=0; imaxIdDistance) return error("Bad distance argument: " + args[0] + ". Expecting a number between 1 and " + maxIdDistance + ". Set playerid.maxdistance in preferences.yml to extend the maximum distance."); + + } catch (NumberFormatException ne2) { + return error("Bad distance argument: " + args[0] + ". Expecting a number between 1 and " + maxIdDistance); + } + } + else if (args[i].toUpperCase().equals("SPHERE")) sphere = true; + else if (args[i].toUpperCase().equals("AXIS")) sphere = false; + } + } } + SensorLibrary.eventDispatcher.registerListener(PlayerMoveEvent.class, moveListener); + return this; } private final EventListener moveListener = new EventListener() { @Override public void onEvent(Event e) { - PlayerMoveEvent p = (PlayerMoveEvent)e; if (pinDisabled) return; - + PlayerMoveEvent p = (PlayerMoveEvent)e; Location to = p.getTo(); boolean found = false; for (int i=0; i0) { + for (byte i=0; imaxIdDistance) return error("Bad distance argument: " + args[0] + ". Expecting a number between 1 and " + maxIdDistance + ". Set playerid.maxdistance in preferences.yml to extend the maximum distance."); + + } catch (NumberFormatException ne2) { + return error("Bad distance argument: " + args[0] + ". Expecting a number between 1 and " + maxIdDistance); + } + } + else if (args[i].toUpperCase().equals("SPHERE")) sphere = true; + else if (args[i].toUpperCase().equals("AXIS")) sphere = false; + } + } + } SensorLibrary.eventDispatcher.registerListener(VehicleMoveEvent.class, moveListener); return this; } private final EventListener moveListener = new EventListener() { + @Override public void onEvent(Event e) { if (pinDisabled) return; VehicleMoveEvent v = (VehicleMoveEvent)e; @@ -51,7 +79,7 @@ public void onEvent(Event e) { for (int i=0; i Date: Mon, 4 May 2020 19:31:32 -0400 Subject: [PATCH 04/12] Updated version number due to the amount of changes --- plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.yml b/plugin.yml index 1f3d9df..4e0e831 100755 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: SensorLibrary main: org.redstonechips.sensorlibrary.SensorLibrary -version: 0.34 +version: 0.35 api-version: 1.15 author: eisental description: Sensor library for RedstoneChips integrated circuits plugin. From ef5aa5e93e6ca64c4a5b3030093e638b5a60aa77 Mon Sep 17 00:00:00 2001 From: eisental Date: Mon, 4 May 2020 19:52:55 -0400 Subject: [PATCH 05/12] Updated to work with 1.15.2 --- .../java/org/redstonechips/sensorlibrary/beacon.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/org/redstonechips/sensorlibrary/beacon.java b/src/main/java/org/redstonechips/sensorlibrary/beacon.java index 9741f92..50b6c9f 100755 --- a/src/main/java/org/redstonechips/sensorlibrary/beacon.java +++ b/src/main/java/org/redstonechips/sensorlibrary/beacon.java @@ -70,6 +70,16 @@ public void shutdown() { SensorLibrary.eventDispatcher.unregisterListener(chunkLoadListener); SensorLibrary.eventDispatcher.unregisterListener(chunkUnloadListener); } + @Override + public void destroyed() { + SensorLibrary.eventDispatcher.unregisterListener(chunkLoadListener); + SensorLibrary.eventDispatcher.unregisterListener(chunkUnloadListener); + } + @Override + public void disable() { + SensorLibrary.eventDispatcher.unregisterListener(chunkLoadListener); + SensorLibrary.eventDispatcher.unregisterListener(chunkUnloadListener); + } private final EventListener chunkLoadListener = new EventListener() { @Override From f0fbb90212115d808e41b56b16a0d079727e0133 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Mon, 4 May 2020 19:59:05 -0400 Subject: [PATCH 06/12] Fixed information given when distance is too large error --- src/main/java/org/redstonechips/sensorlibrary/vehicleid.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/redstonechips/sensorlibrary/vehicleid.java b/src/main/java/org/redstonechips/sensorlibrary/vehicleid.java index 1edcd1e..197cc10 100755 --- a/src/main/java/org/redstonechips/sensorlibrary/vehicleid.java +++ b/src/main/java/org/redstonechips/sensorlibrary/vehicleid.java @@ -53,7 +53,7 @@ public Circuit init(String[] args) { } try { distance = Byte.decode(args[i].substring(args[i].indexOf("{")+1, args[i].length()-1)); - if (distance==0 || distance>maxIdDistance) return error("Bad distance argument: " + args[0] + ". Expecting a number between 1 and " + maxIdDistance + ". Set playerid.maxdistance in preferences.yml to extend the maximum distance."); + if (distance==0 || distance>maxIdDistance) return error("Bad distance argument: " + args[0] + ". Expecting a number between 1 and " + maxIdDistance + ". Set vehicleid.maxdistance in preferences.yml to extend the maximum distance."); } catch (NumberFormatException ne2) { return error("Bad distance argument: " + args[0] + ". Expecting a number between 1 and " + maxIdDistance); From ffc46b021804539f1cc195b5f1fe216b12e4fc65 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Mon, 4 May 2020 20:02:18 -0400 Subject: [PATCH 07/12] More max distance error text fixed --- src/main/java/org/redstonechips/sensorlibrary/playerid.java | 4 ++-- src/main/java/org/redstonechips/sensorlibrary/vehicleid.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/redstonechips/sensorlibrary/playerid.java b/src/main/java/org/redstonechips/sensorlibrary/playerid.java index 0fe6f7b..5ba575e 100755 --- a/src/main/java/org/redstonechips/sensorlibrary/playerid.java +++ b/src/main/java/org/redstonechips/sensorlibrary/playerid.java @@ -53,10 +53,10 @@ public Circuit init(String[] args) { } try { distance = Byte.decode(args[i].substring(args[i].indexOf("{")+1, args[i].length()-1)); - if (distance==0 || distance>maxIdDistance) return error("Bad distance argument: " + args[0] + ". Expecting a number between 1 and " + maxIdDistance + ". Set playerid.maxdistance in preferences.yml to extend the maximum distance."); + if (distance==0 || distance>maxIdDistance) return error("Maximum distance exceeded: " + args[i] + ". The maximum distance is " + maxIdDistance + ". Set playerid.maxdistance in preferences.yml to extend the maximum distance."); } catch (NumberFormatException ne2) { - return error("Bad distance argument: " + args[0] + ". Expecting a number between 1 and " + maxIdDistance); + return error("Bad distance argument: " + args[i] + ". Expecting a number between 1 and " + maxIdDistance); } } else if (args[i].toUpperCase().equals("SPHERE")) sphere = true; diff --git a/src/main/java/org/redstonechips/sensorlibrary/vehicleid.java b/src/main/java/org/redstonechips/sensorlibrary/vehicleid.java index 197cc10..07b81fa 100755 --- a/src/main/java/org/redstonechips/sensorlibrary/vehicleid.java +++ b/src/main/java/org/redstonechips/sensorlibrary/vehicleid.java @@ -53,10 +53,10 @@ public Circuit init(String[] args) { } try { distance = Byte.decode(args[i].substring(args[i].indexOf("{")+1, args[i].length()-1)); - if (distance==0 || distance>maxIdDistance) return error("Bad distance argument: " + args[0] + ". Expecting a number between 1 and " + maxIdDistance + ". Set vehicleid.maxdistance in preferences.yml to extend the maximum distance."); + if (distance==0 || distance>maxIdDistance) return error("Maximum distance exceeded: " + args[i] + ". The maximum distance is " + maxIdDistance + ". Set vehicleid.maxdistance in preferences.yml to extend the maximum distance."); } catch (NumberFormatException ne2) { - return error("Bad distance argument: " + args[0] + ". Expecting a number between 1 and " + maxIdDistance); + return error("Bad distance argument: " + args[i] + ". Expecting a number between 1 and " + maxIdDistance); } } else if (args[i].toUpperCase().equals("SPHERE")) sphere = true; From 1479179a77547d762d209c0725fb70a54476023a Mon Sep 17 00:00:00 2001 From: eisental Date: Tue, 5 May 2020 01:37:05 -0400 Subject: [PATCH 08/12] Added ability to choose which direction to detect playerid from. North, South, West, East, Above, Below. --- .../redstonechips/sensorlibrary/playerid.java | 120 +++++++++++++++--- 1 file changed, 101 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/redstonechips/sensorlibrary/playerid.java b/src/main/java/org/redstonechips/sensorlibrary/playerid.java index 5ba575e..c52a079 100755 --- a/src/main/java/org/redstonechips/sensorlibrary/playerid.java +++ b/src/main/java/org/redstonechips/sensorlibrary/playerid.java @@ -19,7 +19,25 @@ public class playerid extends Circuit { private int lastInterface = -1; private byte distance = 1; private boolean sphere = false; - + + private Boolean[] directionAim = new Boolean[] { + false, + false, + false, + false, + false, + false, + }; + + private static final String[] directionText = new String[] { + "EAST", + "WEST", + "NORTH", + "SOUTH", + "ABOVE", + "BELOW", + }; + @Override public void input(boolean state, int inIdx) { if (inIdx==resetPin && state) { @@ -42,11 +60,11 @@ public void input(boolean state, int inIdx) { public Circuit init(String[] args) { sphere = false; int maxIdDistance = 3; - if (outputlen==0 || chip.interfaceBlocks.length==0) return error("Expecting at least 2 output pins and at least 1 interface block."); - else { - if (args.length>0) { - for (byte i=0; i0) { + for (byte i=0; i0 && + Math.abs(too.getBlockY()-inn.getBlockY())<=distance && + Math.abs(too.getBlockZ()-inn.getBlockZ())<=distance); + boolean distanceSphereEast = (too.getBlockX()-inn.getBlockX()<=distance && + too.getBlockX()-inn.getBlockX()>0 && + Math.abs(too.getBlockY()-inn.getBlockY())<=distance && + Math.abs(too.getBlockZ()-inn.getBlockZ())<=distance); + boolean distanceSphereNorth = (inn.getBlockZ()-too.getBlockZ()<=distance && + inn.getBlockZ()-too.getBlockZ()>0 && + Math.abs(too.getBlockY()-inn.getBlockY())<=distance && + Math.abs(too.getBlockX()-inn.getBlockX())<=distance); + boolean distanceSphereSouth = (too.getBlockZ()-inn.getBlockZ()<=distance && + too.getBlockZ()-inn.getBlockZ()>0 && + Math.abs(too.getBlockY()-inn.getBlockY())<=distance && + Math.abs(too.getBlockX()-inn.getBlockX())<=distance); + boolean distanceSphereAbove = (too.getBlockY()-inn.getBlockY()<=distance && + too.getBlockY()-inn.getBlockY()>0 && + Math.abs(too.getBlockZ()-inn.getBlockZ())<=distance && + Math.abs(too.getBlockX()-inn.getBlockX())<=distance); + boolean distanceSphereBelow = (inn.getBlockY()-too.getBlockY()<=distance && + inn.getBlockY()-too.getBlockY()>0 && + Math.abs(too.getBlockZ()-inn.getBlockZ())<=distance && + Math.abs(too.getBlockX()-inn.getBlockX())<=distance); + boolean distanceSphere = (distanceSphereEast&&!directionAim[1]&&!directionAim[2]&&!directionAim[3]&&!directionAim[4]&&!directionAim[5]) + || (distanceSphereWest&&!directionAim[0]&&!directionAim[2]&&!directionAim[3]&&!directionAim[4]&&!directionAim[5]) + || (distanceSphereNorth&&!directionAim[1]&&!directionAim[0]&&!directionAim[3]&&!directionAim[4]&&!directionAim[5]) + || (distanceSphereSouth&&!directionAim[1]&&!directionAim[2]&&!directionAim[0]&&!directionAim[4]&&!directionAim[5]) + || (distanceSphereAbove&&!directionAim[1]&&!directionAim[2]&&!directionAim[3]&&!directionAim[0]&&!directionAim[5]) + || (distanceSphereBelow&&!directionAim[1]&&!directionAim[2]&&!directionAim[3]&&!directionAim[4]&&!directionAim[0]); + if (distanceSphere) return true; } - else if (!sphere) { - boolean distanceCheckRight = (Math.abs(too.getBlockX()-inn.getBlockX())<=distance && too.getBlockY()-inn.getBlockY()==0 && too.getBlockZ()-inn.getBlockZ()==0); - boolean distanceCheckLeft = (Math.abs(inn.getBlockX() - too.getBlockX())<=distance && too.getBlockY()-inn.getBlockY()==0 && too.getBlockZ()-inn.getBlockZ()==0); - boolean distanceCheckFront = (Math.abs(too.getBlockZ()-inn.getBlockZ())<=distance && too.getBlockY()-inn.getBlockY()==0 && too.getBlockX()-inn.getBlockX()==0); - boolean distanceCheckBack = (Math.abs(inn.getBlockZ()-too.getBlockZ())<=distance && too.getBlockY()-inn.getBlockY()==0 && too.getBlockX()-inn.getBlockX()==0); - boolean distanceCheckAbove = (Math.abs(too.getBlockY()-inn.getBlockY())<=distance && too.getBlockX()-inn.getBlockX()==0 && too.getBlockZ()-inn.getBlockZ()==0); - boolean distanceCheckBelow = (Math.abs(inn.getBlockY()-too.getBlockY())<=distance && too.getBlockX()-inn.getBlockX()==0 && too.getBlockZ()-inn.getBlockZ()==0); - boolean axisDistance = distanceCheckRight || distanceCheckLeft || distanceCheckFront || distanceCheckBack || distanceCheckAbove || distanceCheckBelow; + else { + boolean distanceCheckEast= (too.getBlockX()-inn.getBlockX()<=distance && + too.getBlockX()-inn.getBlockX()>0 && + too.getBlockY()-inn.getBlockY()==0 && + too.getBlockZ()-inn.getBlockZ()==0); // can not use ABS as it will flag opposing sides as true instead of just one side + + boolean distanceCheckWest= (inn.getBlockX()-too.getBlockX()<=distance && + inn.getBlockX()-too.getBlockX()>0 && + too.getBlockY()-inn.getBlockY()==0 && + too.getBlockZ()-inn.getBlockZ()==0); + + boolean distanceCheckNorth=(inn.getBlockZ()-too.getBlockZ()<=distance && + inn.getBlockZ()-too.getBlockZ()>0 && + too.getBlockY()-inn.getBlockY()==0 && + too.getBlockX()-inn.getBlockX()==0); + + boolean distanceCheckSouth=(too.getBlockZ()-inn.getBlockZ()<=distance && + too.getBlockZ()-inn.getBlockZ()>0 && + too.getBlockY()-inn.getBlockY()==0 && + too.getBlockX()-inn.getBlockX()==0); + + boolean distanceCheckAbove=(too.getBlockY()-inn.getBlockY()<=distance && + too.getBlockY()-inn.getBlockY()>0 && + too.getBlockX()-inn.getBlockX()==0 && + too.getBlockZ()-inn.getBlockZ()==0); + + boolean distanceCheckBelow=(inn.getBlockY()-too.getBlockY()<=distance && + inn.getBlockY()-too.getBlockY()>0 && + too.getBlockX()-inn.getBlockX()==0 && + too.getBlockZ()-inn.getBlockZ()==0); + + boolean axisDistance = (distanceCheckEast&&!directionAim[1]&&!directionAim[2]&&!directionAim[3]&&!directionAim[4]&&!directionAim[5]) + || (distanceCheckWest&&!directionAim[0]&&!directionAim[2]&&!directionAim[3]&&!directionAim[4]&&!directionAim[5]) + || (distanceCheckNorth&&!directionAim[1]&&!directionAim[0]&&!directionAim[3]&&!directionAim[4]&&!directionAim[5]) + || (distanceCheckSouth&&!directionAim[1]&&!directionAim[2]&&!directionAim[0]&&!directionAim[4]&&!directionAim[5]) + || (distanceCheckAbove&&!directionAim[1]&&!directionAim[2]&&!directionAim[3]&&!directionAim[0]&&!directionAim[5]) + || (distanceCheckBelow&&!directionAim[1]&&!directionAim[2]&&!directionAim[3]&&!directionAim[4]&&!directionAim[0]); if (axisDistance) return true; } return false; From 5dd8dabf3b1c0b8b1fff812600d7b4c4efe10131 Mon Sep 17 00:00:00 2001 From: eisental Date: Sat, 23 May 2020 21:46:47 -0400 Subject: [PATCH 09/12] Updated some depreciated method usage --- .../sensorlibrary/liquidlevel.java | 14 ++- .../sensorlibrary/pirsensor.java | 2 +- .../sensorlibrary/rangefinder.java | 4 + .../sensorlibrary/vehicleid.java | 106 ++++++++++++++++-- 4 files changed, 107 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/redstonechips/sensorlibrary/liquidlevel.java b/src/main/java/org/redstonechips/sensorlibrary/liquidlevel.java index a475754..8dfae08 100644 --- a/src/main/java/org/redstonechips/sensorlibrary/liquidlevel.java +++ b/src/main/java/org/redstonechips/sensorlibrary/liquidlevel.java @@ -9,7 +9,7 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.data.Levelled; -import org.bukkit.block.BlockState; +import org.bukkit.block.data.BlockData; import org.bukkit.event.Event; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockEvent; @@ -33,7 +33,7 @@ public class liquidlevel extends Circuit { private static final Set liquids = new HashSet<>(); static { liquids.add(Material.WATER); - //liquids.add(Material.STATIONARY_WATER); + //liquids.add(Material.FLOWING_WATER); liquids.add(Material.LAVA); //liquids.add(Material.STATIONARY_LAVA); } @@ -153,15 +153,17 @@ private void updateSide(Location side) { } private byte findWaterLevel(Location l) { - BlockState b = l.getBlock().getState(); + Block b = l.getBlock(); + BlockData bd = b.getBlockData(); + if (liquids.contains(b.getType())) { - byte data = b.getData().getData(); + Levelled data = (Levelled)bd; System.out.println("old = " + b); //System.out.println("new = " + b.getBlockData().getLevel()); - if (data>7) // falling liquid. full water block. + if (data.getLevel()>7) // falling liquid. full water block. return 8; else - return (byte)(8-b.getData().getData()); + return (byte)(8-data.getLevel()); } else { return 0; } diff --git a/src/main/java/org/redstonechips/sensorlibrary/pirsensor.java b/src/main/java/org/redstonechips/sensorlibrary/pirsensor.java index 92cbfc7..32e3f74 100755 --- a/src/main/java/org/redstonechips/sensorlibrary/pirsensor.java +++ b/src/main/java/org/redstonechips/sensorlibrary/pirsensor.java @@ -26,7 +26,7 @@ public void input(boolean state, int inIdx) { // clock pin triggered boolean alarm = false; - for (Object o : chip.world.getEntitiesByClass(checkedEntities)) { + for (Object o : chip.world.getEntitiesByClasses(checkedEntities)) { Entity e = (Entity)o; Location l = e.getLocation(); diff --git a/src/main/java/org/redstonechips/sensorlibrary/rangefinder.java b/src/main/java/org/redstonechips/sensorlibrary/rangefinder.java index 3024b48..7af3e85 100755 --- a/src/main/java/org/redstonechips/sensorlibrary/rangefinder.java +++ b/src/main/java/org/redstonechips/sensorlibrary/rangefinder.java @@ -199,6 +199,10 @@ private void trigger() { case NORTH: lp.add(0,0,-0.2); break; + default: + break; + + } objectsInRange.add(lp); } else { diff --git a/src/main/java/org/redstonechips/sensorlibrary/vehicleid.java b/src/main/java/org/redstonechips/sensorlibrary/vehicleid.java index 07b81fa..2abe456 100755 --- a/src/main/java/org/redstonechips/sensorlibrary/vehicleid.java +++ b/src/main/java/org/redstonechips/sensorlibrary/vehicleid.java @@ -19,6 +19,24 @@ public class vehicleid extends Circuit { private int lastInterface = -1; private byte distance = 1; private boolean sphere = false; + + private Boolean[] directionAim = new Boolean[] { + false, + false, + false, + false, + false, + false, + }; + + private static final String[] directionText = new String[] { + "EAST", + "WEST", + "NORTH", + "SOUTH", + "ABOVE", + "BELOW", + }; @Override public void input(boolean state, int inIdx) { @@ -61,6 +79,11 @@ public Circuit init(String[] args) { } else if (args[i].toUpperCase().equals("SPHERE")) sphere = true; else if (args[i].toUpperCase().equals("AXIS")) sphere = false; + for (byte j=0; j<=5; j++) { + if (args[i].toUpperCase().equals(directionText[j])) { // if sign arg is a direction, mark that direction as true + directionAim[j] = true; + } + } } } } @@ -79,7 +102,7 @@ public void onEvent(Event e) { for (int i=0; i0 && + Math.abs(too.getBlockY()-inn.getBlockY())<=distance && + Math.abs(too.getBlockZ()-inn.getBlockZ())<=distance); + boolean distanceSphereEast = (too.getBlockX()-inn.getBlockX()<=distance && + too.getBlockX()-inn.getBlockX()>0 && + Math.abs(too.getBlockY()-inn.getBlockY())<=distance && + Math.abs(too.getBlockZ()-inn.getBlockZ())<=distance); + boolean distanceSphereNorth = (inn.getBlockZ()-too.getBlockZ()<=distance && + inn.getBlockZ()-too.getBlockZ()>0 && + Math.abs(too.getBlockY()-inn.getBlockY())<=distance && + Math.abs(too.getBlockX()-inn.getBlockX())<=distance); + boolean distanceSphereSouth = (too.getBlockZ()-inn.getBlockZ()<=distance && + too.getBlockZ()-inn.getBlockZ()>0 && + Math.abs(too.getBlockY()-inn.getBlockY())<=distance && + Math.abs(too.getBlockX()-inn.getBlockX())<=distance); + boolean distanceSphereAbove = (too.getBlockY()-inn.getBlockY()<=distance && + too.getBlockY()-inn.getBlockY()>0 && + Math.abs(too.getBlockZ()-inn.getBlockZ())<=distance && + Math.abs(too.getBlockX()-inn.getBlockX())<=distance); + boolean distanceSphereBelow = (inn.getBlockY()-too.getBlockY()<=distance && + inn.getBlockY()-too.getBlockY()>0 && + Math.abs(too.getBlockZ()-inn.getBlockZ())<=distance && + Math.abs(too.getBlockX()-inn.getBlockX())<=distance); + boolean distanceSphere = (distanceSphereEast&&!directionAim[1]&&!directionAim[2]&&!directionAim[3]&&!directionAim[4]&&!directionAim[5]) + || (distanceSphereWest&&!directionAim[0]&&!directionAim[2]&&!directionAim[3]&&!directionAim[4]&&!directionAim[5]) + || (distanceSphereNorth&&!directionAim[1]&&!directionAim[0]&&!directionAim[3]&&!directionAim[4]&&!directionAim[5]) + || (distanceSphereSouth&&!directionAim[1]&&!directionAim[2]&&!directionAim[0]&&!directionAim[4]&&!directionAim[5]) + || (distanceSphereAbove&&!directionAim[1]&&!directionAim[2]&&!directionAim[3]&&!directionAim[0]&&!directionAim[5]) + || (distanceSphereBelow&&!directionAim[1]&&!directionAim[2]&&!directionAim[3]&&!directionAim[4]&&!directionAim[0]); + if (distanceSphere) return true; } - else if (!sphere) { - boolean distanceCheckRight = (Math.abs(too.getBlockX()-inn.getBlockX())<=distance && too.getBlockY()-inn.getBlockY()==0 && too.getBlockZ()-inn.getBlockZ()==0); - boolean distanceCheckLeft = (Math.abs(inn.getBlockX() - too.getBlockX())<=distance && too.getBlockY()-inn.getBlockY()==0 && too.getBlockZ()-inn.getBlockZ()==0); - boolean distanceCheckFront = (Math.abs(too.getBlockZ()-inn.getBlockZ())<=distance && too.getBlockY()-inn.getBlockY()==0 && too.getBlockX()-inn.getBlockX()==0); - boolean distanceCheckBack = (Math.abs(inn.getBlockZ()-too.getBlockZ())<=distance && too.getBlockY()-inn.getBlockY()==0 && too.getBlockX()-inn.getBlockX()==0); - boolean distanceCheckAbove = (Math.abs(too.getBlockY()-inn.getBlockY())<=distance && too.getBlockX()-inn.getBlockX()==0 && too.getBlockZ()-inn.getBlockZ()==0); - boolean distanceCheckBelow = (Math.abs(inn.getBlockY()-too.getBlockY())<=distance && too.getBlockX()-inn.getBlockX()==0 && too.getBlockZ()-inn.getBlockZ()==0); - boolean axisDistance = distanceCheckRight || distanceCheckLeft || distanceCheckFront || distanceCheckBack || distanceCheckAbove || distanceCheckBelow; + else { + boolean distanceCheckEast= (too.getBlockX()-inn.getBlockX()<=distance && + too.getBlockX()-inn.getBlockX()>0 && + too.getBlockY()-inn.getBlockY()==0 && + too.getBlockZ()-inn.getBlockZ()==0); // can not use ABS as it will flag opposing sides as true instead of just one side + + boolean distanceCheckWest= (inn.getBlockX()-too.getBlockX()<=distance && + inn.getBlockX()-too.getBlockX()>0 && + too.getBlockY()-inn.getBlockY()==0 && + too.getBlockZ()-inn.getBlockZ()==0); + + boolean distanceCheckNorth=(inn.getBlockZ()-too.getBlockZ()<=distance && + inn.getBlockZ()-too.getBlockZ()>0 && + too.getBlockY()-inn.getBlockY()==0 && + too.getBlockX()-inn.getBlockX()==0); + + boolean distanceCheckSouth=(too.getBlockZ()-inn.getBlockZ()<=distance && + too.getBlockZ()-inn.getBlockZ()>0 && + too.getBlockY()-inn.getBlockY()==0 && + too.getBlockX()-inn.getBlockX()==0); + + boolean distanceCheckAbove=(too.getBlockY()-inn.getBlockY()<=distance && + too.getBlockY()-inn.getBlockY()>0 && + too.getBlockX()-inn.getBlockX()==0 && + too.getBlockZ()-inn.getBlockZ()==0); + + boolean distanceCheckBelow=(inn.getBlockY()-too.getBlockY()<=distance && + inn.getBlockY()-too.getBlockY()>0 && + too.getBlockX()-inn.getBlockX()==0 && + too.getBlockZ()-inn.getBlockZ()==0); + + boolean axisDistance = (distanceCheckEast&&!directionAim[1]&&!directionAim[2]&&!directionAim[3]&&!directionAim[4]&&!directionAim[5]) + || (distanceCheckWest&&!directionAim[0]&&!directionAim[2]&&!directionAim[3]&&!directionAim[4]&&!directionAim[5]) + || (distanceCheckNorth&&!directionAim[1]&&!directionAim[0]&&!directionAim[3]&&!directionAim[4]&&!directionAim[5]) + || (distanceCheckSouth&&!directionAim[1]&&!directionAim[2]&&!directionAim[0]&&!directionAim[4]&&!directionAim[5]) + || (distanceCheckAbove&&!directionAim[1]&&!directionAim[2]&&!directionAim[3]&&!directionAim[0]&&!directionAim[5]) + || (distanceCheckBelow&&!directionAim[1]&&!directionAim[2]&&!directionAim[3]&&!directionAim[4]&&!directionAim[0]); if (axisDistance) return true; } return false; From a1e723feceeeb55a7fa4f200c9e1595b031324aa Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sat, 23 May 2020 21:47:11 -0400 Subject: [PATCH 10/12] Version update --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 150913e..449bb79 100755 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ jar SensorLibrary http://maven.apache.org - 1.0-SNAPSHOT + 1.1-SNAPSHOT From 8f1e456a6ab651d94ac67ed619c23be3a4808025 Mon Sep 17 00:00:00 2001 From: eisental Date: Sat, 23 May 2020 21:53:45 -0400 Subject: [PATCH 11/12] Version update --- README.md | 8 ++++++-- plugin.yml | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2c4aec2..896d30c 100755 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ a [RedstoneChips](http://eisental.github.com/RedstoneChips) circuit library cont - rangefinder - An ultrasonic transceiver for detecting the exact distance between the chip and anything. - beacon - Can force map chunks to stay loaded and monitors whether chunks in a region are loaded or not. - slotinput - Input decimal numbers by choosing an inventory slot and clicking an interface block. -- vehicleid - Track a vehicle entity id number as it passes over the chip interface blocks. +- vehicleid - Track a vehicle entity id number as it passes by the chip interface blocks. - playerid - Track a player entity id. - spark - Strike thunders on command. @@ -19,10 +19,14 @@ __For much more information, see the [circuitdocs](http://eisental.github.com/Re Installation ------------- * Download the latest RedstoneChips bundle [RedstoneChips](http://eisental.github.com/RedstoneChips). -* Copy all jar files into the plugins folder of your craftbukkit installation. +* Copy all jar files into the plugins folder of your spigot installation. Changelog --------- +#### SensorLibrary 0.4 +- Updated for RC1.0 +__playerid__: Added sign arguments for sphere and axis type detection and distance of detection +__vehicleid__: Added sign arguments for sphere and axis type detection and distance of detection #### SensorLibrary 0.34 - __daytime__: Fixed daytime offset bug. diff --git a/plugin.yml b/plugin.yml index 4e0e831..69c7240 100755 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: SensorLibrary main: org.redstonechips.sensorlibrary.SensorLibrary -version: 0.35 +version: 0.40 api-version: 1.15 author: eisental description: Sensor library for RedstoneChips integrated circuits plugin. From 52c75f29d87a2ec3d85966eccfc3687e417aa745 Mon Sep 17 00:00:00 2001 From: RufiS Date: Thu, 14 Sep 2023 23:02:01 -0400 Subject: [PATCH 12/12] Updated for 1.21.1 --- pom.xml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 449bb79..c871ea8 100755 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ jar SensorLibrary http://maven.apache.org - 1.1-SNAPSHOT + 1.0-SNAPSHOT @@ -22,10 +22,17 @@ + + org.bukkit + bukkit + 1.15.2-R0.1-SNAPSHOT + jar + provided + org.redstonechips RedstoneChips - 1.0-SNAPSHOT + 1.1-SNAPSHOT