is there a way to make the chests face a certain direction in the following? Code:java loc.getBlock().getRelative(4, 1, -2).setType(Material.CHEST); loc.getBlock().getRelative(4, 1, 2).setType(Material.CHEST); loc.getBlock().getRelative(-4, 1, -2).setType(Material.CHEST); loc.getBlock().getRelative(-4, 1, 2).setType(Material.CHEST); loc.getBlock().getRelative(2, 1, -4).setType(Material.CHEST); loc.getBlock().getRelative(2, 1, 4).setType(Material.CHEST); loc.getBlock().getRelative(-2, 1, -4).setType(Material.CHEST); loc.getBlock().getRelative(-2, 1, 4).setType(Material.CHEST); loc.getBlock().getRelative(0, 1, -4).setType(Material.CHEST); loc.getBlock().getRelative(0, 1, 4).setType(Material.CHEST); loc.getBlock().getRelative(4, 1, 0).setType(Material.CHEST); loc.getBlock().getRelative(-4, 1, 0).setType(Material.CHEST);
RebzO1 He means to create a BlockState that affects the chest and edit its direction using the setDirection() method.
SourceForums I understand what he was telling me i need to do, i also understand the setDirection but creating a blockstate i dont have a clue i looked at jd.bukkit.org but i am still clueless
RebzO1 Have a look at these: http://jd.bukkit.org/rb/apidocs/org/bukkit/block/BlockState.html http://jd.bukkit.org/rb/apidocs/org/bukkit/block/Block.html
SourceForums xTrollxDudex k ill have a look at those in a bit gotta go do that work thing hopefully ill get it working.
RebzO1 Judging from what I briefly read, I think you can use the following code to do what you're aiming to do: Code:java Block block = etc.BlockState state = (BlockState) block.getState();state.setDirection() //Direction Haven't tested though.
SourceForums Ye, i saw something like that but where do i put it, in relation to what i have. sorry if it seems like a noob question. bleh nvm read through those pages and still have no clue i feel like a dumb ass now EDIT by Moderator: merged posts, please use the edit button instead of double posting.
RebzO1 Well, you define the block (chest) and the blockstate at the start, then modify it. I'm not really sure what you're trying to ask here:
SourceForums the code in the original post spawns my 12 chests all facing south and i need 3 facing in each direction my problem is that i don't know how to modify my code so it does it sorry i seem to be pretty bad at explaining myself
RebzO1 Could you please provide your current code? I'll give you an example with it. P.S. And no, it's not that you're bad at explaining - I'm just bad at understanding.
SourceForums Code:java /*** CardinalCraft Diamond Dash By RebzO1*/package me.rebz.diamonddash; import net.minecraft.server.v1_7_R1.Block; import org.bukkit.Bukkit;import org.bukkit.ChatColor;import org.bukkit.Material;import org.bukkit.Sound;import org.bukkit.block.BlockFace;import org.bukkit.block.Chest;import org.bukkit.block.Sign;import org.bukkit.command.Command;import org.bukkit.command.CommandSender;import org.bukkit.Location;import org.bukkit.enchantments.Enchantment;import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.block.Action;import org.bukkit.event.entity.EntityDeathEvent;import org.bukkit.event.player.PlayerInteractEvent;import org.bukkit.inventory.Inventory;import org.bukkit.inventory.ItemStack;import org.bukkit.material.MaterialData;import org.bukkit.plugin.java.JavaPlugin; import java.util.logging.Logger; public class Main extends JavaPlugin implements Listener{public final Logger logger = Logger.getLogger("Minecraft");public int number = 5;public int time = 1805; public void onEnable() {Bukkit.getServer().getPluginManager().registerEvents(this, this);getLogger().info("CC-Diamond Dash Enabled!");}public void onDisable() {getLogger().info("CC-Diamond Dash Disabled!");}@EventHandlerpublic void onDeath(EntityDeathEvent e){if (e.getEntity() instanceof Player){for (Player online : getServer().getOnlinePlayers()) {online.playSound(online.getLocation(), Sound.WOLF_HOWL, 1, 2);}}} @SuppressWarnings("deprecation")public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel, String[] args){Player p = (Player) sender; if (CommandLabel.equalsIgnoreCase("kit")){if(args.length == 0){ItemStack pick = new ItemStack(Material.DIAMOND_PICKAXE, 1);pick.addEnchantment(Enchantment.SILK_TOUCH, 1);pick.addEnchantment(Enchantment.DIG_SPEED, 4);pick.addEnchantment(Enchantment.DURABILITY, 3);p.getInventory().addItem(pick);ItemStack[] items = {new ItemStack(Material.DIAMOND_SWORD),new ItemStack(Material.STONE_SPADE),new ItemStack(Material.GOLDEN_CARROT, 64),new ItemStack(Material.LOG, 64),new ItemStack(Material.DIAMOND_HELMET),new ItemStack(Material.DIAMOND_CHESTPLATE),new ItemStack(Material.DIAMOND_LEGGINGS),new ItemStack(Material.DIAMOND_BOOTS),new ItemStack(Material.SIGN)};p.getInventory().addItem(items);p.sendMessage(ChatColor.AQUA + "You are now ready to start!");return true;}}/* if (cmd.getName().equalsIgnoreCase("build")) {if (args.length == 4 && sender instanceof Player) {Player player = (Player) sender;int ylevel = Integer.parseInt(args[0]);int xradius = Integer.parseInt(args[1]);int zradius = Integer.parseInt(args[2]);int yhight = Integer.parseInt(args[3]); //changed this to make it easier Location center = new Location(player.getWorld(), player.getLocation().getX(), ylevel, player.getLocation().getZ()); for (int y = 0; y <= yhight; y++){for (int x = -xradius; x <= xradius; x++ ){for (int z = -zradius; z <= zradius; z++) {if (y == 0) center.getBlock().getRelative(x, y, z).setType(Material.WOOD);else if (y == yhight) center.getBlock().getRelative(x, y, z).setType(Material.GLOWSTONE);else if (Math.abs(x) == xradius || Math.abs(z) == zradius) center.getBlock().getRelative(x,y,z).setType(Material.WOOD);else center.getBlock().getRelative(x,y,z).setType(Material.AIR);}}}}}*/if (cmd.getName().equalsIgnoreCase("build")) {if(args.length == 0){p.getWorld().setSpawnLocation(p.getLocation().getBlockX(),p.getLocation().getBlockY(),p.getLocation().getBlockZ()); Location loc = p.getLocation();loc .setY(11); // basefor (int x = -8; x < 9; ++x) {loc.getBlock().getRelative(x, 0, -8).setType(Material.HARD_CLAY);for (int z = -8; z < 9; ++z) {loc.getBlock().getRelative(x, 0, z).setType(Material.HARD_CLAY);}}//wallsfor (int x = -8; x < 9; ++x) {loc.getBlock().getRelative(x, 1, -8).setType(Material.SMOOTH_BRICK);for (int z = -8; z < 9; ++z) {loc.getBlock().getRelative(x, 1, z).setType(Material.SMOOTH_BRICK); }}for (int x = -8; x < 9; ++x) {loc.getBlock().getRelative(x, 2, -8).setType(Material.SMOOTH_BRICK);for (int z = -8; z < 9; ++z) {loc.getBlock().getRelative(x, 2, z).setType(Material.SMOOTH_BRICK); }}for (int x = -8; x < 9; ++x) {loc.getBlock().getRelative(x, 3, -8).setType(Material.SMOOTH_BRICK);for (int z = -8; z < 9; ++z) {loc.getBlock().getRelative(x, 3, z).setType(Material.SMOOTH_BRICK); }}for (int x = -8; x < 9; ++x) {loc.getBlock().getRelative(x, 4, -8).setType(Material.SMOOTH_BRICK);for (int z = -8; z < 9; ++z) {loc.getBlock().getRelative(x, 4, z).setType(Material.SMOOTH_BRICK); }}for (int x = -8; x < 9; ++x) {loc.getBlock().getRelative(x, 5, -8).setType(Material.SMOOTH_BRICK);for (int z = -8; z < 9; ++z) {loc.getBlock().getRelative(x, 5, z).setType(Material.SMOOTH_BRICK);}}// AIRfor (int x = -7; x < 8; ++x) {loc.getBlock().getRelative(x, 1, -7).setType(Material.AIR);for (int z = -7; z < 8; ++z) {loc.getBlock().getRelative(x, 1, z).setType(Material.AIR);}}for (int x = -7; x < 8; ++x) {loc.getBlock().getRelative(x, 2, -7).setType(Material.AIR);for (int z = -7; z < 8; ++z) {loc.getBlock().getRelative(x, 2, z).setType(Material.AIR);}}for (int x = -7; x < 8; ++x) {loc.getBlock().getRelative(x, 3, -7).setType(Material.AIR);for (int z = -7; z < 8; ++z) {loc.getBlock().getRelative(x, 3, z).setType(Material.AIR);}}for (int x = -7; x < 8; ++x) {loc.getBlock().getRelative(x, 4, -7).setType(Material.AIR);for (int z = -7; z < 8; ++z) {loc.getBlock().getRelative(x, 4, z).setType(Material.AIR);}}loc.getBlock().getRelative(4, 1, -2).setType(Material.CHEST);loc.getBlock().getRelative(4, 1, 2).setType(Material.CHEST);loc.getBlock().getRelative(-4, 1, -2).setType(Material.CHEST);loc.getBlock().getRelative(-4, 1, 2).setType(Material.CHEST);loc.getBlock().getRelative(2, 1, -4).setType(Material.CHEST);loc.getBlock().getRelative(2, 1, 4).setType(Material.CHEST);loc.getBlock().getRelative(-2, 1, -4).setType(Material.CHEST);loc.getBlock().getRelative(-2, 1, 4).setType(Material.CHEST);loc.getBlock().getRelative(0, 1, -4).setType(Material.CHEST);loc.getBlock().getRelative(0, 1, 4).setType(Material.CHEST);loc.getBlock().getRelative(4, 1, 0).setType(Material.CHEST);loc.getBlock().getRelative(-4, 1, 0).setType(Material.CHEST);// loc.getBlock().getRelative(-4, 1, -4).setType(Material.CHEST);// loc.getBlock().getRelative(4, 1, 4).setType(Material.CHEST);// loc.getBlock().getRelative(4, 1, -4).setType(Material.CHEST);// loc.getBlock().getRelative(-4, 1, 4).setType(Material.CHEST); loc.getBlock().getRelative(0, 5, 0).setType(Material.GLOWSTONE);loc.getBlock().getRelative(-4, 5, -4).setType(Material.GLOWSTONE);loc.getBlock().getRelative(-4, 5, 4).setType(Material.GLOWSTONE);loc.getBlock().getRelative(4, 5, -4).setType(Material.GLOWSTONE);loc.getBlock().getRelative(4, 5, 4).setType(Material.GLOWSTONE); p.teleport(loc.add(0, 1, 0));p.getWorld().setSpawnLocation(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); Bukkit.dispatchCommand(Bukkit.getConsoleSender(),"say Start Room Built.");return true;}}if (CommandLabel.equalsIgnoreCase("spawn")){if (!sender.hasPermission("dd.spawn")) {return false;}if(args.length == 0){p.teleport(p.getWorld().getSpawnLocation());p.sendMessage(ChatColor.GOLD + "Teleporting to spawn..." );}return true;} if (CommandLabel.equalsIgnoreCase("diamonds") && sender instanceof Player){if(args.length == 0){p.sendMessage(ChatColor.GRAY + "------------------------------" );p.sendMessage(ChatColor.AQUA + "You have 30 minutes to...");p.sendMessage(ChatColor.AQUA + "Find as many " + ChatColor.GOLD + "DIAMONDS " + ChatColor.AQUA + "as you can! ");p.sendMessage(ChatColor.AQUA + "No PVP & if you die you are out!");p.sendMessage(ChatColor.AQUA + "Winner takes everyones loot!");p.sendMessage(ChatColor.GRAY + "------------------------------" );return true;}}if (CommandLabel.equalsIgnoreCase("ores") && sender instanceof Player){if(args.length == 0){p.sendMessage(ChatColor.GRAY + "-----------------------------------" );p.sendMessage(ChatColor.AQUA + "You have 30 minutes to...");p.sendMessage(ChatColor.AQUA + "Find as many " + ChatColor.GOLD + "ORES " + ChatColor.AQUA + "as you can! ");p.sendMessage(ChatColor.AQUA + "1 Point for each" + ChatColor.GOLD + " Iron ore " + ChatColor.AQUA + " you find.");p.sendMessage(ChatColor.AQUA + "3 Points for each" + ChatColor.GOLD + " Gold ore " + ChatColor.AQUA + " you find.");p.sendMessage(ChatColor.AQUA + "5 Points for each" + ChatColor.GOLD + " Diamond ore " + ChatColor.AQUA + " you find.");p.sendMessage(ChatColor.AQUA + "5 Points for each" + ChatColor.GOLD + " Emerald ore " + ChatColor.AQUA + " you find.");p.sendMessage(ChatColor.AQUA + "No PVP & if you die you are out!");p.sendMessage(ChatColor.AQUA + "Winner takes everyones loot!");p.sendMessage(ChatColor.GRAY + "-----------------------------------" );return true;}}// Start Timers// This focuses on the start countdown and game countdown also the /time commandif (CommandLabel.equalsIgnoreCase("start") && sender instanceof Player){this.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable(){public void run(){if(number != -1){if(number != 0){Bukkit.broadcastMessage(ChatColor.AQUA + "" + number);number--;}else{Bukkit.broadcastMessage(ChatColor.AQUA + "Go! Go! Go!");number--;}}}}, 0L, 20L); this.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable(){public void run(){if(time != -1){if(time != 0){time--;}else{Bukkit.broadcastMessage(ChatColor.AQUA + "Times Up!");for(Player pl : Bukkit.getOnlinePlayers()) {pl.teleport(pl.getWorld().getSpawnLocation());}time--;}}}}, 0L, 20L);return true;} if (CommandLabel.equalsIgnoreCase("time") && sender instanceof Player){if(args.length == 0){int minutes = time / 60;int seconds = time % 60;p.sendMessage(ChatColor.AQUA + "Time left: " + ChatColor.GRAY + minutes + ChatColor.AQUA + " minutes" + ChatColor.AQUA + " and " + ChatColor.GRAY + seconds + ChatColor.AQUA + " seconds.");return true;}}return false;} . SourceForums made a couple of changes EDIT by Moderator: merged posts, please use the edit button instead of double posting.
RebzO1 Please provide your new code. EDIT: Could you please post only the relevant parts this time please?
SourceForums Code:java loc.getBlock().getRelative(4, 1, -2).setType(Material.CHEST);loc.getBlock().getRelative(4, 1, 2).setType(Material.CHEST);loc.getBlock().getRelative(-4, 1, -2).setType(Material.CHEST);loc.getBlock().getRelative(-4, 1, 2).setType(Material.CHEST);loc.getBlock().getRelative(2, 1, -4).setType(Material.CHEST);loc.getBlock().getRelative(2, 1, 4).setType(Material.CHEST);loc.getBlock().getRelative(-2, 1, -4).setType(Material.CHEST);loc.getBlock().getRelative(-2, 1, 4).setType(Material.CHEST);loc.getBlock().getRelative(0, 1, -4).setType(Material.CHEST);loc.getBlock().getRelative(0, 1, 4).setType(Material.CHEST);loc.getBlock().getRelative(4, 1, 0).setType(Material.CHEST);loc.getBlock().getRelative(-4, 1, 0).setType(Material.CHEST); this part didn't change these are the chests that spawn 12 in a square i just need 3 pointing in each direction N, E, S & W. SourceForums If you need more of the code ill get that posted too EDIT by Moderator: merged posts, please use the edit button instead of double posting.
RebzO1 This should solve your problem once and for all: https://forums.bukkit.org/threads/change-the-direction-of-a-sign.31582/