forked from SteamWar/SteamWar
Fight FightWorld
This commit is contained in:
@@ -20,15 +20,19 @@
|
||||
package de.steamwar.misslewars;
|
||||
|
||||
import de.steamwar.core.CraftbukkitWrapper;
|
||||
import net.minecraft.world.level.chunk.Chunk;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.ObjIntConsumer;
|
||||
|
||||
public class FightWorld {
|
||||
@@ -71,10 +75,14 @@ public class FightWorld {
|
||||
}
|
||||
|
||||
private static void resetChunk(World world, World backup, int x, int z) {
|
||||
Chunk chunk = ((CraftWorld) world).getHandle().d(x, z);
|
||||
Chunk backupChunk = ((CraftWorld) backup).getHandle().d(x, z);
|
||||
|
||||
System.arraycopy(backupChunk.d(), 0, chunk.d(), 0, chunk.d().length);
|
||||
LevelChunk worldChunk = ((CraftWorld) world).getHandle().getChunk(x, z);
|
||||
LevelChunk backupChunk = ((CraftWorld) backup).getHandle().getChunk(x, z);
|
||||
LevelChunkSection[] sections = worldChunk.getSections();
|
||||
System.arraycopy(backupChunk.getSections(), 0, sections, 0, sections.length);
|
||||
Set<BlockPos> blocks = new HashSet<>(worldChunk.blockEntities.keySet());
|
||||
blocks.stream().filter(key -> !backupChunk.blockEntities.containsKey(key)).forEach(worldChunk::removeBlockEntity);
|
||||
worldChunk.heightmaps.clear();
|
||||
worldChunk.heightmaps.putAll(backupChunk.heightmaps);
|
||||
|
||||
for(Player p : Bukkit.getOnlinePlayers())
|
||||
CraftbukkitWrapper.impl.sendChunk(p, x, z);
|
||||
|
||||
Reference in New Issue
Block a user