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;
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.io.ClipboardFormats;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock;
import net.minecraft.server.v1_15_R1.BlockPosition;
import net.minecraft.server.v1_15_R1.WorldServer;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.session.ClipboardHolder;
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.FileInputStream;
@ -31,30 +30,18 @@ public class Region_15 {
BlockVector3 dimensions = clipboard.getDimensions();
BlockVector3 v = BlockVector3.at(x, y, z);
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
AffineTransform aT = new AffineTransform();
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);
}else{
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();
v = v.add(offset);
for(int X = v.getBlockX(); X < v.getBlockX() + dimensions.getBlockX(); X++){
for(int Y = v.getBlockY(); Y < v.getBlockY() + dimensions.getBlockY(); Y++){
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);
}
}
}
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1);
ClipboardHolder ch = new ClipboardHolder(clipboard);
ch.setTransform(aT);
Operations.completeBlindly(ch.createPaste(e).to(v).build());
e.flushSession();
}
}