Skip to content
Permalink
Browse files

More work on arrangers.

  • Loading branch information...
kenzierocks committed Jul 23, 2019
1 parent 986df91 commit f3972335f572b12ca1146205b4bdba4ec0e8195a
Showing with 1,955 additions and 931 deletions.
  1. +12 −4 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java
  2. +92 −57 worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java
  3. +103 −0 worldedit-core/src/main/java/com/sk89q/worldedit/action/BlockPlacement.java
  4. +34 −0 worldedit-core/src/main/java/com/sk89q/worldedit/action/BlockWorldAction.java
  5. +48 −0 worldedit-core/src/main/java/com/sk89q/worldedit/action/ChunkLoad.java
  6. +51 −0 worldedit-core/src/main/java/com/sk89q/worldedit/action/ChunkRelight.java
  7. +34 −0 worldedit-core/src/main/java/com/sk89q/worldedit/action/ChunkWorldAction.java
  8. +90 −0 worldedit-core/src/main/java/com/sk89q/worldedit/action/PerformSideEffects.java
  9. +63 −0 worldedit-core/src/main/java/com/sk89q/worldedit/action/SideEffect.java
  10. +39 −0 worldedit-core/src/main/java/com/sk89q/worldedit/action/WorldAction.java
  11. +101 −0 worldedit-core/src/main/java/com/sk89q/worldedit/extent/ArrangerExtent.java
  12. +0 −119 worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/ChunkBatchingExtent.java
  13. +0 −279 worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java
  14. +4 −0 worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/ReorderingExtent.java
  15. +0 −70 worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java
  16. +0 −156 worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java
  17. +2 −2 worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/SetBlockMap.java
  18. +89 −0 worldedit-core/src/main/java/com/sk89q/worldedit/reorder/ChunkBatchingArranger.java
  19. +61 −0 worldedit-core/src/main/java/com/sk89q/worldedit/reorder/ChunkLoadingArranger.java
  20. +96 −0 worldedit-core/src/main/java/com/sk89q/worldedit/reorder/DelayedLightingArranger.java
  21. +59 −0 worldedit-core/src/main/java/com/sk89q/worldedit/reorder/FastModeArranger.java
  22. +76 −0 worldedit-core/src/main/java/com/sk89q/worldedit/reorder/FastReorderArranger.java
  23. +245 −0 worldedit-core/src/main/java/com/sk89q/worldedit/reorder/MultiStageReorderArranger.java
  24. +15 −9 worldedit-core/src/main/java/com/sk89q/worldedit/reorder/arrange/Arranger.java
  25. +32 −0 worldedit-core/src/main/java/com/sk89q/worldedit/reorder/arrange/ArrangerContext.java
  26. +89 −0 worldedit-core/src/main/java/com/sk89q/worldedit/reorder/arrange/ArrangerContextImpl.java
  27. +0 −78 worldedit-core/src/main/java/com/sk89q/worldedit/reorder/arrange/ArrangerPipelineImpl.java
  28. +37 −0 worldedit-core/src/main/java/com/sk89q/worldedit/reorder/arrange/AttributeKey.java
  29. +52 −0 worldedit-core/src/main/java/com/sk89q/worldedit/reorder/arrange/DelegatingArranger.java
  30. +17 −21 ...c/main/java/com/sk89q/worldedit/reorder/arrange/{ArrangerPipeline.java → ForwardingArranger.java}
  31. +66 −0 worldedit-core/src/main/java/com/sk89q/worldedit/reorder/arrange/OptionalArranger.java
  32. +53 −0 worldedit-core/src/main/java/com/sk89q/worldedit/reorder/arrange/SimpleAttributeKey.java
  33. +15 −5 ...a/com/sk89q/worldedit/reorder/arrange/{PlacementOutputStream.java → WorldActionOutputStream.java}
  34. +52 −0 worldedit-core/src/main/java/com/sk89q/worldedit/reorder/arrange/WorldArranger.java
  35. +45 −44 .../worldedit/reorder/buffer/{MutableArrayPlacementBuffer.java → MutableArrayWorldActionBuffer.java}
  36. +14 −14 .../com/sk89q/worldedit/reorder/buffer/{MutablePlacementBuffer.java → MutableWorldActionBuffer.java}
  37. +19 −19 ...orldedit/reorder/buffer/{ReadOnlyArrayPlacementBuffer.java → ReadOnlyArrayWorldActionBuffer.java}
  38. +1 −1 ...om/sk89q/worldedit/reorder/buffer/{ReadOnlyPlacementBuffer.java → ReadOnlyWorldActionBuffer.java}
  39. +9 −9 ...9q/worldedit/reorder/buffer/{SharedArrayPlacementBuffer.java → SharedArrayWorldActionBuffer.java}
  40. +16 −16 .../src/main/java/com/sk89q/worldedit/reorder/buffer/{PlacementBuffer.java → WorldActionBuffer.java}
  41. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/LocatedBlockList.java
  42. +2 −1 worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java
  43. +5 −4 worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java
  44. +39 −4 worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java
  45. +1 −1 worldedit-core/src/test/java/com/sk89q/worldedit/util/collection/BlockMapTest.java
  46. +36 −10 worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricWorld.java
  47. +40 −7 worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java
