diff --git a/pom.xml b/pom.xml
index f72d6634b..b80c84bbd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -112,7 +112,7 @@
com.sk89q.worldedit
worldedit-bukkit
- 7.0.0
+ 7.0.1
provided
diff --git a/src/me/mrCookieSlime/Slimefun/Android/ProgrammableAndroid.java b/src/me/mrCookieSlime/Slimefun/Android/ProgrammableAndroid.java
index c2431eea2..e27cbd00e 100644
--- a/src/me/mrCookieSlime/Slimefun/Android/ProgrammableAndroid.java
+++ b/src/me/mrCookieSlime/Slimefun/Android/ProgrammableAndroid.java
@@ -69,12 +69,13 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
private static final int[] border = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 18, 24, 25, 26, 27, 33, 35, 36, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53};
private static final int[] border_out = {10, 11, 12, 13, 14, 19, 23, 28, 32, 37, 38, 39, 40, 41};
-
+
private static final ItemStack[] fish = new ItemStack[] {new ItemStack(Material.COD), new ItemStack(Material.SALMON), new ItemStack(Material.PUFFERFISH), new ItemStack(Material.TROPICAL_FISH), new ItemStack(Material.STRING), new ItemStack(Material.BONE), new ItemStack(Material.STICK)};
private static final List directions = Arrays.asList(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST);
private static final List blockblacklist = new ArrayList<>();
+
static {
blockblacklist.add(Material.BEDROCK);
blockblacklist.add(Material.BARRIER);
@@ -215,6 +216,8 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
boolean allow = reason.equals(UnregisterReason.PLAYER_BREAK) && (BlockStorage.getLocationInfo(b.getLocation(), "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.android.bypass"));
+ if (BlockStorage.hasBlockInfo(b)) return false;
+
if (allow) {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {
@@ -273,419 +276,419 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
if (getAndroidType().isType(part.getRequiredType())) {
switch (part) {
- case GO_DOWN: {
- try {
- BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
- Block block = b.getRelative(BlockFace.DOWN);
- move(b, face, block);
- } catch (Exception e) {
- e.printStackTrace();
+ case GO_DOWN: {
+ try {
+ BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
+ Block block = b.getRelative(BlockFace.DOWN);
+ move(b, face, block);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ break;
}
- break;
- }
- case GO_FORWARD: {
- try {
+ case GO_FORWARD: {
+ try {
+ BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
+ Block block = b.getRelative(face);
+ move(b, face, block);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ break;
+ }
+ case GO_UP: {
+ try {
+ BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
+ Block block = b.getRelative(BlockFace.UP);
+ move(b, face, block);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ break;
+ }
+ case REPEAT: {
+ BlockStorage.addBlockInfo(b, "index", String.valueOf(0));
+ break;
+ }
+ case TURN_LEFT: {
+ int rotIndex = directions.indexOf(BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"))) - 1;
+ if (rotIndex < 0) rotIndex = directions.size() - 1;
+ BlockFace dir = directions.get(rotIndex);
+ Rotatable blockData = (Rotatable) b.getBlockData();
+ blockData.setRotation(dir);
+ b.setBlockData(blockData);
+ BlockStorage.addBlockInfo(b, "rotation", dir.toString());
+ break;
+ }
+ case TURN_RIGHT: {
+ int rotIndex = directions.indexOf(BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"))) + 1;
+ if (rotIndex == directions.size()) rotIndex = 0;
+ BlockFace dir = directions.get(rotIndex);
+ Rotatable blockData = (Rotatable) b.getBlockData();
+ blockData.setRotation(dir);
+ b.setBlockData(blockData);
+ BlockStorage.addBlockInfo(b, "rotation", dir.toString());
+ break;
+ }
+ case DIG_FORWARD: {
+ Block block = b.getRelative(BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation")));
+ mine(b, block);
+ break;
+ }
+ case DIG_UP: {
+ Block block = b.getRelative(BlockFace.UP);
+ mine(b, block);
+ break;
+ }
+ case DIG_DOWN: {
+ Block block = b.getRelative(BlockFace.DOWN);
+ mine(b, block);
+ break;
+ }
+ case CATCH_FISH: {
+ Block block = b.getRelative(BlockFace.DOWN);
+ if (block.getType().equals(Material.WATER)) {
+ block.getWorld().playSound(block.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1F, 1F);
+ if (CSCoreLib.randomizer().nextInt(100) < 10 * getTier()) {
+ ItemStack drop = fish[CSCoreLib.randomizer().nextInt(fish.length)];
+ if (fits(b, drop)) pushItems(b, drop);
+ }
+
+ }
+ break;
+ }
+ case MOVE_AND_DIG_FORWARD: {
BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
Block block = b.getRelative(face);
- move(b, face, block);
- } catch (Exception e) {
- e.printStackTrace();
+ movedig(b, face, block);
+ break;
}
- break;
- }
- case GO_UP: {
- try {
+ case MOVE_AND_DIG_UP: {
BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
Block block = b.getRelative(BlockFace.UP);
- move(b, face, block);
- } catch (Exception e) {
- e.printStackTrace();
+ movedig(b, face, block);
+ break;
}
- break;
- }
- case REPEAT: {
- BlockStorage.addBlockInfo(b, "index", String.valueOf(0));
- break;
- }
- case TURN_LEFT: {
- int rotIndex = directions.indexOf(BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"))) - 1;
- if (rotIndex < 0) rotIndex = directions.size() - 1;
- BlockFace dir = directions.get(rotIndex);
- Rotatable blockData = (Rotatable) b.getBlockData();
- blockData.setRotation(dir);
- b.setBlockData(blockData);
- BlockStorage.addBlockInfo(b, "rotation", dir.toString());
- break;
- }
- case TURN_RIGHT: {
- int rotIndex = directions.indexOf(BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"))) + 1;
- if (rotIndex == directions.size()) rotIndex = 0;
- BlockFace dir = directions.get(rotIndex);
- Rotatable blockData = (Rotatable) b.getBlockData();
- blockData.setRotation(dir);
- b.setBlockData(blockData);
- BlockStorage.addBlockInfo(b, "rotation", dir.toString());
- break;
- }
- case DIG_FORWARD: {
- Block block = b.getRelative(BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation")));
- mine(b, block);
- break;
- }
- case DIG_UP: {
- Block block = b.getRelative(BlockFace.UP);
- mine(b, block);
- break;
- }
- case DIG_DOWN: {
- Block block = b.getRelative(BlockFace.DOWN);
- mine(b, block);
- break;
- }
- case CATCH_FISH: {
- Block block = b.getRelative(BlockFace.DOWN);
- if (block.getType().equals(Material.WATER)) {
- block.getWorld().playSound(block.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1F, 1F);
- if (CSCoreLib.randomizer().nextInt(100) < 10 * getTier()) {
- ItemStack drop = fish[CSCoreLib.randomizer().nextInt(fish.length)];
- if (fits(b, drop)) pushItems(b, drop);
+ case MOVE_AND_DIG_DOWN: {
+ BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
+ Block block = b.getRelative(BlockFace.DOWN);
+ movedig(b, face, block);
+ break;
+ }
+ case INTERFACE_ITEMS: {
+ BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
+ Block block = b.getRelative(face);
+ if (BlockStorage.check(block, "ANDROID_INTERFACE_ITEMS") && block.getState() instanceof Dispenser) {
+ Dispenser d = (Dispenser) block.getState();
+ for (int slot: getOutputSlots()) {
+ ItemStack stack = BlockStorage.getInventory(b).getItemInSlot(slot);
+ if (stack != null) {
+ Map items = d.getInventory().addItem(stack);
+ if (items.isEmpty()) BlockStorage.getInventory(b).replaceExistingItem(slot, null);
+ else {
+ for (Map.Entry entry: items.entrySet()) {
+ BlockStorage.getInventory(b).replaceExistingItem(slot, entry.getValue());
+ break;
+ }
+ }
+ }
+ }
}
-
+ break;
}
- break;
- }
- case MOVE_AND_DIG_FORWARD: {
- BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
- Block block = b.getRelative(face);
- movedig(b, face, block);
- break;
- }
- case MOVE_AND_DIG_UP: {
- BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
- Block block = b.getRelative(BlockFace.UP);
- movedig(b, face, block);
- break;
- }
- case MOVE_AND_DIG_DOWN: {
- BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
- Block block = b.getRelative(BlockFace.DOWN);
- movedig(b, face, block);
- break;
- }
- case INTERFACE_ITEMS: {
- BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
- Block block = b.getRelative(face);
- if (BlockStorage.check(block, "ANDROID_INTERFACE_ITEMS") && block.getState() instanceof Dispenser) {
- Dispenser d = (Dispenser) block.getState();
- for (int slot: getOutputSlots()) {
- ItemStack stack = BlockStorage.getInventory(b).getItemInSlot(slot);
- if (stack != null) {
- Map items = d.getInventory().addItem(stack);
- if (items.isEmpty()) BlockStorage.getInventory(b).replaceExistingItem(slot, null);
- else {
- for (Map.Entry entry: items.entrySet()) {
- BlockStorage.getInventory(b).replaceExistingItem(slot, entry.getValue());
+ case INTERFACE_FUEL: {
+ BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
+ Block block = b.getRelative(face);
+ if (BlockStorage.check(block, "ANDROID_INTERFACE_FUEL") && block.getState() instanceof Dispenser) {
+ Dispenser d = (Dispenser) block.getState();
+ for (int slot = 0; slot < 9; slot++) {
+ ItemStack item = d.getInventory().getItem(slot);
+ if (item != null) {
+ if (BlockStorage.getInventory(b).getItemInSlot(43) == null) {
+ BlockStorage.getInventory(b).replaceExistingItem(43, item);
+ d.getInventory().setItem(slot, null);
+ break;
+ }
+ else if (SlimefunManager.isItemSimiliar(item, BlockStorage.getInventory(b).getItemInSlot(43), true)) {
+ int rest = item.getType().getMaxStackSize() - BlockStorage.getInventory(b).getItemInSlot(43).getAmount();
+ if (rest > 0) {
+ int amt = item.getAmount() > rest ? rest: item.getAmount();
+ BlockStorage.getInventory(b).replaceExistingItem(43, new CustomItem(item, BlockStorage.getInventory(b).getItemInSlot(43).getAmount() + amt));
+ d.getInventory().setItem(slot, InvUtils.decreaseItem(item, amt));
+ }
break;
}
}
}
}
+ break;
}
- break;
- }
- case INTERFACE_FUEL: {
- BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
- Block block = b.getRelative(face);
- if (BlockStorage.check(block, "ANDROID_INTERFACE_FUEL") && block.getState() instanceof Dispenser) {
- Dispenser d = (Dispenser) block.getState();
- for (int slot = 0; slot < 9; slot++) {
- ItemStack item = d.getInventory().getItem(slot);
- if (item != null) {
- if (BlockStorage.getInventory(b).getItemInSlot(43) == null) {
- BlockStorage.getInventory(b).replaceExistingItem(43, item);
- d.getInventory().setItem(slot, null);
- break;
+ case FARM_FORWARD: {
+ BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
+ Block block = b.getRelative(face);
+ farm(b, block);
+ break;
+ }
+ case FARM_DOWN: {
+ Block block = b.getRelative(BlockFace.DOWN);
+ farm(b, block);
+ break;
+ }
+ case FARM_EXOTIC_FORWARD: {
+ BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
+ Block block = b.getRelative(face);
+ exoticFarm(b, block);
+ break;
+ }
+ case FARM_EXOTIC_DOWN: {
+ Block block = b.getRelative(BlockFace.DOWN);
+ exoticFarm(b, block);
+ break;
+ }
+ case CHOP_TREE: {
+ BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
+ Block block = b.getRelative(face);
+ if (MaterialHelper.isLog( block.getType())) {
+ List list = new ArrayList();
+ list.add(block.getLocation());
+ TreeCalculator.getTree(block.getLocation(), block.getLocation(), list);
+ if (!list.isEmpty()) {
+ refresh = false;
+ Block log = list.get(list.size() - 1).getBlock();
+ Collection drops = log.getDrops();
+ log.getWorld().playEffect(log.getLocation(), Effect.STEP_SOUND, log.getType());
+ if (!drops.isEmpty() && CSCoreLib.getLib().getProtectionManager().canBuild(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), log)) {
+ ItemStack[] items = drops.toArray(new ItemStack[drops.size()]);
+ if (fits(b, items)) {
+ pushItems(b, items);
+ log.getWorld().playEffect(log.getLocation(), Effect.STEP_SOUND, log.getType());
+ if (log.getY() == block.getY()) {
+ log.setType(MaterialHelper.getSaplingFromLog(log.getType()));
+ }
+ else log.setType(Material.AIR);
+ }
+
}
- else if (SlimefunManager.isItemSimiliar(item, BlockStorage.getInventory(b).getItemInSlot(43), true)) {
- int rest = item.getType().getMaxStackSize() - BlockStorage.getInventory(b).getItemInSlot(43).getAmount();
- if (rest > 0) {
- int amt = item.getAmount() > rest ? rest: item.getAmount();
- BlockStorage.getInventory(b).replaceExistingItem(43, new CustomItem(item, BlockStorage.getInventory(b).getItemInSlot(43).getAmount() + amt));
- d.getInventory().setItem(slot, InvUtils.decreaseItem(item, amt));
+ }
+ }
+ break;
+ }
+ case ATTACK_MOBS_ANIMALS: {
+ double damage = getTier() < 2 ? 20D : 4D * getTier();
+
+ entities:
+ for (Entity n: AndroidStatusHologram.getNearbyEntities(b, 4D + getTier())) {
+ switch (BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"))) {
+ case NORTH: {
+ if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getZ() < b.getZ()) {
+ if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
+ n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
+
+ ((LivingEntity) n).damage(damage);
+ break entities;
}
break;
}
- }
- }
- }
- break;
- }
- case FARM_FORWARD: {
- BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
- Block block = b.getRelative(face);
- farm(b, block);
- break;
- }
- case FARM_DOWN: {
- Block block = b.getRelative(BlockFace.DOWN);
- farm(b, block);
- break;
- }
- case FARM_EXOTIC_FORWARD: {
- BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
- Block block = b.getRelative(face);
- exoticFarm(b, block);
- break;
- }
- case FARM_EXOTIC_DOWN: {
- Block block = b.getRelative(BlockFace.DOWN);
- exoticFarm(b, block);
- break;
- }
- case CHOP_TREE: {
- BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
- Block block = b.getRelative(face);
- if (MaterialHelper.isLog( block.getType())) {
- List list = new ArrayList();
- list.add(block.getLocation());
- TreeCalculator.getTree(block.getLocation(), block.getLocation(), list);
- if (!list.isEmpty()) {
- refresh = false;
- Block log = list.get(list.size() - 1).getBlock();
- Collection drops = log.getDrops();
- log.getWorld().playEffect(log.getLocation(), Effect.STEP_SOUND, log.getType());
- if (!drops.isEmpty() && CSCoreLib.getLib().getProtectionManager().canBuild(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), log)) {
- ItemStack[] items = drops.toArray(new ItemStack[drops.size()]);
- if (fits(b, items)) {
- pushItems(b, items);
- log.getWorld().playEffect(log.getLocation(), Effect.STEP_SOUND, log.getType());
- if (log.getY() == block.getY()) {
- log.setType(MaterialHelper.getSaplingFromLog(log.getType()));
+ case EAST: {
+ if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getX() > b.getX()) {
+ if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
+ n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
+
+ ((LivingEntity) n).damage(damage);
+ break entities;
}
- else log.setType(Material.AIR);
+ break;
}
+ case SOUTH: {
+ if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getZ() > b.getZ()) {
+ if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
+ n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
+ ((LivingEntity) n).damage(damage);
+ break entities;
+ }
+ break;
+ }
+ case WEST: {
+ if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getX() < b.getX()) {
+ if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
+ n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
+
+ ((LivingEntity) n).damage(damage);
+ break entities;
+ }
+ break;
+ }
+ default:
+ break;
}
- }
+ }
+ break;
}
- break;
- }
- case ATTACK_MOBS_ANIMALS: {
- double damage = getTier() < 2 ? 20D : 4D * getTier();
+ case ATTACK_MOBS: {
+ double damage = getTier() < 2 ? 20D : 4D * getTier();
- entities:
- for (Entity n: AndroidStatusHologram.getNearbyEntities(b, 4D + getTier())) {
- switch (BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"))) {
- case NORTH: {
- if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getZ() < b.getZ()) {
- if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
- n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
+ entities:
+ for (Entity n: AndroidStatusHologram.getNearbyEntities(b, 4D + getTier())) {
+ if (n instanceof Animals) continue;
+ switch (BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"))) {
+ case NORTH: {
+ if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getZ() < b.getZ()) {
+ if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
+ n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
- ((LivingEntity) n).damage(damage);
- break entities;
+ ((LivingEntity) n).damage(damage);
+ break entities;
+ }
+ break;
+ }
+ case EAST: {
+ if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getX() > b.getX()) {
+ if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
+ n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
+
+ ((LivingEntity) n).damage(damage);
+ break entities;
+ }
+ break;
+ }
+ case SOUTH: {
+ if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getZ() > b.getZ()) {
+ if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
+ n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
+
+ ((LivingEntity) n).damage(damage);
+ break entities;
+ }
+ break;
+ }
+ case WEST: {
+ if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getX() < b.getX()) {
+ if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
+ n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
+
+ ((LivingEntity) n).damage(damage);
+ break entities;
+ }
+ break;
+ }
+ default:
+ break;
}
- break;
- }
- case EAST: {
- if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getX() > b.getX()) {
- if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
- n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
-
- ((LivingEntity) n).damage(damage);
- break entities;
- }
- break;
- }
- case SOUTH: {
- if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getZ() > b.getZ()) {
- if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
- n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
-
- ((LivingEntity) n).damage(damage);
- break entities;
- }
- break;
- }
- case WEST: {
- if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getX() < b.getX()) {
- if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
- n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
-
- ((LivingEntity) n).damage(damage);
- break entities;
- }
- break;
- }
- default:
- break;
}
+ break;
}
- break;
- }
- case ATTACK_MOBS: {
- double damage = getTier() < 2 ? 20D : 4D * getTier();
- entities:
- for (Entity n: AndroidStatusHologram.getNearbyEntities(b, 4D + getTier())) {
- if (n instanceof Animals) continue;
- switch (BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"))) {
- case NORTH: {
- if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getZ() < b.getZ()) {
- if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
- n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
+ case ATTACK_ANIMALS: {
+ double damage = getTier() < 2 ? 20D : 4D * getTier();
- ((LivingEntity) n).damage(damage);
- break entities;
+ entities:
+ for (Entity n: AndroidStatusHologram.getNearbyEntities(b, 4D + getTier())) {
+ if (n instanceof Monster) continue;
+ switch (BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"))) {
+ case NORTH: {
+ if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getZ() < b.getZ()) {
+ if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
+ n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
+
+ ((LivingEntity) n).damage(damage);
+ break entities;
+ }
+ break;
+ }
+ case EAST: {
+ if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getX() > b.getX()) {
+ if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
+ n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
+
+ ((LivingEntity) n).damage(damage);
+ break entities;
+ }
+ break;
+ }
+ case SOUTH: {
+ if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getZ() > b.getZ()) {
+ if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
+ n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
+
+ ((LivingEntity) n).damage(damage);
+ break entities;
+ }
+ break;
+ }
+ case WEST: {
+ if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getX() < b.getX()) {
+ if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
+ n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
+
+ ((LivingEntity) n).damage(damage);
+ break entities;
+ }
+ break;
+ }
+ default:
+ break;
}
- break;
- }
- case EAST: {
- if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getX() > b.getX()) {
- if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
- n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
-
- ((LivingEntity) n).damage(damage);
- break entities;
- }
- break;
- }
- case SOUTH: {
- if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getZ() > b.getZ()) {
- if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
- n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
-
- ((LivingEntity) n).damage(damage);
- break entities;
- }
- break;
- }
- case WEST: {
- if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getX() < b.getX()) {
- if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
- n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
-
- ((LivingEntity) n).damage(damage);
- break entities;
- }
- break;
- }
- default:
- break;
}
+ break;
}
- break;
- }
- case ATTACK_ANIMALS: {
- double damage = getTier() < 2 ? 20D : 4D * getTier();
+ case ATTACK_ANIMALS_ADULT: {
+ double damage = getTier() < 2 ? 20D : 4D * getTier();
- entities:
- for (Entity n: AndroidStatusHologram.getNearbyEntities(b, 4D + getTier())) {
- if (n instanceof Monster) continue;
- switch (BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"))) {
- case NORTH: {
- if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getZ() < b.getZ()) {
- if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
- n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
+ entities:
+ for (Entity n: AndroidStatusHologram.getNearbyEntities(b, 4D + getTier())) {
+ if (n instanceof Monster) continue;
+ if (n instanceof org.bukkit.entity.Ageable && !((org.bukkit.entity.Ageable) n).isAdult()) continue;
+ switch (BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"))) {
+ case NORTH: {
+ if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getZ() < b.getZ()) {
+ if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
+ n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
- ((LivingEntity) n).damage(damage);
- break entities;
+ ((LivingEntity) n).damage(damage);
+ break entities;
+ }
+ break;
+ }
+ case EAST: {
+ if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getX() > b.getX()) {
+ if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
+ n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
+
+ ((LivingEntity) n).damage(damage);
+ break entities;
+ }
+ break;
+ }
+ case SOUTH: {
+ if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getZ() > b.getZ()) {
+ if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
+ n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
+
+ ((LivingEntity) n).damage(damage);
+ break entities;
+ }
+ break;
+ }
+ case WEST: {
+ if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getX() < b.getX()) {
+ if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
+ n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
+
+ ((LivingEntity) n).damage(damage);
+ break entities;
+ }
+ break;
+ }
+ default:
+ break;
}
- break;
- }
- case EAST: {
- if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getX() > b.getX()) {
- if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
- n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
-
- ((LivingEntity) n).damage(damage);
- break entities;
- }
- break;
- }
- case SOUTH: {
- if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getZ() > b.getZ()) {
- if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
- n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
-
- ((LivingEntity) n).damage(damage);
- break entities;
- }
- break;
- }
- case WEST: {
- if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getX() < b.getX()) {
- if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
- n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
-
- ((LivingEntity) n).damage(damage);
- break entities;
- }
- break;
- }
- default:
- break;
}
+ break;
}
- break;
- }
-
- case ATTACK_ANIMALS_ADULT: {
- double damage = getTier() < 2 ? 20D : 4D * getTier();
-
- entities:
- for (Entity n: AndroidStatusHologram.getNearbyEntities(b, 4D + getTier())) {
- if (n instanceof Monster) continue;
- if (n instanceof org.bukkit.entity.Ageable && !((org.bukkit.entity.Ageable) n).isAdult()) continue;
- switch (BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"))) {
- case NORTH: {
- if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getZ() < b.getZ()) {
- if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
- n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
-
- ((LivingEntity) n).damage(damage);
- break entities;
- }
- break;
- }
- case EAST: {
- if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getX() > b.getX()) {
- if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
- n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
-
- ((LivingEntity) n).damage(damage);
- break entities;
- }
- break;
- }
- case SOUTH: {
- if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getZ() > b.getZ()) {
- if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
- n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
-
- ((LivingEntity) n).damage(damage);
- break entities;
- }
- break;
- }
- case WEST: {
- if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.getLocation().getX() < b.getX()) {
- if (n.hasMetadata("android_killer")) n.removeMetadata("android_killer", SlimefunStartup.instance);
- n.setMetadata("android_killer", new FixedMetadataValue(SlimefunStartup.instance, new AndroidObject(this, b)));
-
- ((LivingEntity) n).damage(damage);
- break entities;
- }
- break;
- }
- default:
- break;
- }
- }
- break;
- }
- default:
- break;
+ default:
+ break;
}
}
if (refresh) BlockStorage.addBlockInfo(b, "index", String.valueOf(index));
@@ -711,19 +714,20 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
Collection drops = block.getDrops();
if (!blockblacklist.contains(block.getType()) && !drops.isEmpty() && CSCoreLib.getLib().getProtectionManager().canBuild(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), block)) {
SlimefunItem item = BlockStorage.check(block);
+
if (item != null) {
- if (fits(b, item.getItem())) {
- if (SlimefunItem.blockhandler.containsKey(item.getID())) {
- if (SlimefunItem.blockhandler.get(item.getID()).onBreak(null, block, item, UnregisterReason.ANDROID_DIG)) {
- pushItems(b, BlockStorage.retrieve(block));
- if (SlimefunItem.blockhandler.containsKey(item.getID())) SlimefunItem.blockhandler.get(item.getID()).onBreak(null, block, item, UnregisterReason.ANDROID_DIG);
- block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
- block.setType(Material.AIR);
- }
- }
- }
- }
- else {
+ return;
+ /*if (fits(b, item.getItem())) {
+ if (SlimefunItem.blockhandler.containsKey(item.getID())) {
+ if (SlimefunItem.blockhandler.get(item.getID()).onBreak(null, block, item, UnregisterReason.ANDROID_DIG)) {
+ pushItems(b, BlockStorage.retrieve(block));
+ if (SlimefunItem.blockhandler.containsKey(item.getID())) SlimefunItem.blockhandler.get(item.getID()).onBreak(null, block, item, UnregisterReason.ANDROID_DIG);
+ block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
+ block.setType(Material.AIR);
+ }
+ }
+ }*/
+ } else {
ItemStack[] items = drops.toArray(new ItemStack[drops.size()]);
if (fits(b, items)) {
pushItems(b, items);
@@ -734,6 +738,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
}
}
+
private void movedig(Block b, BlockFace face, Block block) {
Collection drops = block.getDrops();
if (!blockblacklist.contains(block.getType()) && !drops.isEmpty() && CSCoreLib.getLib().getProtectionManager().canBuild(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), block)) {
@@ -788,111 +793,111 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
return ageable.getAge() >= ageable.getMaximumAge();
}
- private void farm(Block b, Block block) {
- switch (block.getType()) {
- case WHEAT: {
- if (isFullGrown(block)) {
- ItemStack drop = new ItemStack(Material.WHEAT, CSCoreLib.randomizer().nextInt(3) + 1);
- if (fits(b, drop)) {
- pushItems(b, drop);
- Ageable ageable = (Ageable) block.getBlockData();
- ageable.setAge(0);
- block.setBlockData(ageable);
- block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
- }
- }
- break;
- }
- case POTATOES: {
- if (isFullGrown(block)) {
- ItemStack drop = new ItemStack(Material.POTATO, CSCoreLib.randomizer().nextInt(3) + 1);
- if (fits(b, drop)) {
- pushItems(b, drop);
- Ageable ageable = (Ageable) block.getBlockData();
- ageable.setAge(0);
- block.setBlockData(ageable);
- block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
- }
- }
- break;
- }
- case CARROTS: {
- if (isFullGrown(block)) {
- ItemStack drop = new ItemStack(Material.CARROT, CSCoreLib.randomizer().nextInt(3) + 1);
- if (fits(b, drop)) {
- pushItems(b, drop);
- Ageable ageable = (Ageable) block.getBlockData();
- ageable.setAge(0);
- block.setBlockData(ageable);
- block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
- }
- }
- break;
- }
+ private void farm(Block b, Block block) {
+ switch (block.getType()) {
+ case WHEAT: {
+ if (isFullGrown(block)) {
+ ItemStack drop = new ItemStack(Material.WHEAT, CSCoreLib.randomizer().nextInt(3) + 1);
+ if (fits(b, drop)) {
+ pushItems(b, drop);
+ Ageable ageable = (Ageable) block.getBlockData();
+ ageable.setAge(0);
+ block.setBlockData(ageable);
+ block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
+ }
+ }
+ break;
+ }
+ case POTATOES: {
+ if (isFullGrown(block)) {
+ ItemStack drop = new ItemStack(Material.POTATO, CSCoreLib.randomizer().nextInt(3) + 1);
+ if (fits(b, drop)) {
+ pushItems(b, drop);
+ Ageable ageable = (Ageable) block.getBlockData();
+ ageable.setAge(0);
+ block.setBlockData(ageable);
+ block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
+ }
+ }
+ break;
+ }
+ case CARROTS: {
+ if (isFullGrown(block)) {
+ ItemStack drop = new ItemStack(Material.CARROT, CSCoreLib.randomizer().nextInt(3) + 1);
+ if (fits(b, drop)) {
+ pushItems(b, drop);
+ Ageable ageable = (Ageable) block.getBlockData();
+ ageable.setAge(0);
+ block.setBlockData(ageable);
+ block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
+ }
+ }
+ break;
+ }
case BEETROOTS: {
- if (isFullGrown(block)) {
- ItemStack drop = new ItemStack(Material.BEETROOT, CSCoreLib.randomizer().nextInt(3) + 1);
- if (fits(b, drop)) {
- pushItems(b, drop);
- Ageable ageable = (Ageable) block.getBlockData();
- ageable.setAge(0);
- block.setBlockData(ageable);
- block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
- }
- }
- break;
- }
- case COCOA: {
- if (isFullGrown(block)) {
- ItemStack drop = new ItemStack(Material.COCOA_BEANS, CSCoreLib.randomizer().nextInt(3) + 1);
- if (fits(b, drop)) {
- pushItems(b, drop);
- Ageable ageable = (Ageable) block.getBlockData();
- ageable.setAge(0);
- block.setBlockData(ageable);
- block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
- }
- }
- break;
- }
+ if (isFullGrown(block)) {
+ ItemStack drop = new ItemStack(Material.BEETROOT, CSCoreLib.randomizer().nextInt(3) + 1);
+ if (fits(b, drop)) {
+ pushItems(b, drop);
+ Ageable ageable = (Ageable) block.getBlockData();
+ ageable.setAge(0);
+ block.setBlockData(ageable);
+ block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
+ }
+ }
+ break;
+ }
+ case COCOA: {
+ if (isFullGrown(block)) {
+ ItemStack drop = new ItemStack(Material.COCOA_BEANS, CSCoreLib.randomizer().nextInt(3) + 1);
+ if (fits(b, drop)) {
+ pushItems(b, drop);
+ Ageable ageable = (Ageable) block.getBlockData();
+ ageable.setAge(0);
+ block.setBlockData(ageable);
+ block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
+ }
+ }
+ break;
+ }
case NETHER_WART: {
- if (isFullGrown(block)) {
- ItemStack drop = new ItemStack(Material.NETHER_WART, CSCoreLib.randomizer().nextInt(3) + 1);
- if (fits(b, drop)) {
- pushItems(b, drop);
- Ageable ageable = (Ageable) block.getBlockData();
- ageable.setAge(0);
- block.setBlockData(ageable);
- block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
- }
- }
- break;
- }
- default:
- break;
- }
- }
+ if (isFullGrown(block)) {
+ ItemStack drop = new ItemStack(Material.NETHER_WART, CSCoreLib.randomizer().nextInt(3) + 1);
+ if (fits(b, drop)) {
+ pushItems(b, drop);
+ Ageable ageable = (Ageable) block.getBlockData();
+ ageable.setAge(0);
+ block.setBlockData(ageable);
+ block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
+ }
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
- private void exoticFarm(Block b, Block block) {
+ private void exoticFarm(Block b, Block block) {
farm(b, block);
- if (SlimefunStartup.instance.isExoticGardenInstalled()) {
- ItemStack drop = ExoticGarden.harvestPlant(block);
- if (drop != null && fits(b, drop)) {
- pushItems(b, drop);
- block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
- }
- }
- }
+ if (SlimefunStartup.instance.isExoticGardenInstalled()) {
+ ItemStack drop = ExoticGarden.harvestPlant(block);
+ if (drop != null && fits(b, drop)) {
+ pushItems(b, drop);
+ block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
+ }
+ }
+ }
private void constructMenu(BlockMenuPreset preset) throws Exception {
for (int i : border) {
preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "),
- (p, slot, item, action) -> false
+ (p, slot, item, action) -> false
);
}
for (int i : border_out) {
preset.addItem(i, new CustomItem(new ItemStack(Material.ORANGE_STAINED_GLASS_PANE), " "),
- (p, slot, item, action) -> false
+ (p, slot, item, action) -> false
);
}
@@ -913,17 +918,17 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
if (getTier() == 1) {
preset.addItem(34, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTM0M2NlNThkYTU0Yzc5OTI0YTJjOTMzMWNmYzQxN2ZlOGNjYmJlYTliZTQ1YTdhYzg1ODYwYTZjNzMwIn19fQ=="), "&8\u21E9 &cFuel Input &8\u21E9", "", "&rThis Android runs on solid Fuel", "&re.g. Coal, Wood, etc..."),
- (p, slot, item, action) -> false
+ (p, slot, item, action) -> false
);
}
else if (getTier() == 2){
preset.addItem(34, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTM0M2NlNThkYTU0Yzc5OTI0YTJjOTMzMWNmYzQxN2ZlOGNjYmJlYTliZTQ1YTdhYzg1ODYwYTZjNzMwIn19fQ=="), "&8\u21E9 &cFuel Input &8\u21E9", "", "&rThis Android runs on liquid Fuel", "&re.g. Lava, Oil, Fuel, etc..."),
- (p, slot, item, action) -> false
+ (p, slot, item, action) -> false
);
}
else {
preset.addItem(34, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTM0M2NlNThkYTU0Yzc5OTI0YTJjOTMzMWNmYzQxN2ZlOGNjYmJlYTliZTQ1YTdhYzg1ODYwYTZjNzMwIn19fQ=="), "&8\u21E9 &cFuel Input &8\u21E9", "", "&rThis Android runs on radioactive Fuel", "&re.g. Uranium, Neptunium or Boosted Uranium"),
- (p, slot, item, action) -> false
+ (p, slot, item, action) -> false
);
}
}
@@ -932,47 +937,47 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
ChestMenu menu = new ChestMenu("&eScript Editor");
menu.addItem(1, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDliZjZkYjRhZWRhOWQ4ODIyYjlmNzM2NTM4ZThjMThiOWE0ODQ0Zjg0ZWI0NTUwNGFkZmJmZWU4N2ViIn19fQ=="), "&2> Edit Script", "", "&aEdits your current Script"),
- (pl, slot, item, action) -> {
- try {
- openScript(pl, b, BlockStorage.getLocationInfo(b.getLocation(), "script"));
- } catch (Exception e) {
- e.printStackTrace();
+ (pl, slot, item, action) -> {
+ try {
+ openScript(pl, b, BlockStorage.getLocationInfo(b.getLocation(), "script"));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
}
- return false;
- }
);
menu.addItem(3, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTcxZDg5NzljMTg3OGEwNTk4N2E3ZmFmMjFiNTZkMWI3NDRmOWQwNjhjNzRjZmZjZGUxZWExZWRhZDU4NTIifX19"), "&4> Create new Script", "", "&cDeletes your current Script", "&cand creates a blank one"),
- (pl, slot, item, action) -> {
- try {
- openScript(pl, b, "START-TURN_LEFT-REPEAT");
- } catch (Exception e) {
- e.printStackTrace();
+ (pl, slot, item, action) -> {
+ try {
+ openScript(pl, b, "START-TURN_LEFT-REPEAT");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
}
- return false;
- }
);
menu.addItem(5, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzAxNTg2ZTM5ZjZmZmE2M2I0ZmIzMDFiNjVjYTdkYThhOTJmNzM1M2FhYWI4OWQzODg2NTc5MTI1ZGZiYWY5In19fQ=="), "&6> Download a Script", "", "&eDownload a Script from the Server", "&eYou can edit or simply use it"),
- (pl, slot, item, action) -> {
- try {
- openScriptDownloader(pl, b, 1);
- } catch (Exception e) {
- e.printStackTrace();
+ (pl, slot, item, action) -> {
+ try {
+ openScriptDownloader(pl, b, 1);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
}
- return false;
- }
);
menu.addItem(8, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTE4NWM5N2RiYjgzNTNkZTY1MjY5OGQyNGI2NDMyN2I3OTNhM2YzMmE5OGJlNjdiNzE5ZmJlZGFiMzVlIn19fQ=="), "&6> Back", "", "&7Return to the Android's interface"),
- (pl, slot, item, action) -> {
- try {
- BlockStorage.getInventory(b).open(p);
- } catch (Exception e) {
- e.printStackTrace();
+ (pl, slot, item, action) -> {
+ try {
+ BlockStorage.getInventory(b).open(p);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
}
- return false;
- }
);
menu.open(p);
@@ -1073,7 +1078,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
final ChestMenu menu = new ChestMenu("Android Scripts");
menu.addMenuOpeningHandler(
- (pl) -> pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_BLOCK_HAT, 0.7F, 0.7F)
+ (pl) -> pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_BLOCK_HAT, 0.7F, 0.7F)
);
List scripts = getUploadedScripts();
@@ -1084,7 +1089,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
for (int i = 45; i < 54; i++) {
menu.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "));
menu.addMenuClickHandler(i,
- (pl, slot, item, action) -> false
+ (pl, slot, item, action) -> false
);
}
@@ -1281,52 +1286,52 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
for (int i = 0; i < 9; i++) {
menu.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "),
- (pl, slot, item, action) -> false
+ (pl, slot, item, action) -> false
);
}
menu.addItem(9, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTYxMzlmZDFjNTY1NGU1NmU5ZTRlMmM4YmU3ZWIyYmQ1YjQ5OWQ2MzM2MTY2NjNmZWVlOTliNzQzNTJhZDY0In19fQ=="), "&rDo nothing"),
- (pl, slot, item, action) -> {
- int i = 0;
- StringBuilder builder = new StringBuilder("START-");
- for (String command : commands) {
- if (i != index && i > 0 && i < commands.length - 1) builder.append(command + "-");
- i++;
- }
- builder.append("REPEAT");
- BlockStorage.addBlockInfo(b, "script", builder.toString());
- try {
- openScript(p, b, builder.toString());
- } catch (Exception e) {
- e.printStackTrace();
- }
- return false;
- }
- );
-
- int i = 10;
- for (final ScriptPart part : getAccessibleScriptParts()) {
- menu.addItem(i, part.toItemStack(),
(pl, slot, item, action) -> {
- int j = 0;
+ int i = 0;
StringBuilder builder = new StringBuilder("START-");
for (String command : commands) {
- if (j > 0) {
- if (j == index) builder.append(part.toString() + "-");
- else if (j < commands.length - 1) builder.append(command + "-");
- }
- j++;
+ if (i != index && i > 0 && i < commands.length - 1) builder.append(command + "-");
+ i++;
}
builder.append("REPEAT");
BlockStorage.addBlockInfo(b, "script", builder.toString());
-
try {
- openScript(pl, b, builder.toString());
+ openScript(p, b, builder.toString());
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
+ );
+
+ int i = 10;
+ for (final ScriptPart part : getAccessibleScriptParts()) {
+ menu.addItem(i, part.toItemStack(),
+ (pl, slot, item, action) -> {
+ int j = 0;
+ StringBuilder builder = new StringBuilder("START-");
+ for (String command : commands) {
+ if (j > 0) {
+ if (j == index) builder.append(part.toString() + "-");
+ else if (j < commands.length - 1) builder.append(command + "-");
+ }
+ j++;
+ }
+ builder.append("REPEAT");
+ BlockStorage.addBlockInfo(b, "script", builder.toString());
+
+ try {
+ openScript(pl, b, builder.toString());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
);
i++;
}
diff --git a/src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java b/src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java
index 563aeb73b..b71341439 100644
--- a/src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java
+++ b/src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java
@@ -1536,6 +1536,7 @@ public class SlimefunSetup {
@Override
public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List drops) {
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.AUTO_SMELT_PICKAXE, true)) {
+ if (BlockStorage.hasBlockInfo(e.getBlock())) return true;
if (e.getBlock().getType().equals(Material.PLAYER_HEAD)) return true;
int j = -1;
@@ -1838,17 +1839,18 @@ public class SlimefunSetup {
@Override
public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List drops) {
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.PICKAXE_OF_CONTAINMENT, true)) {
- if (e.getBlock().getType() != Material.SPAWNER) return true;
- BlockStorage.clearBlockInfo(e.getBlock());
+ Block b = e.getBlock(); // Refactored it into this so we don't need to call e.getBlock() all the time.
+ if (b.getType() != Material.SPAWNER || BlockStorage.hasBlockInfo(b)) return true;
+ // If the spawner's BlockStorage has BlockInfo, then it's not a vanilla spawner and shouldn't give a broken spawner.
ItemStack spawner = SlimefunItems.BROKEN_SPAWNER.clone();
ItemMeta im = spawner.getItemMeta();
List lore = im.getLore();
for (int i = 0; i < lore.size(); i++) {
- if (lore.get(i).contains("")) lore.set(i, lore.get(i).replace("", StringUtils.format(((CreatureSpawner) e.getBlock().getState()).getSpawnedType().toString())));
+ if (lore.get(i).contains("")) lore.set(i, lore.get(i).replace("", StringUtils.format(((CreatureSpawner) b.getState()).getSpawnedType().toString())));
}
im.setLore(lore);
spawner.setItemMeta(im);
- e.getBlock().getLocation().getWorld().dropItemNaturally(e.getBlock().getLocation(), spawner);
+ b.getLocation().getWorld().dropItemNaturally(b.getLocation(), spawner);
e.setExpToDrop(0);
return true;
}
@@ -2179,7 +2181,7 @@ public class SlimefunSetup {
for (int y = -1; y <= 1; y++) {
for (int z = -1; z <= 1; z++) {
Block b = e.getBlock().getRelative(x, y, z);
- if (b.getType() != Material.AIR && !StringUtils.equals(b.getType().toString(), explosiveblacklist)) {
+ if (b.getType() != Material.AIR && !b.isLiquid() && !StringUtils.equals(b.getType().toString(), explosiveblacklist)) {
if (CSCoreLib.getLib().getProtectionManager().canBuild(e.getPlayer().getUniqueId(), b)) {
if (SlimefunStartup.instance.isCoreProtectInstalled()) SlimefunStartup.instance.getCoreProtectAPI().logRemoval(e.getPlayer().getName(), b.getLocation(), b.getType(), b.getBlockData());
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
diff --git a/src/me/mrCookieSlime/Slimefun/listeners/DamageListener.java b/src/me/mrCookieSlime/Slimefun/listeners/DamageListener.java
index aa0506988..04b6fc752 100644
--- a/src/me/mrCookieSlime/Slimefun/listeners/DamageListener.java
+++ b/src/me/mrCookieSlime/Slimefun/listeners/DamageListener.java
@@ -2,12 +2,15 @@ package me.mrCookieSlime.Slimefun.listeners;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
+import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
+import org.bukkit.entity.ChestedHorse;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
@@ -105,13 +108,21 @@ public class DamageListener implements Listener {
}
if (!e.getEntity().getCanPickupItems() && Talisman.checkFor(e, SlimefunItem.getByID("HUNTER_TALISMAN")) && !(e.getEntity() instanceof Player)) {
+
List newDrops = new ArrayList();
for (ItemStack drop : e.getDrops()) {
- newDrops.add(drop);
+ newDrops.add(drop);
}
for (ItemStack drop : newDrops) {
e.getDrops().add(drop);
}
+
+ if(e.getEntity() instanceof ChestedHorse) {
+ for(ItemStack invItem : ((ChestedHorse) e.getEntity()).getInventory().getStorageContents()) {
+ e.getDrops().remove(invItem);
+ }
+ e.getDrops().remove(new ItemStack(Material.CHEST)); //The chest is not included in getStorageContents()
+ }
}
}
}