3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-09 13:00:05 +01:00

Current progress #4

Dieser Commit ist enthalten in:
IronApollo 2019-01-09 03:32:38 -05:00
Ursprung 842b1307c7
Commit a9919d130c
12 geänderte Dateien mit 260 neuen und 35 gelöschten Zeilen

Datei anzeigen

@ -72,4 +72,16 @@ public class NullChangeSet extends FaweChangeSet {
public final int size() { public final int size() {
return 0; return 0;
} }
@Override
public boolean isRecordingChanges() {
// TODO Auto-generated method stub
return false;
}
@Override
public void setRecordChanges(boolean recordChanges) {
// TODO Auto-generated method stub
}
} }

Datei anzeigen

@ -172,4 +172,16 @@ public class AbstractDelegateChangeSet extends FaweChangeSet {
public void add(int x, int y, int z, int combinedFrom, BaseBlock to) { public void add(int x, int y, int z, int combinedFrom, BaseBlock to) {
parent.add(x, y, z, combinedFrom, to); parent.add(x, y, z, combinedFrom, to);
} }
@Override
public boolean isRecordingChanges() {
// TODO Auto-generated method stub
return false;
}
@Override
public void setRecordChanges(boolean recordChanges) {
// TODO Auto-generated method stub
}
} }

Datei anzeigen

@ -102,4 +102,16 @@ public class AnvilHistory extends FaweChangeSet implements IAnvilHistory {
public int size() { public int size() {
return size == -1 ? folder.listFiles().length : size; return size == -1 ? folder.listFiles().length : size;
} }
@Override
public boolean isRecordingChanges() {
// TODO Auto-generated method stub
return false;
}
@Override
public void setRecordChanges(boolean recordChanges) {
// TODO Auto-generated method stub
}
} }

Datei anzeigen

@ -78,4 +78,16 @@ public class CFIChangeSet extends FaweChangeSet {
public int size() { public int size() {
return 1; return 1;
} }
@Override
public boolean isRecordingChanges() {
// TODO Auto-generated method stub
return false;
}
@Override
public void setRecordChanges(boolean recordChanges) {
// TODO Auto-generated method stub
}
} }

Datei anzeigen

@ -107,4 +107,16 @@ public class CPUOptimizedChangeSet extends FaweChangeSet {
public int size() { public int size() {
return changes.size() * 65536; // num chunks * 65536 (guess of 65536 changes per chunk) return changes.size() * 65536; // num chunks * 65536 (guess of 65536 changes per chunk)
} }
@Override
public boolean isRecordingChanges() {
// TODO Auto-generated method stub
return false;
}
@Override
public void setRecordChanges(boolean recordChanges) {
// TODO Auto-generated method stub
}
} }

Datei anzeigen

@ -509,4 +509,16 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
return count; return count;
} }
} }
@Override
public boolean isRecordingChanges() {
// TODO Auto-generated method stub
return false;
}
@Override
public void setRecordChanges(boolean recordChanges) {
// TODO Auto-generated method stub
}
} }

Datei anzeigen

@ -238,4 +238,16 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
public NBTInputStream getTileRemoveIS() throws IOException { public NBTInputStream getTileRemoveIS() throws IOException {
return tileR == null ? null : new NBTInputStream(MainUtil.getCompressedIS(new FastByteArraysInputStream(tileR))); return tileR == null ? null : new NBTInputStream(MainUtil.getCompressedIS(new FastByteArraysInputStream(tileR)));
} }
@Override
public boolean isRecordingChanges() {
// TODO Auto-generated method stub
return false;
}
@Override
public void setRecordChanges(boolean recordChanges) {
// TODO Auto-generated method stub
}
} }

Datei anzeigen

