diff --git a/src/me/mrCookieSlime/Slimefun/AncientAltar/RitualAnimation.java b/src/me/mrCookieSlime/Slimefun/AncientAltar/RitualAnimation.java index 112e9e177..56803e9ab 100644 --- a/src/me/mrCookieSlime/Slimefun/AncientAltar/RitualAnimation.java +++ b/src/me/mrCookieSlime/Slimefun/AncientAltar/RitualAnimation.java @@ -1,13 +1,19 @@ package me.mrCookieSlime.Slimefun.AncientAltar; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import me.mrCookieSlime.Slimefun.SlimefunStartup; import me.mrCookieSlime.Slimefun.listeners.AncientAltarListener; import me.mrCookieSlime.Slimefun.Variables; -import org.bukkit.*; +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Particle; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.entity.Item; import org.bukkit.inventory.ItemStack; @@ -23,6 +29,7 @@ public class RitualAnimation implements Runnable { List items; List particles; + Map itemLock = new HashMap<>(); boolean running; int stage; @@ -38,11 +45,19 @@ public class RitualAnimation implements Runnable { this.running = true; this.stage = 0; + for(Block ped:this.pedestals) { + Item itm = AncientAltarListener.findItem(ped); + this.itemLock.put(itm, itm.getLocation().clone()); + } } @Override public void run() { idle(); + if(!checkLockedItems()) { + abort(); + return; + } if(this.stage == 36) { finish(); return; @@ -54,6 +69,15 @@ public class RitualAnimation implements Runnable { SlimefunStartup.instance.getServer().getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, this, 8); } + private boolean checkLockedItems() { + + for(Item itm:this.itemLock.keySet()) + if(itm.getLocation().distance(this.itemLock.get(itm)) > 0.3) + return false; + + return true; + } + private void idle() { try { l.getWorld().spawnParticle(Particle.SPELL_WITCH, l,16, 1.2F, 0F, 1.2F); @@ -69,7 +93,12 @@ public class RitualAnimation implements Runnable { private void checkPedestal(Block pedestal) { Item item = AncientAltarListener.findItem(pedestal); - if (item == null) abort(); + + + if(item == null || itemLock.remove(item) == null) { + abort(); + } + else { particles.add(pedestal.getLocation().add(0.5, 1.5, 0.5)); items.add(AncientAltarListener.fixItemStack(item.getItemStack(), item.getCustomName())); @@ -81,8 +110,10 @@ public class RitualAnimation implements Runnable { } catch (Exception e) { e.printStackTrace(); } - + + itemLock.remove(item); item.remove(); + pedestal.removeMetadata("item_placed", SlimefunStartup.instance); } } @@ -96,6 +127,7 @@ public class RitualAnimation implements Runnable { Variables.altarinuse.remove(altar.getLocation()); // should re-enable altar blocks on craft failure. l.getWorld().playSound(l, Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 5F, 1F); + itemLock.clear(); altars.remove(altar); } @@ -115,4 +147,4 @@ public class RitualAnimation implements Runnable { l.getWorld().playSound(l, Sound.ENTITY_ZOMBIE_BREAK_WOODEN_DOOR, 1F, 1F); } } -} \ No newline at end of file +} diff --git a/src/me/mrCookieSlime/Slimefun/Lists/SlimefunItems.java b/src/me/mrCookieSlime/Slimefun/Lists/SlimefunItems.java index a46a99102..6427ccd68 100644 --- a/src/me/mrCookieSlime/Slimefun/Lists/SlimefunItems.java +++ b/src/me/mrCookieSlime/Slimefun/Lists/SlimefunItems.java @@ -367,7 +367,8 @@ public class SlimefunItems { public static ItemStack PRESSURE_CHAMBER = new CustomItem(Material.GLASS, "&bPressure Chamber", "", "&a&oCompresses Items even more"); public static ItemStack MAGIC_WORKBENCH = new CustomItem(Material.CRAFTING_TABLE, "&6Magic Workbench", "Infuses Items with magical Energy"); public static ItemStack ORE_WASHER = new CustomItem(Material.CAULDRON, "&6Ore Washer", "", "&a&oWashes Sifted Ore to filter Ores", "&a&oand gives you small Stone Chunks"); - public static ItemStack SAW_MILL = new CustomItem(Material.IRON_BARS, "&6Saw Mill", "", "&a&oAllows you to get 8 planks from 1 Log"); + public static ItemStack TABLE_SAW = new CustomItem(Material.STONECUTTER, "&6Table Saw", "", "&a&oAllows you get 8 planks from 1 Log", "&a&o(Works with all log types)"); + public static ItemStack SAW_MILL = new CustomItem(Material.BARRIER, "&6Saw Mill", "", "&cObsolete! Use the Table Saw instead"); public static ItemStack COMPOSTER = new CustomItem(Material.CAULDRON, "&aComposter", "", "&a&oCan convert various Materials over Time..."); public static ItemStack ENHANCED_CRAFTING_TABLE = new CustomItem(Material.CRAFTING_TABLE, "&eEnhanced Crafting Table", "", "&a&oA regular Crafting Table cannot", "&a&ohold this massive Amount of Power..."); public static ItemStack CRUCIBLE = new CustomItem(Material.CAULDRON, "&cCrucible", "", "&a&oUsed to smelt Items into Liquids"); diff --git a/src/me/mrCookieSlime/Slimefun/Setup/ResearchSetup.java b/src/me/mrCookieSlime/Slimefun/Setup/ResearchSetup.java index e50d57eec..97371241c 100644 --- a/src/me/mrCookieSlime/Slimefun/Setup/ResearchSetup.java +++ b/src/me/mrCookieSlime/Slimefun/Setup/ResearchSetup.java @@ -94,7 +94,7 @@ public class ResearchSetup { Slimefun.registerResearch(new Research(89, "Night Vision Goggles", 10), SlimefunItems.NIGHT_VISION_GOGGLES); Slimefun.registerResearch(new Research(90, "Pickaxe of Containment", 14), SlimefunItems.PICKAXE_OF_CONTAINMENT, SlimefunItems.BROKEN_SPAWNER); Slimefun.registerResearch(new Research(91, "Hercules Pickaxe", 28), SlimefunItems.HERCULES_PICKAXE); - Slimefun.registerResearch(new Research(92, "Saw Mill", 2), SlimefunItems.SAW_MILL); + Slimefun.registerResearch(new Research(92, "Table Saw", 2), SlimefunItems.SAW_MILL, SlimefunItems.TABLE_SAW); Slimefun.registerResearch(new Research(93, "Slimy Steel Armor", 27), SlimefunItems.SLIME_HELMET_STEEL, SlimefunItems.SLIME_CHESTPLATE_STEEL, SlimefunItems.SLIME_LEGGINGS_STEEL, SlimefunItems.SLIME_BOOTS_STEEL); Slimefun.registerResearch(new Research(94, "Blade of Vampires", 26), SlimefunItems.BLADE_OF_VAMPIRES); Slimefun.registerResearch(new Research(95, "Lazy Mining", 40), SlimefunItems.DIGITAL_MINER); diff --git a/src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java b/src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java index bd5cc68bf..563aeb73b 100644 --- a/src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java +++ b/src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java @@ -1875,7 +1875,45 @@ public class SlimefunSetup { else return false; } }); + + new SlimefunMachine(Categories.MACHINES_1, SlimefunItems.TABLE_SAW, "TABLE_SAW", + new ItemStack[] {null, null, null, new ItemStack(Material.STONE_SLAB), new ItemStack(Material.STONECUTTER), new ItemStack(Material.STONE_SLAB), null, new ItemStack(Material.IRON_BLOCK), null}, + new ItemStack[] {}, Material.STONECUTTER) + .register(true, new MultiBlockInteractionHandler() { + @Override + public boolean onInteract(Player p, MultiBlock mb, Block b) { + if (mb.isMultiBlock(SlimefunItem.getByID("TABLE_SAW"))) { + if (CSCoreLib.getLib().getProtectionManager().canBuild(p.getUniqueId(), b.getRelative(BlockFace.UP), true)) { + if (Slimefun.hasUnlocked(p, SlimefunItems.TABLE_SAW, true)) { + if(p.getInventory().getItemInMainHand() != null && Tag.LOGS.getValues().contains(p.getInventory().getItemInMainHand().getType())) { + ItemStack log = p.getInventory().getItemInMainHand(); + + ItemStack item = new ItemStack(MaterialHelper.getWoodFromLog(log.getType()), 8); + b.getWorld().dropItemNaturally(b.getLocation(), item); + b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, log.getType()); + log.setAmount(log.getAmount() -1); + if(log.getAmount() <= 0) + p.getInventory().setItemInMainHand(new ItemStack(Material.AIR)); + + + } + } + } + return true; + } + else return false; + } + }); + + /* + * dNiym 7/30/2019 added the Table_Saw machine to replace the Saw_mill, as the sawmill's design does not work with + * the new types of log's in minecraft. Now that there are multiple types with their own object ID the existing + * way of detecting multi blocks limits us to using specific material types in a build, therefore having a block that + * needs to change like for the sawmill is not possible to do without major overhauling of multiblocks. The Saw_Mill + * machine has been left in as to not break machines on existing servers however it should no longer show up in the + * slimefun guide. + */ new SlimefunMachine(Categories.MACHINES_1, SlimefunItems.SAW_MILL, "SAW_MILL", new ItemStack[] {null, null, null, new ItemStack(Material.IRON_BARS), new ItemStack(Material.OAK_LOG), new ItemStack(Material.IRON_BARS), new ItemStack(Material.OAK_LOG), new ItemStack(Material.CRAFTING_TABLE), new ItemStack(Material.OAK_LOG)}, new ItemStack[] {}, Material.CRAFTING_TABLE)