nus-yam/ex-repair huggingface dataset:
Program: 11761
Project: 11761
Buggy source:
private HashMultimap<Class<? extends Event>,ReflectNotifier> reflectorsFrom(Plugin plugin,Listener listener,final Class<?> c){
  MethodAccess access=accessors.computeIfAbsent(c,(k) -> MethodAccess.get(c));
  Method[] methods=c.getDeclaredMethods();
  HashMultimap<Class<? extends Event>,ReflectNotifier> map=HashMultimap.create(11,11);
  for (int i=0, n=methods.length; i < n; i++) {
    Method method=methods[i];
    Class<?>[] parameterTypes=method.getParameterTypes();
    if (parameterTypes.length != 1)     continue;
    Class<?> type=parameterTypes[0];
    if (!Event.class.isAssignableFrom(type))     continue;
    Class<? extends Event> eventClass=type.asSubclass(Event.class);
    ListenerOpts handler=method.getAnnotation(ListenerOpts.class);
    Importance importance=handler == null ? Importance.MEDIUM : handler.importance();
    ReflectNotifier registeredListener=new ReflectNotifier(access,plugin,access.getIndex(method.getName()),listener,eventClass,importance);
    map.get(eventClass).add(registeredListener);
  }
  return map;
}

Fixed version (ground truth):
private HashMultimap<Class<? extends Event>,ReflectNotifier> reflectorsFrom(Plugin plugin,Listener listener,final Class<?> c){
  MethodAccess access=accessors.computeIfAbsent(c,(k) -> MethodAccess.get(c));
  Method[] methods=c.getDeclaredMethods();
  HashMultimap<Class<? extends Event>,ReflectNotifier> map=HashMultimap.create(11,11);
  for (  Method method : methods) {
    Class<?>[] parameterTypes=method.getParameterTypes();
    if (parameterTypes.length != 1)     continue;
    Class<?> type=parameterTypes[0];
    if (!Event.class.isAssignableFrom(type) || !method.isAnnotationPresent(IgnoreRegistration.class))     continue;
    Class<? extends Event> eventClass=type.asSubclass(Event.class);
    ListenerOpts handler=method.getAnnotation(ListenerOpts.class);
    Importance importance=handler == null ? Importance.MEDIUM : handler.importance();
    ReflectNotifier registeredListener=new ReflectNotifier(access,plugin,access.getIndex(method.getName()),listener,eventClass,importance);
    map.get(eventClass).add(registeredListener);
  }
  return map;
}
Program: 11762
Project: 11762
Buggy source:
@Override protected void doTick(){
  int distance=viewDistance();
  if (!loggingIn)   sendChunks(distance);
  ThreadsHandler.chunkExecutor().execute(() -> {
    PacketPlayOutMapChunkBulk bulk=new PacketPlayOutMapChunkBulk();
    boolean reached=false;
    for (int i=0; bulk.size() < 1845152; i++) {
      ChunkLocation location=chunkQueue.poll();
      if (location == null)       continue;
      bulk.addEntry(((TridentChunk)world().chunkAt(location,true)).asPacket());
      if (i == 16) {
        reached=true;
        break;
      }
    }
    if (bulk.hasEntries() && !reached) {
      connection().sendPacket(bulk);
    }
    for (int i=0; i < CLEAN_ITERATIONS; i++) {
      if (knownChunks.size() > MAX_CHUNKS)       cleanChunks(distance - i);
    }
  }
);
  connection.tick();
  ticksExisted.incrementAndGet();
}

Fixed version (ground truth):
@Override protected void doTick(){
  int distance=viewDistance();
  if (!loggingIn)   ThreadsHandler.chunkExecutor().execute(() -> {
    sendChunks(distance);
    for (int i=0; i < CLEAN_ITERATIONS; i++) {
      if (knownChunks.size() > MAX_CHUNKS)       cleanChunks(distance - i);
    }
  }
);
  connection.tick();
  ticksExisted.incrementAndGet();
}
Program: 11763
Project: 11763
Buggy source:
private void removeChunk(ChunkLocation location){
  chunkQueue.remove(location);
  ((TridentWorld)world()).loadedChunks.tryRemove(location);
  connection.sendPacket(new PacketPlayOutChunkData(new byte[0],location,true,(short)0));
  knownChunks.remove(location);
}

Fixed version (ground truth):
private void removeChunk(ChunkLocation location){
  ((TridentWorld)world()).loadedChunks.tryRemove(location);
  connection.sendPacket(new PacketPlayOutChunkData(new byte[0],location,true,(short)0));
  knownChunks.remove(location);
}
Program: 11764
Project: 11764
Buggy source:
public void sendChunks(int viewDistance){
  int centX=((int)Math.floor(loc.x())) >> 4;
  int centZ=((int)Math.floor(loc.z())) >> 4;
  for (int x=(centX - viewDistance / 2); x <= (centX + viewDistance / 2); x+=1) {
    for (int z=(centZ - viewDistance / 2); z <= (centZ + viewDistance / 2); z+=1) {
      ChunkLocation location=ChunkLocation.create(x,z);
      if (!knownChunks.add(location))       continue;
      chunkQueue.offer(location);
    }
  }
}

Fixed version (ground truth):
public void sendChunks(int viewDistance){
  int centX=((int)Math.floor(loc.x())) >> 4;
  int centZ=((int)Math.floor(loc.z())) >> 4;
  PacketPlayOutMapChunkBulk bulk=new PacketPlayOutMapChunkBulk();
  for (int x=(centX - viewDistance / 2); x <= (centX + viewDistance / 2); x+=1) {
    for (int z=(centZ - viewDistance / 2); z <= (centZ + viewDistance / 2); z+=1) {
      ChunkLocation location=ChunkLocation.create(x,z);
      if (!knownChunks.add(location))       continue;
      bulk.addEntry(((TridentChunk)world().chunkAt(location,true)).asPacket());
      if (bulk.size() >= 1845152) {
        connection().sendPacket(bulk);
        bulk=new PacketPlayOutMapChunkBulk();
      }
    }
  }
  if (bulk.hasEntries()) {
    connection().sendPacket(bulk);
  }
}
Program: 11767
Project: 11767
Buggy source:
@Override public Packet decode(ByteBuf buf){
  this.windowId=(int)buf.readByte();
  this.clickedSlot=buf.readShort();
  this.clickedButton=(int)buf.readByte();
  this.actionNumber=buf.readShort();
  short mode=buf.readShort();
  this.mode=ClickAction.getAction(mode,clickedButton,clickedSlot);
  this.clickedItem=new Slot(buf);
  return this;
}