@@ -22,6 +22,7 @@
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.action.SideEffect;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
@@ -55,6 +56,7 @@
import java.lang.ref.WeakReference;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
@@ -437,7 +439,9 @@ public void simulateBlockMine(BlockVector3 pt) {
}

@Override
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws WorldEditException {
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, Collection<SideEffect> sideEffects) throws WorldEditException {
// TODO re-write adapter
boolean notifyAndLight = sideEffects.contains(SideEffect.LIGHT) && sideEffects.contains(SideEffect.NOTIFY_NEIGHBORS);
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
if (adapter != null) {
try {
@@ -470,11 +474,15 @@ public BaseBlock getFullBlock(BlockVector3 position) {
}

@Override
public boolean notifyAndLightBlock(BlockVector3 position, com.sk89q.worldedit.world.block.BlockState previousType) throws WorldEditException {
public boolean applySideEffects(BlockVector3 position, com.sk89q.worldedit.world.block.BlockState previousType, Collection<SideEffect> sideEffects) throws WorldEditException {
// TODO re-write adapter
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
if (adapter != null) {
adapter.notifyAndLightBlock(BukkitAdapter.adapt(getWorld(), position), previousType);
return true;
boolean notifyAndLight = sideEffects.contains(SideEffect.LIGHT) && sideEffects.contains(SideEffect.NOTIFY_NEIGHBORS);
if (notifyAndLight) {
adapter.notifyAndLightBlock(BukkitAdapter.adapt(getWorld(), position), previousType);
return true;
}
}

return false;

Large diffs are not rendered by default.

@@ -0,0 +1,103 @@
/*
* 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.action;

import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock;

import java.util.Collection;
import java.util.Objects;

import static com.google.common.base.Preconditions.checkNotNull;

/**
* Represents the placement of a block.
*/
public final class BlockPlacement implements BlockWorldAction {

public static BlockPlacement create(BlockVector3 location, BaseBlock oldBlock, BaseBlock block) {
return create(location, oldBlock, block, SideEffect.getDefault());
}

public static BlockPlacement create(BlockVector3 location, BaseBlock oldBlock, BaseBlock block, Collection<SideEffect> sideEffects) {
return new BlockPlacement(location, oldBlock, block, sideEffects);
}

private final BlockVector3 position;
private final BaseBlock oldBlock;
private final BaseBlock block;
private final ImmutableSet<SideEffect> sideEffects;

private BlockPlacement(BlockVector3 position, BaseBlock oldBlock, BaseBlock block, Collection<SideEffect> sideEffects) {
this.position = checkNotNull(position);
this.oldBlock = oldBlock;
this.block = checkNotNull(block);
this.sideEffects = Sets.immutableEnumSet(sideEffects);
}

@Override
public BlockVector3 getPosition() {
return position;
}

public BaseBlock getOldBlock() {
return oldBlock;
}

public BaseBlock getBlock() {
return block;
}

public ImmutableSet<SideEffect> getSideEffects() {
return sideEffects;
}

public BlockPlacement withSideEffects(Collection<SideEffect> sideEffects) {
return new BlockPlacement(position, oldBlock, block, sideEffects);
}

@Override
public void apply(World world) throws WorldEditException {
world.setBlock(position, block, sideEffects);
}

@Override
public int hashCode() {
return Objects.hash(position, block, sideEffects);
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (this.getClass() != obj.getClass()) {
return false;
}
BlockPlacement p = (BlockPlacement) obj;
return Objects.equals(position, p.position) && Objects.equals(block, p.block)
&& Objects.equals(sideEffects, p.sideEffects);
}

}
@@ -0,0 +1,34 @@
/*
* 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.action;

import com.sk89q.worldedit.math.BlockVector3;

/**
* An action that affects a single block.
*/
public interface BlockWorldAction extends WorldAction {

/**
* The position of the block this action affects.
*/
BlockVector3 getPosition();

}
@@ -0,0 +1,48 @@
/*
* 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.action;

import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.world.World;

public class ChunkLoad implements ChunkWorldAction {

public static ChunkLoad create(BlockVector2 position) {
return new ChunkLoad(position);
}

private final BlockVector2 position;

private ChunkLoad(BlockVector2 position) {
this.position = position;
}

@Override
public BlockVector2 getPosition() {
return position;
}

@Override
public void apply(World world) throws WorldEditException {
world.checkLoadedChunk(position.toBlockVector3().shl(4));
}

}
@@ -0,0 +1,51 @@
/*
* 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.action;

import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.world.World;

/**
* Re-light the given chunk.
*/
public class ChunkRelight implements ChunkWorldAction {

public static ChunkRelight create(BlockVector2 position) {
return new ChunkRelight(position);
}

private final BlockVector2 position;

private ChunkRelight(BlockVector2 position) {
this.position = position;
}

@Override
public BlockVector2 getPosition() {
return position;
}

@Override
public void apply(World world) throws WorldEditException {
world.fixLighting(ImmutableList.of(position));
}
}
@@ -0,0 +1,34 @@
/*
* 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.action;

import com.sk89q.worldedit.math.BlockVector2;

/**
* An action that affects a single chunk.
*/
public interface ChunkWorldAction extends WorldAction {

/**
* The position of the chunk this action affects.
*/
BlockVector2 getPosition();

}

0 comments on commit f397233

Please sign in to comment.
You can’t perform that action at this time.