are these warnings dangerous?

Discussion in 'Plugin Development' started by xize, Jun 4, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    xize

    Hello,

    so i've made a way to build a schematic through a scheduler where a mob with a name tag teleports everytime.

    my question is since my console shows these typical errors:

    Code:
    [19:10:36] [Server thread/WARN]: Wrong location for EntityEnderman['§6[ManCo]§fbuilder!'/6143, l='MineInTheBox', x=-12475,00, y=83,00, z=-6792,00] in world 'MineInTheBox'!
    [19:10:36] [Server thread/WARN]: Entity is at -12475.0,-6792.0 (chunk -780,-425) but was stored in chunk -779,-425
    
    does this mean that this is very dangerous?
    I'm 100% sure I'm loading a chunk before the enderman teleports so whats this error all about?

    my code is:

    Code:java
    1.  
    2. public class SchematicBuilder {
    3. private final Schematic schematic;
    4. private final Location loc;
    5. private final String player;
    6. private HashMap<Block, Integer> data = new HashMap<Block, Integer>();
    7. public SchematicBuilder(Schematic schematic, Location base, String player) {
    8. this.schematic = schematic;
    9. this.loc = base;
    10. this.player = player;
    11. }
    12. /**
    13.   * @author xize
    14.   * @param returns the schematic
    15.   * @return Schematic
    16.   */
    17. public Schematic getSchematic() {
    18. return schematic;
    19. }
    20. /**
    21.   * @author xize
    22.   * @param slowly generates the schematic from bottom to highest.
    23.   */
    24. public void startGeneration(final EntityType type) {
    25. new BukkitRunnable() {
    26. private Iterator<Block> it;
    27. private LivingEntity entity;
    28. public void setData() {
    29. for(int x = 0; x < schematic.getWidth(); x++){
    30. for (int y = 0; y < schematic.getHeight(); y++){
    31. for (int z = 0; z < schematic.getLength(); ++z){
    32. Location temp = loc.clone().add(x, y, z);
    33. Block block = temp.getBlock();
    34. int index = y * schematic.getWidth() * schematic.getLength() + z * schematic.getWidth() + x;
    35. if(getMaterial(schematic.getBlocks()[index]) != Material.AIR) {
    36. data.put(block, index);
    37. }
    38. }
    39. }
    40. }
    41. }
    42. public void setupBuilderEntity() {
    43. if(this.entity instanceof LivingEntity) {
    44. if(!this.entity.isDead()) {
    45. return;
    46. } else {
    47. this.entity = (LivingEntity) loc.getWorld().spawnEntity(loc, type);
    48. this.entity.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 1));
    49. this.entity.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, Integer.MAX_VALUE, 1));
    50. this.entity.setCustomName(ChatColor.GOLD + "[ManCo]"+ChatColor.WHITE + "builder!");
    51. this.entity.setCustomNameVisible(true);
    52. }
    53. } else {
    54. this.entity = (LivingEntity) loc.getWorld().spawnEntity(loc, type);
    55. this.entity.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 1));
    56. this.entity.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, Integer.MAX_VALUE, 1));
    57. this.entity.setCustomName(ChatColor.GOLD + "[ManCo]"+ChatColor.WHITE + "builder!");
    58. this.entity.setCustomNameVisible(true);
    59. }
    60. }
    61. @SuppressWarnings("deprecation")
    62. @Override
    63. public void run() {
    64. if(data.isEmpty()) {
    65. setData();
    66. }
    67. setupBuilderEntity();
    68. final List<Block> collection = new ArrayList<Block>();
    69. if(collection.isEmpty()) {
    70. collection.addAll(Arrays.asList(data.keySet().toArray(new Block[data.size()])));
    71. Collections.sort(collection, new Comparator<Block>() {
    72. @Override
    73. public int compare(Block o1, Block o2) {
    74. return Double.compare(o1.getY(), o2.getY());
    75. }
    76. });
    77. }
    78. if(!(it instanceof Iterator)) {
    79. this.it = collection.iterator();
    80. }
    81. if(it instanceof Iterator) {
    82. if(it.hasNext()) {
    83. Block block = it.next();
    84. int index = data.get(block);
    85. Material dataValue = getMaterial(schematic.getBlocks()[index]);
    86. byte subValue = schematic.getData()[index];
    87.  
    88. if(entity instanceof Enderman) {
    89. Enderman enderman = (Enderman) entity;
    90. enderman.setCarriedMaterial(new MaterialData(dataValue, subValue));
    91. }
    92.  
    93. if(block.getType() == Material.AIR) {
    94. try {
    95. if(!block.getChunk().isLoaded()) {
    96. block.getChunk().load();
    97. }
    98. block.setTypeIdAndData(dataValue.getId(), subValue, true);
    99. saveRollback(block);
    100. block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, dataValue);
    101. entity.teleport(block.getRelative(BlockFace.UP).getRelative(BlockFace.UP).getLocation());
    102. entity.setHealth(entity.getMaxHealth());
    103. }catch(NullPointerException e) {e.printStackTrace();}
    104. }
    105. it.remove();
    106. collection.remove(block);
    107. data.remove(block);
    108. } else {
    109. entity.remove();
    110. collection.clear();
    111. data.clear();
    112. cancel();
    113. }
    114. }
    115. }
    116. }.runTaskTimer(ManCo.getPlugin(), 0L, 1L);
    117. }
    118. @SuppressWarnings("deprecation")
    119. public Material getMaterial(int id) {
    120. try {
    121. Material mat = Material.getMaterial(id);
    122. return (mat instanceof Material ? mat : Material.AIR);
    123. } catch(NullPointerException e) {
    124. return Material.AIR;
    125. }
    126. }
    127.  
    128. @SuppressWarnings("deprecation")
    129. private void saveRollback(Block block) {
    130. if(Hook.isCoreProtectEnabled()) {
    131. CoreProtectHook.log(player, block);
    132. } else if(Hook.isLogBlockEnabled()) {
    133. LogBlockHook.log(player, block);
    134. } else if(Hook.isPrismEnabled()) {
    135. PrismHook.log(player, block);
    136. }
    137. }
    138. }
    139.  


    thanks for the help though :)
     
  2. Offline

    LazyLemons

    Are you positive the initial chunk is loaded properly?
     
Thread Status:
Not open for further replies.

Share This Page