Package com.tommytony.war.utility

Examples of com.tommytony.war.utility.DeferredBlockReset


                      String[] lines = linesStr.split(";;");

                      // Signs set
                      if (diskBlockType == Material.WALL_SIGN.getId() && ((diskBlockData & 0x04) == 0x04) && i + 1 != volume.getSizeX()) {
                        // A sign post hanging on a wall south of here needs that block to be set first
                        deferred.add(new DeferredBlockReset(x, y, z, diskBlockType, diskBlockData, lines));
                      } else {
                        worldBlock.setType(Material.getMaterial(diskBlockType));
                        BlockState state = worldBlock.getState();
                        state.setData(new org.bukkit.material.Sign(diskBlockType, diskBlockData));
                        if (state instanceof Sign) {
                          Sign sign = (Sign) state;
                          if (lines != null && sign.getLines() != null) {
                            if (lines.length > 0) {
                              sign.setLine(0, lines[0]);
                            }
                            if (lines.length > 1) {
                              sign.setLine(1, lines[1]);
                            }
                            if (lines.length > 2) {
                              sign.setLine(2, lines[2]);
                            }
                            if (lines.length > 3) {
                              sign.setLine(3, lines[3]);
                            }
                            sign.update(true);
                          }
                        }
                      }
                    } else if (diskBlockType == Material.CHEST.getId()) {
                      // Chests read
                      List<ItemStack> items = VolumeMapper.readInventoryString(invsReader.readLine());

                      // Chests set
                      worldBlock.setType(Material.getMaterial(diskBlockType));
                      worldBlock.setData(diskBlockData);
                      BlockState state = worldBlock.getState();
                      if (state instanceof Chest) {
                        Chest chest = (Chest) state;
                        if (items != null) {
                          int ii = 0;
                          chest.getInventory().clear();
                          for (ItemStack item : items) {
                            if (item != null) {
                              chest.getInventory().setItem(ii, item);
                              ii++;
                            }
                          }
                          chest.update(true);
                        }
                      }
                    } else if (diskBlockType == Material.DISPENSER.getId()) {
                      // Dispensers read
                      List<ItemStack> items = VolumeMapper.readInventoryString(invsReader.readLine());

                      // Dispensers set
                      worldBlock.setType(Material.getMaterial(diskBlockType));
                      worldBlock.setData(diskBlockData);
                      BlockState state = worldBlock.getState();
                      if (state instanceof Dispenser) {
                        Dispenser dispenser = (Dispenser) state;
                        if (items != null) {
                          int ii = 0;
                          dispenser.getInventory().clear();
                          for (ItemStack item : items) {
                            if (item != null) {
                              dispenser.getInventory().setItem(ii, item);
                              ii++;
                            }
                          }
                          dispenser.update(true);
                        }
                      }
                    } else if (diskBlockType == Material.WOODEN_DOOR.getId() || diskBlockType == Material.IRON_DOOR_BLOCK.getId()) {
                      // Door blocks
                      deferred.add(new DeferredBlockReset(x, y, z, diskBlockType, diskBlockData));
                    } else if (((diskBlockType == Material.TORCH.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.REDSTONE_TORCH_OFF.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.REDSTONE_TORCH_ON.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.LEVER.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.STONE_BUTTON.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.LADDER.getId() && ((diskBlockData & 0x04) == 0x04)) || (diskBlockType == Material.RAILS.getId() && ((diskBlockData & 0x02) == 0x02))) && i + 1 != volume.getSizeX()) {
                      // Blocks that hang on a block south of themselves need to make sure that block is there before placing themselves... lol
                      // Change the block itself later on:
                      deferred.add(new DeferredBlockReset(x, y, z, diskBlockType, diskBlockData));
                    } else {
                      // regular block
                      if (diskBlockType >= 0) {
                        worldBlock.setType(Material.getMaterial(diskBlockType));
                        worldBlock.setData(diskBlockData);
View Full Code Here


                            String[] lines = linesStr.split(";;");

                            // Signs set
                            // A sign post hanging on a wall south of here will
                            if (diskBlockType == Material.SIGN_POST.getId() && ((diskBlockData & 0x04) == 0x04) && i + 1 != volume.getSizeX()) {
                              deferred.add(new DeferredBlockReset(x, y, z, diskBlockType, diskBlockData, lines));
                            } else {
                              worldBlock.setType(Material.getMaterial(diskBlockType));
                              BlockState state = worldBlock.getState();
                              state.setData(new org.bukkit.material.Sign(diskBlockType, diskBlockData));
                              if (state instanceof Sign) {
                                Sign sign = (Sign) state;
                                if (lines != null && sign.getLines() != null) {
                                  if (lines.length > 0) {
                                    sign.setLine(0, lines[0]);
                                  }
                                  if (lines.length > 1) {
                                    sign.setLine(1, lines[1]);
                                  }
                                  if (lines.length > 2) {
                                    sign.setLine(2, lines[2]);
                                  }
                                  if (lines.length > 3) {
                                    sign.setLine(3, lines[3]);
                                  }
                                  sign.update(true);
                                }
                              }
                            }
                          }
                        } else if (diskBlockType == Material.CHEST.getId()) {
                          // Chests read
                          List<ItemStack> items = null;
                          if (blockSplit.length > 2) {
                            String itemsStr = blockSplit[2];
                            items = PreDeGaulleZoneVolumeMapper.readInventoryString(itemsStr);
                          }

                          // Chests set
                          worldBlock.setType(Material.getMaterial(diskBlockType));
                          worldBlock.setData(diskBlockData);
                          BlockState state = worldBlock.getState();
                          if (state instanceof Chest) {
                            Chest chest = (Chest) state;
                            if (items != null) {
                              int ii = 0;
                              chest.getInventory().clear();
                              for (ItemStack item : items) {
                                if (item != null) {
                                  chest.getInventory().setItem(ii, item);
                                  ii++;
                                }
                              }
                              chest.update(true);
                            }
                          }
                        } else if (diskBlockType == Material.DISPENSER.getId()) {
                          // Dispensers read
                          List<ItemStack> items = null;
                          if (blockSplit.length > 2) {
                            String itemsStr = blockSplit[2];
                            // String itemsStr = lineScanner.nextLine();
                            items = PreDeGaulleZoneVolumeMapper.readInventoryString(itemsStr);
                          }

                          // Dispensers set
                          worldBlock.setType(Material.getMaterial(diskBlockType));
                          worldBlock.setData(diskBlockData);
                          BlockState state = worldBlock.getState();
                          if (state instanceof Dispenser) {
                            Dispenser dispenser = (Dispenser) state;
                            if (items != null) {
                              int ii = 0;
                              dispenser.getInventory().clear();
                              for (ItemStack item : items) {
                                if (item != null) {
                                  dispenser.getInventory().setItem(ii, item);
                                  ii++;
                                }
                              }
                              dispenser.update(true);
                            }
                          }
                        } else if (diskBlockType == Material.WOODEN_DOOR.getId() || diskBlockType == Material.IRON_DOOR_BLOCK.getId()) {
                          // Door blocks

                          if (j - 1 > 0) {
                            Block blockBelow = world.getBlockAt(x, y - 1, z);
                            boolean belowIsGlass = blockBelow.getTypeId() == Material.GLASS.getId();
                            // Set current block to glass if block below isn't glass.
                            // Having a glass block below means the current block is a door top.
                            if (belowIsGlass) {
                              // Top door block. Set both it and the block below as door.
                              blockBelow.setType(Material.getMaterial(diskBlockType));
                              blockBelow.setData(diskBlockData);
                              worldBlock.setType(Material.getMaterial(diskBlockType));
                              worldBlock.setData(diskBlockData);
                            } else {
                              worldBlock.setType(Material.GLASS);
                            }
                          }

                        } else if (((diskBlockType == Material.TORCH.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.REDSTONE_TORCH_OFF.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.REDSTONE_TORCH_ON.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.LEVER.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.STONE_BUTTON.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.LADDER.getId() && ((diskBlockData & 0x04) == 0x04)) || (diskBlockType == Material.RAILS.getId() && ((diskBlockData & 0x02) == 0x02))) && i + 1 != volume.getSizeX()) {
                          // Blocks that hang on a block south of themselves need to make sure that block is there before placing themselves... lol
                          // Change the block itself later on:
                          deferred.add(new DeferredBlockReset(x, y, z, diskBlockType, diskBlockData));
                        } else {
                          // regular block
                          worldBlock.setType(Material.getMaterial(diskBlockType));
                          worldBlock.setData(diskBlockData);
                        }
View Full Code Here

TOP

Related Classes of com.tommytony.war.utility.DeferredBlockReset

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.