Fixed version (ground truth):
@Override public Packet decode(ByteBuf buf){
  this.windowId=(int)buf.readByte();
  this.clickedSlot=buf.readShort();
  this.clickedButton=(int)buf.readByte();
  this.actionNumber=buf.readShort();
  this.modeId=buf.readByte();
  this.mode=ClickAction.getAction(modeId,clickedButton,clickedSlot);
  this.clickedItem=new Slot(buf);
  return this;
}
Program: 11770
Project: 11770
Buggy source:
@Override public void manipulate(int relX,int y,int relZ,Substance substance,byte data){
  if (relX >= 0 && relX <= 15 && relZ >= 0 && relZ <= 15) {
    setAt(relX,y,relZ,substance,data,(byte)255,(byte)15);
    return;
  }
  int cx=location.x();
  int cz=location.z();
  int xMinDiff=Math.max(relX,0) - Math.min(relX,0);
  int xMaxDiff=Math.max(relX,15) - Math.min(relX,15);
  int zMinDiff=Math.max(relZ,0) - Math.min(relZ,0);
  int zMaxDiff=Math.max(relZ,15) - Math.min(relZ,15);
  int chunkX=location.x();
  int chunkZ=location.z();
  int newX=relX;
  int newZ=relZ;
  if (relX < 0) {
    newX=16 - xMinDiff;
    chunkX=cx - up(xMinDiff / 16) - 1;
  }
 else   if (relX > 15) {
    newX=xMaxDiff - 1;
    chunkX=cx + up(xMaxDiff / 16) + 1;
  }
  if (relZ < 0) {
    newZ=16 - zMinDiff;
    chunkZ=cz - up(zMinDiff / 16) - 1;
  }
 else   if (relZ > 15) {
    newZ=zMaxDiff - 1;
    chunkZ=cz + up(zMaxDiff / 16) + 1;
  }
  ChunkLocation loc=ChunkLocation.create(chunkX,chunkZ);
  TridentChunk chunk=rawChunk(loc);
  TridentLogger.get().debug(relX + "String_Node_Str" + relZ+ "String_Node_Str"+ xMinDiff+ "String_Node_Str"+ xMaxDiff+ "String_Node_Str"+ zMinDiff+ "String_Node_Str"+ zMaxDiff+ "String_Node_Str"+ newX+ "String_Node_Str"+ newZ);
  chunk.setAndSend(newX,y,newZ,substance,data,(byte)255,(byte)15,change);
}

Fixed version (ground truth):
@Override public void manipulate(int relX,int y,int relZ,Substance substance,byte data){
  if (relX >= 0 && relX <= 15 && relZ >= 0 && relZ <= 15) {
    setAndSend(relX,y,relZ,substance,data,(byte)255,(byte)15,change);
    return;
  }
  int cx=location.x();
  int cz=location.z();
  int xMinDiff=Math.max(relX,0) - Math.min(relX,0);
  int xMaxDiff=Math.max(relX,15) - Math.min(relX,15);
  int zMinDiff=Math.max(relZ,0) - Math.min(relZ,0);
  int zMaxDiff=Math.max(relZ,15) - Math.min(relZ,15);
  int chunkX=location.x();
  int chunkZ=location.z();
  int newX=relX;
  int newZ=relZ;
  if (relX < 0) {
    newX=16 - xMinDiff;
    chunkX=cx - up(xMinDiff / 16) - 1;
  }
 else   if (relX > 15) {
    newX=xMaxDiff - 1;
    chunkX=cx + up(xMaxDiff / 16) + 1;
  }
  if (relZ < 0) {
    newZ=16 - zMinDiff;
    chunkZ=cz - up(zMinDiff / 16) - 1;
  }
 else   if (relZ > 15) {
    newZ=zMaxDiff - 1;
    chunkZ=cz + up(zMaxDiff / 16) + 1;
  }
  ChunkLocation loc=ChunkLocation.create(chunkX,chunkZ);
  TridentChunk chunk=rawChunk(loc);
  TridentLogger.get().debug(relX + "String_Node_Str" + relZ+ "String_Node_Str"+ xMinDiff+ "String_Node_Str"+ xMaxDiff+ "String_Node_Str"+ zMinDiff+ "String_Node_Str"+ zMaxDiff+ "String_Node_Str"+ newX+ "String_Node_Str"+ newZ);
  chunk.setAndSend(newX,y,newZ,substance,data,(byte)255,(byte)15,change);
}
Program: 11771
Project: 11771
Buggy source:
/** 
 * Performs the shutdown procedure on the server, ending with the exit of the JVM
 */