@ -29,9 +29,10 @@ import com.sk89q.worldedit.function.operation.BlockMapEntryPlacer;
import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.OperationQueue; import com.sk89q.worldedit.function.operation.OperationQueue;
import com.sk89q.worldedit.function.operation.RunContext; import com.sk89q.worldedit.function.operation.RunContext;
import com.sk89q.worldedit.function.operation.SetLocatedBlocks; //import com.sk89q.worldedit.function.operation.SetLocatedBlocks;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.LocatedBlock;
import com.sk89q.worldedit.util.collection.TupleArrayList; import com.sk89q.worldedit.util.collection.TupleArrayList;
import com.sk89q.worldedit.world.block.BlockCategories; import com.sk89q.worldedit.world.block.BlockCategories;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -51,9 +52,9 @@ import java.util.Set;
*/ */
public class MultiStageReorder extends AbstractDelegateExtent implements ReorderingExtent { public class MultiStageReorder extends AbstractDelegateExtent implements ReorderingExtent {
private TupleArrayList<BlockVector, BlockStateHolder> stage1 = new TupleArrayList<>(); private TupleArrayList<BlockVector3, BlockStateHolder> stage1 = new TupleArrayList<>();
private TupleArrayList<BlockVector, BlockStateHolder> stage2 = new TupleArrayList<>(); private TupleArrayList<BlockVector3, BlockStateHolder> stage2 = new TupleArrayList<>();
private TupleArrayList<BlockVector, BlockStateHolder> stage3 = new TupleArrayList<>(); private TupleArrayList<BlockVector3, BlockStateHolder> stage3 = new TupleArrayList<>();
private boolean enabled; private boolean enabled;
/** /**
@ -95,13 +96,8 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
} }
@Override @Override
<<<<<<< HEAD
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
BlockStateHolder existing = getBlock(location);
=======
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
BlockState existing = getBlock(location); BlockState existing = getBlock(location);
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
if (!enabled) { if (!enabled) {
return super.setBlock(location, block); return super.setBlock(location, block);
@ -109,30 +105,30 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
if (Blocks.shouldPlaceLast(block.getBlockType())) { if (Blocks.shouldPlaceLast(block.getBlockType())) {
// Place torches, etc. last // Place torches, etc. last
<<<<<<< HEAD //<<<<<<< HEAD
stage2.put(location.toBlockVector(), block); stage2.put(location, block);
return !existing.equalsFuzzy(block); return !existing.equalsFuzzy(block);
} else if (Blocks.shouldPlaceFinal(block.getBlockType())) { } else if (Blocks.shouldPlaceFinal(block.getBlockType())) {
// Place signs, reed, etc even later // Place signs, reed, etc even later
stage3.put(location.toBlockVector(), block); stage3.put(location, block);
======= //=======
stage2.add(location, block); // stage2.add(location, block);
return !existing.equalsFuzzy(block); // return !existing.equalsFuzzy(block);
} else if (Blocks.shouldPlaceFinal(block.getBlockType())) { // } else if (Blocks.shouldPlaceFinal(block.getBlockType())) {
// Place signs, reed, etc even later // // Place signs, reed, etc even later
stage3.add(location, block); // stage3.add(location, block);
>>>>>>> 399e0ad5... Refactor vector system to be cleaner //>>>>>>> 399e0ad5... Refactor vector system to be cleaner
return !existing.equalsFuzzy(block); return !existing.equalsFuzzy(block);
} else if (Blocks.shouldPlaceLast(existing.getBlockType())) { } else if (Blocks.shouldPlaceLast(existing.getBlockType())) {
// Destroy torches, etc. first // Destroy torches, etc. first
super.setBlock(location, BlockTypes.AIR.getDefaultState()); super.setBlock(location, BlockTypes.AIR.getDefaultState());
return super.setBlock(location, block); return super.setBlock(location, block);
} else { } else {
<<<<<<< HEAD //<<<<<<< HEAD
stage1.put(location.toBlockVector(), block); stage1.put(location, block);
======= //=======
stage1.add(location, block); // stage1.add(location, block);
>>>>>>> 399e0ad5... Refactor vector system to be cleaner //>>>>>>> 399e0ad5... Refactor vector system to be cleaner
return !existing.equalsFuzzy(block); return !existing.equalsFuzzy(block);
} }
} }
@ -152,17 +148,17 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
public Operation resume(RunContext run) throws WorldEditException { public Operation resume(RunContext run) throws WorldEditException {
Extent extent = getExtent(); Extent extent = getExtent();
<<<<<<< HEAD //<<<<<<< HEAD
final Set<BlockVector> blocks = new HashSet<>();
final Map<BlockVector, BlockStateHolder> blockTypes = new HashMap<>();
for (Map.Entry<BlockVector, BlockStateHolder> entry : stage3) {
final BlockVector pt = entry.getKey();
=======
final Set<BlockVector3> blocks = new HashSet<>(); final Set<BlockVector3> blocks = new HashSet<>();
final Map<BlockVector3, BlockStateHolder> blockTypes = new HashMap<>(); final Map<BlockVector3, BlockStateHolder> blockTypes = new HashMap<>();
for (LocatedBlock entry : stage3) { for (Map.Entry<BlockVector3, BlockStateHolder> entry : stage3) {
final BlockVector3 pt = entry.getLocation(); final BlockVector3 pt = entry.getKey();
>>>>>>> 399e0ad5... Refactor vector system to be cleaner //=======
// final Set<BlockVector3> blocks = new HashSet<>();
// final Map<BlockVector3, BlockStateHolder> blockTypes = new HashMap<>();
// for (LocatedBlock entry : stage3) {
// final BlockVector3 pt = entry.getLocation();
//>>>>>>> 399e0ad5... Refactor vector system to be cleaner
blocks.add(pt); blocks.add(pt);
blockTypes.put(pt, entry.getValue()); blockTypes.put(pt, entry.getValue());
} }

Datei anzeigen

@ -0,0 +1,56 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.function.operation;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.util.LocatedBlock;
import java.util.List;
public class SetLocatedBlocks implements Operation {
private final Extent extent;
private final Iterable<LocatedBlock> blocks;
public SetLocatedBlocks(Extent extent, Iterable<LocatedBlock> blocks) {
this.extent = checkNotNull(extent);
this.blocks = checkNotNull(blocks);
}
@Override
public Operation resume(RunContext run) throws WorldEditException {
for (LocatedBlock block : blocks) {
extent.setBlock(block.getLocation(), block.getBlock());
}
return null;
}
@Override
public void cancel() {
}
@Override
public void addStatusMessages(List<String> messages) {
}
}

Datei anzeigen

@ -0,0 +1,73 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.history.changeset;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Lists;
import com.sk89q.worldedit.history.change.Change;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* Stores all {@link Change}s in an {@link ArrayList}.
*/
public class ArrayListHistory implements ChangeSet {
private final List<Change> changes = new ArrayList<>();
private boolean recordChanges = true;
@Override
public void add(Change change) {
checkNotNull(change);
if (recordChanges) {
changes.add(change);
}
}
@Override
public boolean isRecordingChanges() {
return recordChanges;
}
@Override
public void setRecordChanges(boolean recordChanges) {
this.recordChanges = recordChanges;
}
@Override
public Iterator<Change> backwardIterator() {
return Lists.reverse(changes).iterator();
}
@Override
public Iterator<Change> forwardIterator() {
return changes.iterator();
}
@Override
public int size() {
return changes.size();
}
}

Datei anzeigen

@ -36,6 +36,20 @@ public interface ChangeSet {
*/ */
void add(Change change); void add(Change change);
/**
* Whether or not the ChangeSet is recording changes.
*
* @return whether or not the ChangeSet is set to record changes
*/
boolean isRecordingChanges();
/**
* Tell the change set whether to record changes or not.
*
* @param recordChanges whether to record changes or not
*/
void setRecordChanges(boolean recordChanges);
/** /**
* Get a backward directed iterator that can be used for undo. * Get a backward directed iterator that can be used for undo.
* *

Datei anzeigen

@ -27,6 +27,7 @@ import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
@ -150,6 +151,7 @@ public class ServerCUIHandler {
structureTag.put("showboundingbox", new ByteTag((byte) 1)); structureTag.put("showboundingbox", new ByteTag((byte) 1));
structureTag.put("id", new StringTag(BlockTypes.STRUCTURE_BLOCK.getId())); structureTag.put("id", new StringTag(BlockTypes.STRUCTURE_BLOCK.getId()));
return BlockTypes.STRUCTURE_BLOCK.getDefaultState().toBaseBlock(new CompoundTag(structureTag)); // return BlockTypes.STRUCTURE_BLOCK.getDefaultState().toBaseBlock(new CompoundTag(structureTag));
return new BaseBlock(BlockTypes.STRUCTURE_BLOCK.getDefaultState(), new CompoundTag(structureTag));
} }
} }