2017-11-27 5 views
-1

1.7 클래스를 1.12.2로 업데이트하려고합니다. 몇 가지 오류를 해결했지만 다른 오류를 수정하는 방법을 모릅니다.1.7 클래스를 1.12.2로 변경하십시오.

package de.beastsoup.utils.spigot.bo2; 

import java.io.BufferedReader; 
import java.io.File; 
import java.io.FileReader; 
import java.util.ArrayList; 
import java.util.HashSet; 
import java.util.List; 

import de.beastsoup.utils.spigot.BeastUtils; 
import net.minecraft.server.v1_12_R1.TileEntity; 
import org.bukkit.Bukkit; 
import org.bukkit.Location; 
import org.bukkit.Material; 
import org.bukkit.World; 
import org.bukkit.block.Block; 
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld; 
import org.bukkit.scheduler.BukkitRunnable; 

public class BO2 { 

private Arena arena; 

public BO2() { 
    this.arena = new Arena(this); 
} 

public Arena getArena() { 
    return arena; 
} 

private static HashSet<Location> blocksForUpdate = new HashSet<>(); 

public void addBlockUpdate(Location location) { 
    blocksForUpdate.add(location); 
} 

public void startUpdate() { 
    new BukkitRunnable() { 
     @Override 
     public void run() { 
      if (!blocksForUpdate.isEmpty()) { 
       net.minecraft.server.v1_12_R1.World world = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle(); 
       for (Location location : blocksForUpdate) { 
        world.notify(location.getBlockX(), location.getBlockY(), location.getBlockZ()); 
       } 
       blocksForUpdate.clear(); 
      } 
     } 
    }.runTaskTimer(BeastUtils.getPlugin(BeastUtils.class), 1, 1); 
} 

/* Spawn BO2 */ 

public List<Block> spawn(Location location, File file) { 
    long time = System.currentTimeMillis(); 
    BufferedReader reader; 
    ArrayList<Block> blocks = new ArrayList<>(); 
    try { 
     reader = new BufferedReader(new FileReader(file)); 
     String line = null; 
     while ((line = reader.readLine()) != null) { 
      if (!line.contains(",") || !line.contains(":")) { 
       continue; 
      } 
      String[] parts = line.split(":"); 
      String[] coordinates = parts[0].split(","); 
      String[] blockData = parts[1].split("\\."); 

      setBlockFast(location.getWorld(), location.getBlockX() + Integer.valueOf(coordinates[0]), location.getBlockY() + Integer.valueOf(coordinates[2]), location.getBlockZ() + Integer.valueOf(coordinates[1]), Integer.valueOf(blockData[0]), blockData.length > 1 ? Byte.valueOf(blockData[1]) : 0); 
      blocks.add(location.getWorld().getBlockAt(location.getBlockX() + Integer.valueOf(coordinates[0]), location.getBlockY() + Integer.valueOf(coordinates[2]), location.getBlockZ() + Integer.valueOf(coordinates[1]))); 
     } 
     reader.close(); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 
    System.out.println("BO2 spawnada em " + (time - System.currentTimeMillis()) + "ms"); 
    return blocks; 
} 

/* Load BO2 file */ 

public List<FutureBlock> load(Location location, File file) { 
    BufferedReader reader; 
    ArrayList<FutureBlock> blocks = new ArrayList<>(); 
    try { 
     reader = new BufferedReader(new FileReader(file)); 
     String line = null; 
     while ((line = reader.readLine()) != null) { 
      if (!line.contains(",") || !line.contains(":")) { 
       continue; 
      } 
      String[] parts = line.split(":"); 
      String[] coordinates = parts[0].split(","); 
      String[] blockData = parts[1].split("\\."); 
      blocks.add(new FutureBlock(location.clone().add(Integer.valueOf(coordinates[0]), Integer.valueOf(coordinates[2]), Integer.valueOf(coordinates[1])), Integer.valueOf(blockData[0]), blockData.length > 1 ? Byte.valueOf(blockData[1]) : 0)); 
     } 
     reader.close(); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 
    return blocks; 
} 

/* Set methods */ 

public boolean setBlockFast(World world, int x, int y, int z, int blockId, byte data) { 
    if (y >= 255 || y < 0) { 
     return false; 
    } 
    net.minecraft.server.v1_12_R1.World w = ((CraftWorld) world).getHandle(); 
    net.minecraft.server.v1_12_R1.Chunk chunk = w.getChunkAt(x >> 4, z >> 4); 
    boolean b = data(chunk, x & 0x0f, y, z & 0x0f, net.minecraft.server.v1_12_R1.Block.getById(blockId), data); 
    addBlockUpdate(new Location(Bukkit.getWorlds().get(0), x, y, z)); 
    return b; 
} 

@SuppressWarnings("deprecation") 
public boolean setBlockFast(Location location, Material material, byte data) { 
    return setBlockFast(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), material.getId(), data); 
} 

private boolean data(net.minecraft.server.v1_12_R1.Chunk that, int i, int j, int k, net.minecraft.server.v1_12_R1.Block block, int l) { 
    int i1 = k << 4 | i; 

    if (j >= that.b[i1] - 1) { 
     that.b[i1] = -999; 
    } 

    int j1 = that.heightMap[i1]; 
    net.minecraft.server.v1_12_R1.Block block1 = that.getType(i, j, k); 
    int k1 = that.getData(i, j, k); 

    if (block1 == block && k1 == l) { 
     return false; 
    } else { 
     boolean flag = false; 
     net.minecraft.server.v1_12_R1.ChunkSection chunksection = that.getSections()[j >> 4]; 

     if (chunksection == null) { 
      if (block == net.minecraft.server.v1_12_R1.Blocks.AIR) { 
       return false; 
      } 

      chunksection = that.getSections()[j >> 4] = new net.minecraft.server.v1_12_R1.ChunkSection(j >> 4 << 4, !that.world.worldProvider.g); 
      flag = j >= j1; 
     } 

     int l1 = that.locX * 16 + i; 
     int i2 = that.locZ * 16 + k; 

     if (!that.world.isStatic) { 
      block1.f(that.world, l1, j, i2, k1); 
     } 
     if (!(block1 instanceof IContainer)) { 
      chunksection.setTypeId(i, j & 15, k, block); 
     } 
     if (!that.world.isStatic) { 
      block1.remove(that.world, l1, j, i2, block1, k1); 
     } else if (block1 instanceof IContainer && block1 != block) { 
      that.world.p(l1, j, i2); 
     } 
     if (block1 instanceof IContainer) { 
      chunksection.setTypeId(i, j & 15, k, block); 
     } 
     if (chunksection.getTypeId(i, j & 15, k) != block) { 
      return false; 
     } else { 
      chunksection.setData(i, j & 15, k, l); 
      if (flag) { 
       that.initLighting(); 
      } 
      TileEntity tileentity; 

      if (block1 instanceof IContainer) { 
       tileentity = that.e(i, j, k); 
       if (tileentity != null) { 
        tileentity.u(); 
       } 
      } 
      if (!that.world.isStatic && (!that.world.captureBlockStates || (block instanceof net.minecraft.server.v1_7_R4.BlockContainer))) { 
       block.onPlace(that.world, l1, j, i2); 
      } 

      if (block instanceof IContainer) { 
       if (that.getType(i, j, k) != block) { 
        return false; 
       } 
       tileentity = that.e(i, j, k); 
       if (tileentity == null) { 
        tileentity = ((IContainer) block).a(that.world, l); 
        that.world.setTileEntity(l1, j, i2, tileentity); 
       } 

       if (tileentity != null) { 
        tileentity.u(); 
       } 
      } 

      that.n = true; 
      return true; 
     } 
    } 
} 

/* FutureBlock Utils */ 

public class FutureBlock { 
    private Location location; 
    private int id; 
    private byte data; 

    public FutureBlock(Location location, int id, byte data) { 
     this.location = location; 
     this.id = id; 
     this.data = data; 
    } 

    public byte getData() { 
     return data; 
    } 

    public Location getLocation() { 
     return location; 
    } 

    public int getId() { 
     return id; 
    } 

    @SuppressWarnings("deprecation") 
    public void place() { 
     location.getBlock().setTypeIdAndData(id, data, true); 
    } 
} 

} 

지금 해결해야 할이 오류 : https://gyazo.com/cb3176c9d879532adddfc5ce1edad2eb, https://gyazo.com/014047f5103fd1eaace121bc121fa8dc, https://gyazo.com/6b546cd147037a9deffad42e3b1ce1ef

하는 사람이 NMS 수도꼭지를 알고있는 경우에 사람이 제안이있는 경우, 나는

... 더 클래스 매우 매우 행복 할 것 1.12.2 또는 무엇인가 행복 할 것임

답변

0

나는 그 세 번째 이미지에 대해 확신하지 못한다. (나는 오류가 보이지 않는다.) Spigot 문서를보고 특정 정보를 얻는다. 이 문제를 해결하려면,하지만 난 은 바닐라가 BlockPos 시스템 (다양한 도우미 메서드와 함께 3 개의 int를 포함하는 단일 클래스 인스턴스로 지정됨)에 X, Y, Z 위치 (3 개의 별도 정수로 지정됨) 및 east()).

첫 번째 두 이미지/오류는 모두 호출자가 BlockPos을 전달해야하며 3 개의 int를 제공합니다.

int가 두 번째에서 오는 곳을 알지 못합니다. 처음에는 Spigot의 Location 개체가 어디에 있는지, 또는 그 값이 어디서오고 어떻게 구성되었는지 알 수 없습니다.

하지만 이제는 이러한 유형의 오류를 스스로 해결할 수있는 충분한 정보를 제공해야합니다.