@Override public void shutdown(){
  TridentLogger.get().log("String_Node_Str");
  try {
    ((Statuses)Registered.statuses()).saveAll();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  TridentLogger.get().log("String_Node_Str");
  for (  Plugin plugin : Registered.plugins())   Registered.plugins().disable(plugin);
  TridentLogger.get().log("String_Node_Str");
  for (  Player player : TridentPlayer.players()) {
    ((TridentPlayer)player).kickPlayer("String_Node_Str");
    ((TridentPlayer)player).connection().logout();
  }
  TridentLogger.get().log("String_Node_Str");
  for (  World world : rootWorldLoader.worlds())   ((TridentWorld)world).save();
  TridentLogger.get().log("String_Node_Str");
  ((TridentTaskScheduler)Registered.tasks()).shutdown();
  TridentLogger.get().log("String_Node_Str");
  ThreadsHandler.shutdownAll();
  TridentLogger.get().log("String_Node_Str");
  ConcurrentTaskExecutor.executors().forEach(ConcurrentTaskExecutor::shutdown);
  TridentLogger.get().log("String_Node_Str");
  TridentStart.close();
  TridentLogger.get().log("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Performs the shutdown procedure on the server, ending with the exit of the JVM
 */
@Override public void shutdown(){
  TridentLogger.get().log("String_Node_Str");
  try {
    ((Statuses)Registered.statuses()).saveAll();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  TridentLogger.get().log("String_Node_Str");
  ConcurrentTaskExecutor.executors().forEach(ConcurrentTaskExecutor::shutdown);
  TridentLogger.get().log("String_Node_Str");
  for (  Player player : TridentPlayer.players()) {
    ((TridentPlayer)player).kickPlayer("String_Node_Str");
    ((TridentPlayer)player).connection().logout();
  }
  TridentLogger.get().log("String_Node_Str");
  for (  World world : rootWorldLoader.worlds())   ((TridentWorld)world).save();
  TridentLogger.get().log("String_Node_Str");
  ((TridentTaskScheduler)Registered.tasks()).shutdown();
  TridentLogger.get().log("String_Node_Str");
  ThreadsHandler.shutdownAll();
  TridentLogger.get().log("String_Node_Str");
  for (  Plugin plugin : Registered.plugins())   Registered.plugins().disable(plugin);
  TridentLogger.get().log("String_Node_Str");
  TridentStart.close();
  TridentLogger.get().log("String_Node_Str");
}
Program: 11772
Project: 11772
Buggy source:
@Override public TridentChunk chunkAt(ChunkLocation location,boolean generateIfNotFound){
  if (location == null) {
    return null;
  }
  TridentChunk chunk=this.loadedChunks.get(location,generateIfNotFound);
  if (chunk != null)   chunk.paint();
  return chunk;
}

Fixed version (ground truth):
@Override public TridentChunk chunkAt(ChunkLocation location,boolean generateIfNotFound){
  if (location == null) {
    return null;
  }
  TridentChunk chunk=this.loadedChunks.get(location,generateIfNotFound);
  if (chunk != null && generateIfNotFound)   chunk.paint();
  return chunk;
}
Program: 11775
Project: 11775
Buggy source:
/** 
 * Blocks the thread until this method is called again by a   {@link #complete(String)} method
 */
public static void awaitSync(){
  boolean b=canProceed();
  if (b)   return;
  try {
    if (!latch.await(200,TimeUnit.MILLISECONDS)) {
      TridentLogger.get().warn("String_Node_Str" + complete.sum() + "String_Node_Str"+ expected.sum()+ "String_Node_Str"+ b);
      if (DEBUG) {
        TridentLogger.get().warn("String_Node_Str");
        TridentLogger.get().warn("String_Node_Str");
        completed.forEach(TridentLogger::warn);
        TridentLogger.get().warn("String_Node_Str");
        TridentLogger.get().warn("String_Node_Str");
        TridentLogger.get().warn("String_Node_Str");
        expect.forEach(TridentLogger::warn);
        TridentLogger.get().warn("String_Node_Str");
        TridentLogger.get().warn("String_Node_Str" + TridentServer.instance().mainThread().getAverageTickLength() + "String_Node_Str");
      }
 else {
        TridentLogger.get().warn("String_Node_Str");
      }
    }
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
/** 
 * Blocks the thread until this method is called again by a   {@link #complete(String)} method
 */
public static void awaitSync(){
  boolean b=canProceed();
  if (b)   return;
  try {
    if (!latch.await(200,TimeUnit.MILLISECONDS)) {
      TridentLogger.get().warn("String_Node_Str" + complete.sum() + "String_Node_Str"+ expected.sum()+ "String_Node_Str"+ b);
      if (DEBUG) {
        TridentLogger.get().warn("String_Node_Str");
        TridentLogger.get().warn("String_Node_Str");
        completed.forEach(s -> TridentLogger.get().warn(s));
        TridentLogger.get().warn("String_Node_Str");
        TridentLogger.get().warn("String_Node_Str");
        TridentLogger.get().warn("String_Node_Str");
        expect.forEach(s -> TridentLogger.get().warn(s));
        TridentLogger.get().warn("String_Node_Str");
        TridentLogger.get().warn("String_Node_Str" + TridentServer.instance().mainThread().getAverageTickLength() + "String_Node_Str");
      }
 else {
        TridentLogger.get().warn("String_Node_Str");
      }
    }
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
}
Program: 11776
Project: 11776
Buggy source:
@Override public void handleReceived(ClientConnection connection){
  TridentPlayer player=((PlayerConnection)connection).player();
  location.setWorld(player.world());
  Substance substance=player.heldItem().type();
  if (substance != Substance.AIR) {
    Vector vector=determineOffset();
    if (!substance.isBlock()) {
    }
    if (location.y() + vector.y() > 255 || location.y() + vector.y() < 0) {
      return;
    }
    Position position=location.relative(vector);
    Block block=new OwnedTridentBlock(player,position.block());
    short yaw=(short)(player.position().yaw() * 10);
    short meta=player.heldItem().damageValue();
    Value<Byte> result=Value.of((byte)0);
    Value<Substance> substanceValue=Value.of(substance);
    boolean allow=MetaFactory.decode(block,substanceValue,new byte[]{writeFirst(yaw),writeSecond(yaw),direction,((byte)cursorPosition.x()),((byte)cursorPosition.y()),((byte)cursorPosition.z()),writeFirst(meta),writeSecond(meta)},result);
    if (allow) {
      block.setSubstanceAndMeta(substanceValue.get(),result.get());
    }
  }
}

Fixed version (ground truth):
@Override public void handleReceived(ClientConnection connection){
  TridentPlayer player=((PlayerConnection)connection).player();
  location.setWorld(player.world());
  Substance substance=player.heldItem().type();
  if (substance != Substance.AIR) {
    Vector vector=determineOffset();
    if (!substance.isBlock()) {
      return;
    }
    if (substance.isFunctional() && !player.isCrouching()) {
      return;
    }
    if (location.y() + vector.y() > 255 || location.y() + vector.y() < 0) {
      return;
    }
    Position position=location.relative(vector);
    Block block=new OwnedTridentBlock(player,position.block());
    short yaw=(short)(player.position().yaw() * 10);
    short meta=player.heldItem().damageValue();
    Value<Byte> result=Value.of((byte)0);
    Value<Substance> substanceValue=Value.of(substance);
    boolean allow=MetaFactory.decode(block,substanceValue,new byte[]{writeFirst(yaw),writeSecond(yaw),direction,((byte)cursorPosition.x()),((byte)cursorPosition.y()),((byte)cursorPosition.z()),writeFirst(meta),writeSecond(meta)},result);
    if (allow) {
      block.setSubstanceAndMeta(substanceValue.get(),result.get());
      SoundEffectType soundEffectType=substance.placeSound();
      if (soundEffectType != null) {
        SoundEffect sound=location.world().playSound(soundEffectType);
        sound.setPosition(location);
        sound.apply();
      }
    }
  }
}
Program: 11778
Project: 11778
Buggy source:
/** 
 * Resets the counters and the blocking mechanisms for the next tick iteration
 */
public static void reset(){
  expected.reset();
  complete.reset();
  proceed.reset();
}

Fixed version (ground truth):
/** 
 * Resets the counters and the blocking mechanisms for the next tick iteration
 */
public static void reset(){
  expected.reset();
  complete.reset();
  latch=new CountDownLatch(1);
  Lock lock=taskLock;
  lock.lock();
  try {
    taskLock=new ReentrantLock();
    available=taskLock.newCondition();
  }
  finally {
    lock.unlock();
  }
}
Program: 11779
Project: 11779
Buggy source:
/** 
 * Records that an update has occurred <p> <p>Signals the main thread to sync method to continue if the expected and update counters match</p>
 */
public static void complete(){
  complete.increment();
  if (canProceed()) {
    awaitSync();
  }
}

Fixed version (ground truth):
/** 
 * Records that an update has occurred <p> <p>Signals the main thread to sync method to continue if the expected and update counters match</p>
 */
public static void complete(){
  complete.increment();
  if (canProceed()) {
    latch.countDown();
  }
}
Program: 11780
Project: 11780
Buggy source:
/** 
 * Blocks the thread until this method is called again by a   {@link #complete()} method
 */
public static void awaitSync(){
  if (canProceed())   return;
  try {
    proceed.await();
  }
 catch (  InterruptedException|BrokenBarrierException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
/** 
 * Blocks the thread until this method is called again by a   {@link #complete()} method
 */
public static void awaitSync(){
  if (canProceed())   return;
  try {
    latch.await();
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
}
Program: 11781
Project: 11781
Buggy source:
public void populate(Block block){
  Substance substance=block.substance();
  MetaCompiler compiler=metaMap.get(substance);
  if (compiler != null) {
    for (    BlockMeta<Block> meta : compiler.compileBlock(block)) {
      block.commit(meta,false);
    }
  }
}

Fixed version (ground truth):
public void populate(Block block){
  Substance substance=block.substance();
  MetaCompiler compiler=metaMap.get(substance);
  if (compiler != null) {
    for (    BlockMeta<Block> meta : compiler.compileBlock(block)) {
      block.applyMeta(meta,false);
    }
  }
}
Program: 11782
Project: 11782
Buggy source:
@Override public void setPosition(Position loc){
  players().stream().filter((p) -> !p.equals(this)).forEach((p) -> {
    ((TridentPlayer)p).connection.sendPacket(new PacketPlayOutEntityTeleport().set("String_Node_Str",entityId()).set("String_Node_Str",loc).set("String_Node_Str",onGround));
  }
);
  super.setPosition(loc);
}

Fixed version (ground truth):
@Override public void setPosition(Position loc){
  double dX=loc.x() - position().x();
  double dY=loc.y() - position().y();
  double dZ=loc.z() - position().z();
  if (dX == 0 && dY == 0 && dZ == 0) {
    sendFiltered(new PacketPlayOutEntityLook().set("String_Node_Str",entityId()).set("String_Node_Str",loc).set("String_Node_Str",onGround),player -> !player.equals(this));
    return;
  }
  if ((dX > 4 || dY > 4 || dZ > 4) || (ticksExisted.get() & 1) == 0) {
    sendFiltered(new PacketPlayOutEntityTeleport().set("String_Node_Str",entityId()).set("String_Node_Str",loc).set("String_Node_Str",onGround),player -> !player.equals(this));
  }
 else {
    for (    Player player : players()) {
      if (player.equals(this))       continue;
      Packet packet=new PacketPlayOutEntityRelativeMove().set("String_Node_Str",entityId()).set("String_Node_Str",new Vector(dX,dY,dZ)).set("String_Node_Str",onGround);
      ((TridentPlayer)player).connection.sendPacket(packet);
    }
  }
  super.setPosition(loc);
}
Program: 11783
Project: 11783
Buggy source:
@Override protected void doRemove(){
  ONLINE_PLAYERS.remove(this.uniqueId());
  cleanChunks(0);
  PacketPlayOutPlayerListItem item=new PacketPlayOutPlayerListItem();
  item.set("String_Node_Str",4).set("String_Node_Str",new PlayerListDataBuilder[]{new PacketPlayOutPlayerListItem.PlayerListDataBuilder().id(uniqueId).values(new Object[0])});
  sendAll(item);
  players().forEach(p -> new MessageBuilder(name + "String_Node_Str").color(ChatColor.YELLOW).build().sendTo(p));
  TridentLogger.log(name + "String_Node_Str");
}

Fixed version (ground truth):
@Override protected void doRemove(){
  ONLINE_PLAYERS.remove(this.uniqueId());
  PacketPlayOutPlayerListItem item=new PacketPlayOutPlayerListItem();
  item.set("String_Node_Str",4).set("String_Node_Str",new PlayerListDataBuilder[]{new PacketPlayOutPlayerListItem.PlayerListDataBuilder().id(uniqueId).values(new Object[0])});
  sendAll(item);
  players().forEach(p -> new MessageBuilder(name + "String_Node_Str").color(ChatColor.YELLOW).build().sendTo(p));
  TridentLogger.log(name + "String_Node_Str");
}
Program: 11784
Project: 11784
Buggy source:
@InternalUseOnly public void setCrouching(boolean crouching){
  PacketPlayOutEffect effect=new PacketPlayOutEffect();
  effect.set("String_Node_Str",104);
  this.crouching=crouching;
}

Fixed version (ground truth):
@InternalUseOnly public void setCrouching(boolean crouching){
  ProtocolMetadata meta=new ProtocolMetadata();
  encodeMetadata(meta);
  int idx=0;
  int mask=0x02;
  meta.setMeta(idx,MetadataType.BYTE,(byte)(((byte)meta.get(0).value() & ~mask) | (crouching ? mask : 0)));
  sendFiltered(new PacketPlayOutEntityMetadata().set("String_Node_Str",entityId()).set("String_Node_Str",meta),p -> !p.equals(this));
  this.crouching=crouching;
}
Program: 11785
Project: 11785
Buggy source:
@Override public TaskExecutor nextWorker(){
  int count;
  int max=this.count.get();
  long stamp=lock.readLock();
  try {
    count=this.scaleIdx;
  }
  finally {
    lock.unlockRead(stamp);
  }
  if (count >= max) {
    count=0;
    stamp=lock.writeLock();
    try {
      this.scaleIdx=0;
    }
  finally {
      lock.unlockWrite(stamp);
    }
  }
 else {
    stamp=lock.writeLock();
    try {
      scaleIdx++;
    }
  finally {
      lock.unlockWrite(stamp);
    }
  }
  return workerSet.get(count);
}

Fixed version (ground truth):
@Override public TaskExecutor nextWorker(){
  int count;
  int max=this.workerSet.size();
  long stamp=lock.readLock();
  try {
    count=this.scaleIdx;
  }
  finally {
    lock.unlockRead(stamp);
  }
  if (count >= max) {
    count=0;
    stamp=lock.writeLock();
    try {
      this.scaleIdx=0;
    }
  finally {
      lock.unlockWrite(stamp);
    }
  }
 else {
    stamp=lock.writeLock();
    try {
      scaleIdx++;
    }
  finally {
      lock.unlockWrite(stamp);
    }
  }
  return workerSet.get(count);
}
Program: 11786
Project: 11786
Buggy source:
@Override public void handleReceived(ClientConnection connection){
  PluginChannel channel=Registered.channels().fromName(this.channel);
  if (channel != null) {
    channel.read(this.data);
  }
}

Fixed version (ground truth):
@Override public void handleReceived(ClientConnection connection){
  PluginChannel channel=Registered.channels().fromName(this.channel);
  if (channel != null) {
    Registered.plugins().executor().execute(() -> channel.read(this.data));
  }
}
Program: 11787
Project: 11787
Buggy source:
@Override public Packet decode(ByteBuf buf){
  this.target=Codec.readVarInt32(buf);
  this.type=InteractType.fromId(Codec.readVarInt32(buf));
  double x=(double)buf.readFloat();
  double y=(double)buf.readFloat();
  double z=(double)buf.readFloat();
  this.location=Position.create(null,x,y,z);
  return this;
}

Fixed version (ground truth):
@Override public Packet decode(ByteBuf buf){
  this.target=Codec.readVarInt32(buf);
  this.type=InteractType.fromId(Codec.readVarInt32(buf));
  if (type == InteractType.INTERACT_AT) {
    double x=(double)buf.readFloat();
    double y=(double)buf.readFloat();
    double z=(double)buf.readFloat();
    this.location=Position.create(null,x,y,z);
  }
  return this;
}
Program: 11788
Project: 11788
Buggy source:
@Override public void handleReceived(ClientConnection connection){
  TridentPlayer player=((PlayerConnection)connection).player();
  if (location.y() >= 4095) {
    return;
  }
  Substance substance=player.heldItem().type();
  if (!substance.isBlock()) {
  }
  if (substance != Substance.AIR) {
    int x=(int)location.x();
    int y=(int)location.y();
    int z=(int)location.z();
switch (blockDirection()) {
case 0:
      y--;
    break;
case 1:
  y++;
break;
case 2:
z--;
break;
case 3:
z++;
break;
case 4:
x--;
break;
case 5:
x++;
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
Position position=Position.create(player.world(),x,y,z);
position.block().setSubstance(substance);
}
}

Fixed version (ground truth):
@Override public void handleReceived(ClientConnection connection){
  TridentPlayer player=((PlayerConnection)connection).player();
  location.setWorld(player.world());
  if (location.y() >= 4095) {
    return;
  }
  Substance substance=player.heldItem().type();
  if (!substance.isBlock()) {
  }
  if (substance != Substance.AIR) {
    int x=0;
    int y=0;
    int z=0;
switch (blockDirection()) {
case 0:
      y--;
    break;
case 1:
  y++;
break;
case 2:
z--;
break;
case 3:
z++;
break;
case 4:
x--;
break;
case 5:
x++;
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
Position position=location.relative(new Vector(x,y,z));
position.block().setSubstance(substance);
}
}
Program: 11789
Project: 11789
Buggy source:
@Override public Block blockAt(Position location){
  if (!location.world().name().equals(this.name()))   throw new IllegalArgumentException("String_Node_Str");
  int x=(int)Math.round(location.x());
  int y=(int)Math.round(location.y());
  int z=(int)Math.round(location.z());
  return this.chunkAt(WorldUtils.chunkLocation(x,z),true).blockAt(x % 16,y,z % 16);
}

Fixed version (ground truth):
@Override public Block blockAt(Position location){
  if (!location.world().name().equals(this.name()))   throw new IllegalArgumentException("String_Node_Str");
  int x=(int)Math.round(location.x());
  int y=(int)Math.round(location.y());
  int z=(int)Math.round(location.z());
  return this.chunkAt(WorldUtils.chunkLocation(x,z),true).blockAt(x & 15,y,z & 15);
}
Program: 11790
Project: 11790
Buggy source:
/** 
 * Occupies up a certain length of sectors, from a starting point
 * @param start  the sector to start from (inclusive)
 * @param length the amount of sectors to occupy
 */
void addSectors(int start,int length){
  for (int i=start; i < start + length; i++) {
    this.sectorMapping.set(i,true);
  }
}

Fixed version (ground truth):
/** 
 * Occupies up a certain length of sectors, from a starting point
 * @param start  the sector to start from (inclusive)
 * @param length the amount of sectors to occupy
 */
void addSectors(int start,int length){
  for (int i=start; i < start + length; i++) {
    sectorMapping[i]=1;
  }
}
Program: 11791
Project: 11791
Buggy source:
private SectorStorage(int... offsets){
  this.offsets=offsets;
  this.sectorMapping=new BitSet(1024);
  this.sectorMapping.set(0);
  this.sectorMapping.set(1);
  for (  int offset : offsets) {
    int loc=offset >> 8;
    int length=offset & 0xFF;
    for (int j=loc; j < loc + length; j++) {
      this.sectorMapping.set(j);
    }
  }
}

Fixed version (ground truth):
private SectorStorage(int... offsets){
  this.offsets=offsets;
  this.sectorMapping=new byte[1024];
  sectorMapping[0]=1;
  sectorMapping[1]=1;
  for (  int offset : offsets) {
    int loc=offset >> 8;
    int length=offset & 0xFF;
    for (int j=loc; j < loc + length; j++) {
      sectorMapping[j]=1;
    }
  }
}
Program: 11792
Project: 11792
Buggy source:
/** 
 * Free up a certain length of sectors, from a starting point
 * @param start  the sector to start from (inclusive)
 * @param length the amount of sectors to free up
 */
void freeSectors(int start,int length){
  for (int i=start; i < start + length; i++) {
    this.sectorMapping.set(i,false);
  }
}

Fixed version (ground truth):
/** 
 * Free up a certain length of sectors, from a starting point
 * @param start  the sector to start from (inclusive)
 * @param length the amount of sectors to free up
 */
void freeSectors(int start,int length){
  for (int i=start; i < start + length; i++) {
    sectorMapping[i]=0;
  }
}
Program: 11793
Project: 11793
Buggy source:
/** 
 * Finds a section of the file with enough free-space to accomodate 'length' sectors of data
 * @param length the amount of sectors of data
 * @return offset the location of the free space (in sectors)
 */
int findFreeSectors(int length){
  int counter=2;
  int consecutive=0;
  while (true) {
    if (!this.sectorMapping.get(counter)) {
      consecutive++;
      if (consecutive >= length) {
        break;
      }
    }
 else {
      consecutive=0;
    }
  }
  return counter;
}

Fixed version (ground truth):
/** 
 * Finds a section of the file with enough free-space to accomodate 'length' sectors of data
 * @param length the amount of sectors of data
 * @return offset the location of the free space (in sectors)
 */
int findFreeSectors(int length){
  int counter=2;
  int consecutive=0;
  while (consecutive < length) {
    if (sectorMapping[counter] != 1) {
      consecutive++;
      if (consecutive == length) {
        break;
      }
    }
 else {
      consecutive=0;
    }
    counter++;
  }
  return counter;
}
Program: 11796
Project: 11796
Buggy source:
/** 
 * Tracks the movement of the entity, not for teleportation
 * @param entity the entity to track
 * @param from   the original location
 * @param to     the new location
 */
public void trackMovement(Entity entity,Position from,Position to){
  tracker.trackMovement(entity,from,to);
}

Fixed version (ground truth):
/** 
 * Tracks the movement of the entity, not for teleportation
 * @param entity the entity to track
 * @param from   the original location
 * @param to     the new location
 */
public void trackMovement(Entity entity,Position from,Position to){
}
Program: 11797
Project: 11797
Buggy source:
private PlayerConnection(ClientConnection connection,TridentPlayer player){
  ClientConnection.clientData.remove(connection.address());
  ClientConnection.clientData.retrieve(connection.address(),() -> PlayerConnection.this);
  super.address=connection.address();
  super.channel=connection.channel();
  super.loginKeyPair=connection.loginKeyPair();
  super.sharedSecret=connection.sharedSecret();
  super.stage=Protocol.ClientStage.PLAY;
  super.encryptionEnabled=connection.isEncryptionEnabled();
  super.compressionEnabled=connection.isCompressionEnabled();
  this.player=player;
  PacketHandler handler=channel.pipeline().get(PacketHandler.class);
  if (handler != null) {
    handler.updateConnection(this);
  }
}

Fixed version (ground truth):
private PlayerConnection(ClientConnection connection,TridentPlayer player){
  ClientConnection.clientData.put(connection.address(),connection);
  super.address=connection.address();
  super.channel=connection.channel();
  super.loginKeyPair=connection.loginKeyPair();
  super.sharedSecret=connection.sharedSecret();
  super.stage=Protocol.ClientStage.PLAY;
  super.encryptionEnabled=connection.isEncryptionEnabled();
  super.compressionEnabled=connection.isCompressionEnabled();
  this.player=player;
  PacketHandler handler=channel.pipeline().get(PacketHandler.class);
  if (handler != null) {
    handler.updateConnection(this);
  }
}
Program: 11798
Project: 11798
Buggy source:
@Override public void setLocation(Position loc){
  ProtocolMetadata metadata=new ProtocolMetadata();
  encodeMetadata(metadata);
  PacketPlayOutEntityCompleteMove move=new PacketPlayOutEntityCompleteMove();
  move.set("String_Node_Str",entityId()).set("String_Node_Str",position().asVector().subtract(loc.asVector())).set("String_Node_Str",loc.pitch()).set("String_Node_Str",loc.yaw()).set("String_Node_Str",(byte)0x00);
  sendFiltered(move,(p) -> !p.equals(this));
  super.setLocation(loc);
}

Fixed version (ground truth):
@Override public void setLocation(Position loc){
  ProtocolMetadata metadata=new ProtocolMetadata();
  encodeMetadata(metadata);
  PacketPlayOutEntityCompleteMove move=new PacketPlayOutEntityCompleteMove();
  move.set("String_Node_Str",entityId()).set("String_Node_Str",loc.pitch()).set("String_Node_Str",loc.yaw()).set("String_Node_Str",(byte)0x00);
  players().stream().filter((p) -> !p.equals(this)).forEach((p) -> {
    Vector difference=p.position().asVector().subtract(loc.asVector());
    move.set("String_Node_Str",difference);
    if (Math.abs(difference.x()) > 4 || Math.abs(difference.y()) > 4 || Math.abs(difference.z()) > 4) {
      ((TridentPlayer)p).connection.sendPacket(new PacketPlayOutEntityTeleport().set("String_Node_Str",entityId()).set("String_Node_Str",loc).set("String_Node_Str",onGround));
      return;
    }
    ((TridentPlayer)p).connection.sendPacket(move);
  }
);
  super.setLocation(loc);
}
Program: 11799
Project: 11799
Buggy source:
@Override public TaskExecutor scaledThread(){
  for (  TaskExecutor ex : workers) {
    Worker w=(Worker)ex;
    if (!w.isHeld()) {
      return w;
    }
  }
  return addWorker(true);
}

Fixed version (ground truth):
@Override public TaskExecutor scaledThread(){
  for (  TaskExecutor ex : workerSet) {
    Worker w=(Worker)ex;
    if (!w.isHeld()) {
      return w;
    }
  }
  return addWorker(true);
}
Program: 11800
Project: 11800
Buggy source:
public void tick(){
  executor.execute(new Runnable(){
    @Override public void run(){
      ticksExisted.incrementAndGet();
      doTick();
    }
  }
);
}

Fixed version (ground truth):
public void tick(){
  executor.execute(() -> {
    ticksExisted.incrementAndGet();
    doTick();
  }
);
}
Program: 11801
Project: 11801
Buggy source:
@Override public Set<Entity> withinRange(double radius){
  double squared=radius * radius;
  Set<Entity> entities=location().world().entities();
  return entities.stream().filter((e) -> e.location().distanceSquared(location()) <= squared).collect(Collectors.toSet());
}

Fixed version (ground truth):
@Override public Set<Entity> withinRange(double radius){
  double squared=radius * radius;
  Set<Entity> entities=position().world().entities();
  return entities.stream().filter((e) -> e.position().distanceSquared(position()) <= squared).collect(Collectors.toSet());
}
Program: 11802
Project: 11802
Buggy source:
public void tick(){
  ThreadsHandler.worldExecutor().execute(() -> {
    redstoneTick=!redstoneTick;
    if (time >= 2400)     time=0;
    if (time % 40 == 0)     TridentPlayer.sendAll(new PacketPlayOutTimeUpdate().set("String_Node_Str",existed).set("String_Node_Str",time));
    rainTime--;
    thunderTime--;
    if (rainTime <= 0) {
      raining=!raining;
      rainTime=ThreadLocalRandom.current().nextInt();
    }
    if (thunderTime <= 0) {
      thundering=!thundering;
      thunderTime=ThreadLocalRandom.current().nextInt();
    }
    time++;
    existed++;
    if (time % 150 == 0) {
      Set<ChunkLocation> set=Sets.newHashSet();
      for (      Entity entity : entities) {
        if (entity instanceof Player) {
          Position pos=entity.location();
          int x=(int)pos.x() % 16;
          int z=(int)pos.z() % 16;
          int viewDist=Trident.config().getInt("String_Node_Str",7);
          for (int i=x - viewDist; i < x + viewDist; i++) {
            for (int j=z - viewDist; j < z + viewDist; j++) {
              set.add(ChunkLocation.create(i,j));
            }
          }
        }
      }
      loadedChunks.retain(set);
      set=null;
    }
  }
);
}

Fixed version (ground truth):
public void tick(){
  ThreadsHandler.worldExecutor().execute(() -> {
    redstoneTick=!redstoneTick;
    if (time >= 2400)     time=0;
    if (time % 40 == 0)     TridentPlayer.sendAll(new PacketPlayOutTimeUpdate().set("String_Node_Str",existed).set("String_Node_Str",time));
    rainTime--;
    thunderTime--;
    if (rainTime <= 0) {
      raining=!raining;
      rainTime=ThreadLocalRandom.current().nextInt();
    }
    if (thunderTime <= 0) {
      thundering=!thundering;
      thunderTime=ThreadLocalRandom.current().nextInt();
    }
    time++;
    existed++;
    if (time % 150 == 0) {
      Set<ChunkLocation> set=Sets.newHashSet();
      for (      Entity entity : entities) {
        if (entity instanceof Player) {
          Position pos=entity.position();
          int x=(int)pos.x() % 16;
          int z=(int)pos.z() % 16;
          int viewDist=Trident.config().getInt("String_Node_Str",7);
          for (int i=x - viewDist; i < x + viewDist; i++) {
            for (int j=z - viewDist; j < z + viewDist; j++) {
              set.add(ChunkLocation.create(i,j));
            }
          }
        }
      }
      loadedChunks.retain(set);
      set=null;
    }
  }
);
}
Program: 11803
Project: 11803
Buggy source:
/** 
 * Inherits constructor from   {@link net.tridentsdk.server.entity.living.TridentLivingEntity}
 */
public TridentInventoryHolder(UUID id,Position spawnLocation){
  super(id,spawnLocation);
  BARRIER=new Object();
}

Fixed version (ground truth):
/** 
 * Inherits constructor from   {@link TridentLivingEntity}
 */
public TridentInventoryHolder(UUID id,Position spawnLocation){
  super(id,spawnLocation);
  BARRIER=new Object();
}
Program: 11804
Project: 11804
Buggy source:
@Override public void show(Entity entity){
  PacketPlayOutSpawnMob packet=new PacketPlayOutSpawnMob();
  packet.set("String_Node_Str",entity.entityId()).set("String_Node_Str",entity).set("String_Node_Str",((TridentEntity)entity).protocolMeta);
  if (this instanceof Player) {
    ((TridentPlayer)this).connection().sendPacket(packet);
  }
}

Fixed version (ground truth):
@Override public void show(Entity entity){
  PacketPlayOutSpawnMob packet=new PacketPlayOutSpawnMob();
  ProtocolMetadata protocolMeta=new ProtocolMetadata();
  ((TridentEntity)entity).encodeMetadata(protocolMeta);
  packet.set("String_Node_Str",entity.entityId()).set("String_Node_Str",entity).set("String_Node_Str",protocolMeta);
  if (this instanceof Player) {
    ((TridentPlayer)this).connection().sendPacket(packet);
  }
}
Program: 11805
Project: 11805
Buggy source:
@Override public void show(Entity entity){
  PacketPlayOutSpawnMob packet=new PacketPlayOutSpawnMob();
  ProtocolMetadata protocolMeta=new ProtocolMetadata();
  ((TridentEntity)entity).encodeMetadata(protocolMeta);
  packet.set("String_Node_Str",entity.entityId()).set("String_Node_Str",entity).set("String_Node_Str",((TridentEntity)entity).protocolMeta);
  if (this instanceof Player) {
    ((TridentPlayer)this).connection().sendPacket(packet);
  }
}

Fixed version (ground truth):
@Override public void show(Entity entity){
  PacketPlayOutSpawnMob packet=new PacketPlayOutSpawnMob();
  ProtocolMetadata protocolMeta=new ProtocolMetadata();
  ((TridentEntity)entity).encodeMetadata(protocolMeta);
  packet.set("String_Node_Str",entity.entityId()).set("String_Node_Str",entity).set("String_Node_Str",protocolMeta);
  if (this instanceof Player) {
    ((TridentPlayer)this).connection().sendPacket(packet);
  }
}
Program: 11806
Project: 11806
Buggy source:
void clear(){
  for (  ChunkSection section : sections) {
    section.clear();
  }
  executor.addTask(new Runnable(){
    @Override public void run(){
      sections=null;
    }
  }
);
  try {
    data.flush();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
void clear(){
  for (  ChunkSection section : sections) {
    section.clear();
  }
  executor.addTask(new Runnable(){
    @Override public void run(){
      sections=null;
    }
  }
);
}
Program: 11808
Project: 11808
Buggy source:
private RegionFile(Path path) throws IOException {
  this.path=path;
synchronized (this.readWriteLock) {
    RandomAccessFile access;
    if (!Files.isRegularFile(path)) {
      Files.deleteIfExists(path);
      Files.createFile(path);
      access=new RandomAccessFile(path.toFile(),"String_Node_Str");
      this.createNew(access);
    }
 else {
      access=new RandomAccessFile(path.toFile(),"String_Node_Str");
    }
    if (access.length() < 8192L) {
      access.seek(access.length());
      long diff=8192L - access.length();
      for (long l=0L; l < diff; l++) {
        access.write(0);
      }
    }
    this.packFile(access);
    access.seek(0L);
    int[] offsets=new int[1024];
    for (int i=0; i < offsets.length; i++) {
      offsets[i]=access.readInt();
    }
    this.sectors=new SectorStorage(offsets);
    access.close();
  }
}

Fixed version (ground truth):
private RegionFile(Path path) throws IOException {
  this.path=path;
synchronized (this.readWriteLock) {
    RandomAccessFile access;
    if (!Files.isRegularFile(path) || !path.toFile().exists()) {
      Files.deleteIfExists(path);
      Files.createFile(path);
      access=new RandomAccessFile(path.toFile(),"String_Node_Str");
      this.createNew(access);
    }
 else {
      access=new RandomAccessFile(path.toFile(),"String_Node_Str");
    }
    if (access.length() < 8192L) {
      access.seek(access.length());
      long diff=8192L - access.length();
      for (long l=0L; l < diff; l++) {
        access.write(0);
      }
    }
    this.packFile(access);
    access.seek(0L);
    int[] offsets=new int[1024];
    for (int i=0; i < offsets.length; i++) {
      offsets[i]=access.readInt();
    }
    this.sectors=new SectorStorage(offsets);
    access.close();
  }
}
Program: 11809
Project: 11809
Buggy source:
@Override public void run(){
  redstoneTick=!redstoneTick;
  if (time >= 2400)   time=0;
  if (time % 40 == 0)   rainTime--;
  thunderTime--;
  if (rainTime <= 0) {
    raining=!raining;
    rainTime=ThreadLocalRandom.current().nextInt();
  }
  if (thunderTime <= 0) {
    thundering=!thundering;
    thunderTime=ThreadLocalRandom.current().nextInt();
  }
  time++;
  existed++;
  if (time % 600 == 0) {
    Set<ChunkLocation> set=Sets.newHashSet();
    for (    Entity entity : entities) {
      if (entity instanceof Player) {
        Position pos=entity.location();
        int x=(int)pos.x() % 16;
        int z=(int)pos.z() % 16;
        int viewDist=Trident.config().getInt("String_Node_Str",7);
        for (int i=x - viewDist; i < x + viewDist; i++) {
          for (int j=z - viewDist; j < z + viewDist; j++) {
            set.add(ChunkLocation.create(i,j));
          }
        }
      }
    }
    loadedChunks.retain(set);
    set=null;
  }
}

Fixed version (ground truth):
@Override public void run(){
  redstoneTick=!redstoneTick;
  if (time >= 2400)   time=0;
  if (time % 40 == 0)   TridentPlayer.sendAll(new PacketPlayOutTimeUpdate().set("String_Node_Str",existed).set("String_Node_Str",time));
  rainTime--;
  thunderTime--;
  if (rainTime <= 0) {
    raining=!raining;
    rainTime=ThreadLocalRandom.current().nextInt();
  }
  if (thunderTime <= 0) {
    thundering=!thundering;
    thunderTime=ThreadLocalRandom.current().nextInt();
  }
  time++;
  existed++;
  if (time % 600 == 0) {
    Set<ChunkLocation> set=Sets.newHashSet();
    for (    Entity entity : entities) {
      if (entity instanceof Player) {
        Position pos=entity.location();
        int x=(int)pos.x() % 16;
        int z=(int)pos.z() % 16;
        int viewDist=Trident.config().getInt("String_Node_Str",7);
        for (int i=x - viewDist; i < x + viewDist; i++) {
          for (int j=z - viewDist; j < z + viewDist; j++) {
            set.add(ChunkLocation.create(i,j));
          }
        }
      }
    }
    loadedChunks.retain(set);
    set=null;
  }
}
Program: 11811
Project: 11811
Buggy source:
public void tick(){
  ThreadsHandler.worldExecutor().execute(new Runnable(){
    @Override public void run(){
      redstoneTick=!redstoneTick;
      if (time >= 2400)       time=0;
      if (time % 40 == 0)       rainTime--;
      thunderTime--;
      if (rainTime <= 0) {
        raining=!raining;
        rainTime=ThreadLocalRandom.current().nextInt();
      }
      if (thunderTime <= 0) {
        thundering=!thundering;
        thunderTime=ThreadLocalRandom.current().nextInt();
      }
      time++;
      existed++;
      if (time % 600 == 0) {
        Set<ChunkLocation> set=Sets.newHashSet();
        for (        Entity entity : entities) {
          if (entity instanceof Player) {
            Position pos=entity.location();
            int x=(int)pos.x() % 16;
            int z=(int)pos.z() % 16;
            int viewDist=Trident.config().getInt("String_Node_Str",7);
            for (int i=x - viewDist; i < x + viewDist; i++) {
              for (int j=z - viewDist; j < z + viewDist; j++) {
                set.add(ChunkLocation.create(i,j));
              }
            }
          }
        }
        loadedChunks.retain(set);
        set=null;
      }
    }
  }
);
}

Fixed version (ground truth):
public void tick(){
  ThreadsHandler.worldExecutor().execute(new Runnable(){
    @Override public void run(){
      redstoneTick=!redstoneTick;
      if (time >= 2400)       time=0;
      if (time % 40 == 0)       TridentPlayer.sendAll(new PacketPlayOutTimeUpdate().set("String_Node_Str",existed).set("String_Node_Str",time));
      rainTime--;
      thunderTime--;
      if (rainTime <= 0) {
        raining=!raining;
        rainTime=ThreadLocalRandom.current().nextInt();
      }
      if (thunderTime <= 0) {
        thundering=!thundering;
        thunderTime=ThreadLocalRandom.current().nextInt();
      }
      time++;
      existed++;
      if (time % 600 == 0) {
        Set<ChunkLocation> set=Sets.newHashSet();
        for (        Entity entity : entities) {
          if (entity instanceof Player) {
            Position pos=entity.location();
            int x=(int)pos.x() % 16;
            int z=(int)pos.z() % 16;
            int viewDist=Trident.config().getInt("String_Node_Str",7);
            for (int i=x - viewDist; i < x + viewDist; i++) {
              for (int j=z - viewDist; j < z + viewDist; j++) {
                set.add(ChunkLocation.create(i,j));
              }
            }
          }
        }
        loadedChunks.retain(set);
        set=null;
      }
    }
  }
);
}