SteamWar/BauSystem
Archiviert
13
0

Revert "Speed /reset & /tb up"

This reverts commit 3082797a
Dieser Commit ist enthalten in:
Lixfel 2020-07-11 10:34:30 +02:00
Ursprung 83ab53aa91
Commit f9d5bc89e8

Datei anzeigen

@ -1,16 +1,15 @@
package de.steamwar.bausystem.world; package de.steamwar.bausystem.world;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.math.transform.AffineTransform;
import net.minecraft.server.v1_15_R1.BlockPosition; import com.sk89q.worldedit.session.ClipboardHolder;
import net.minecraft.server.v1_15_R1.WorldServer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -31,30 +30,18 @@ public class Region_15 {
BlockVector3 dimensions = clipboard.getDimensions(); BlockVector3 dimensions = clipboard.getDimensions();
BlockVector3 v = BlockVector3.at(x, y, z); BlockVector3 v = BlockVector3.at(x, y, z);
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
AffineTransform aT = new AffineTransform();
if(rotate){ if(rotate){
aT = aT.rotateY(180);
v = v.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1); v = v.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
}else{ }else{
v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset); v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
} }
WorldServer world = ((CraftWorld)Bukkit.getWorlds().get(0)).getHandle(); EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1);
v = v.add(offset); ClipboardHolder ch = new ClipboardHolder(clipboard);
ch.setTransform(aT);
for(int X = v.getBlockX(); X < v.getBlockX() + dimensions.getBlockX(); X++){ Operations.completeBlindly(ch.createPaste(e).to(v).build());
for(int Y = v.getBlockY(); Y < v.getBlockY() + dimensions.getBlockY(); Y++){ e.flushSession();
for(int Z = v.getBlockZ(); Z < v.getBlockZ() + dimensions.getBlockZ(); Z++){
BlockPosition blockPos = new BlockPosition(X, Y, Z);
BaseBlock fullBlock = clipboard.getFullBlock(BlockVector3.at(X, Y, Z).subtract(v).add(clipboard.getRegion().getMinimumPoint()));
Material replaceTo = BukkitAdapter.adapt(fullBlock.getBlockType());
world.removeTileEntity(blockPos);
if(replaceTo == null)
world.setTypeAndData(blockPos, ((CraftBlockData)Material.AIR.createBlockData()).getState(), 1042);
else
world.setTypeAndData(new BlockPosition(X, Y, Z), ((CraftBlockData)replaceTo.createBlockData()).getState(), 1042);
world.getChunkProvider().flagDirty(blockPos);
}
}
}
} }
} }