Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-17 00:20:09 +01:00
Adjustment for tall flowers - add capability to forcefully override block updates
Dieser Commit ist enthalten in:
Ursprung
f0f9316d76
Commit
aa63677135
@ -19,6 +19,7 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
public class PaperweightLevelProxy extends ServerLevel {
|
public class PaperweightLevelProxy extends ServerLevel {
|
||||||
|
|
||||||
|
protected ServerLevel serverLevel;
|
||||||
private PaperweightFaweAdapter adapter;
|
private PaperweightFaweAdapter adapter;
|
||||||
private PaperweightPlacementStateProcessor processor;
|
private PaperweightPlacementStateProcessor processor;
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ public class PaperweightLevelProxy extends ServerLevel {
|
|||||||
throw new IllegalStateException("Cannot be instantiated");
|
throw new IllegalStateException("Cannot be instantiated");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PaperweightLevelProxy getInstance(PaperweightPlacementStateProcessor processor) {
|
public static PaperweightLevelProxy getInstance(ServerLevel serverLevel, PaperweightPlacementStateProcessor processor) {
|
||||||
Unsafe unsafe = ReflectionUtils.getUnsafe();
|
Unsafe unsafe = ReflectionUtils.getUnsafe();
|
||||||
|
|
||||||
PaperweightLevelProxy newLevel;
|
PaperweightLevelProxy newLevel;
|
||||||
@ -39,6 +40,7 @@ public class PaperweightLevelProxy extends ServerLevel {
|
|||||||
}
|
}
|
||||||
newLevel.processor = processor;
|
newLevel.processor = processor;
|
||||||
newLevel.adapter = ((PaperweightFaweAdapter) WorldEditPlugin.getInstance().getBukkitImplAdapter());
|
newLevel.adapter = ((PaperweightFaweAdapter) WorldEditPlugin.getInstance().getBukkitImplAdapter());
|
||||||
|
newLevel.serverLevel = serverLevel;
|
||||||
return newLevel;
|
return newLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,4 +96,14 @@ public class PaperweightLevelProxy extends ServerLevel {
|
|||||||
return getBlockState(pos).getFluidState().is(FluidTags.WATER);
|
return getBlockState(pos).getFluidState().is(FluidTags.WATER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHeight() {
|
||||||
|
return serverLevel.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMinBuildHeight() {
|
||||||
|
return serverLevel.getMinBuildHeight();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R2;
|
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R2;
|
||||||
|
|
||||||
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
|
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
|
||||||
|
import com.fastasyncworldedit.core.util.ExtentTraverser;
|
||||||
|
import com.fastasyncworldedit.core.wrappers.WorldWrapper;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||||
@ -8,12 +11,14 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R2.CraftWorld;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -29,7 +34,18 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
|
|||||||
|
|
||||||
public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region region) {
|
public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region region) {
|
||||||
super(extent, mask, region);
|
super(extent, mask, region);
|
||||||
this.proxyLevel = PaperweightLevelProxy.getInstance(this);
|
World world = ExtentTraverser.getWorldFromExtent(extent);
|
||||||
|
if (world == null) {
|
||||||
|
throw new UnsupportedOperationException(
|
||||||
|
"World is required for PlacementStateProcessor but none found in given extent.");
|
||||||
|
}
|
||||||
|
BukkitWorld bukkitWorld;
|
||||||
|
if (world instanceof WorldWrapper wrapper) {
|
||||||
|
bukkitWorld = (BukkitWorld) wrapper.getParent();
|
||||||
|
} else {
|
||||||
|
bukkitWorld = (BukkitWorld) world;
|
||||||
|
}
|
||||||
|
this.proxyLevel = PaperweightLevelProxy.getInstance(((CraftWorld) bukkitWorld.getWorld()).getHandle(), this);
|
||||||
this.mutableBlockPlaceContext = new PaperweightFaweMutableBlockPlaceContext(proxyLevel);
|
this.mutableBlockPlaceContext = new PaperweightFaweMutableBlockPlaceContext(proxyLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +58,18 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
|
|||||||
AtomicBoolean finished
|
AtomicBoolean finished
|
||||||
) {
|
) {
|
||||||
super(extent, mask, crossChunkSecondPasses, threadProcessors, region, finished);
|
super(extent, mask, crossChunkSecondPasses, threadProcessors, region, finished);
|
||||||
this.proxyLevel = PaperweightLevelProxy.getInstance(this);
|
World world = ExtentTraverser.getWorldFromExtent(extent);
|
||||||
|
if (world == null) {
|
||||||
|
throw new UnsupportedOperationException(
|
||||||
|
"World is required for PlacementStateProcessor but none found in given extent.");
|
||||||
|
}
|
||||||
|
BukkitWorld bukkitWorld;
|
||||||
|
if (world instanceof WorldWrapper wrapper) {
|
||||||
|
bukkitWorld = (BukkitWorld) wrapper.getParent();
|
||||||
|
} else {
|
||||||
|
bukkitWorld = (BukkitWorld) world;
|
||||||
|
}
|
||||||
|
this.proxyLevel = PaperweightLevelProxy.getInstance(((CraftWorld) bukkitWorld.getWorld()).getHandle(), this);
|
||||||
this.mutableBlockPlaceContext = new PaperweightFaweMutableBlockPlaceContext(proxyLevel);
|
this.mutableBlockPlaceContext = new PaperweightFaweMutableBlockPlaceContext(proxyLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
public class PaperweightLevelProxy extends ServerLevel {
|
public class PaperweightLevelProxy extends ServerLevel {
|
||||||
|
|
||||||
|
protected ServerLevel serverLevel;
|
||||||
private PaperweightFaweAdapter adapter;
|
private PaperweightFaweAdapter adapter;
|
||||||
private PaperweightPlacementStateProcessor processor;
|
private PaperweightPlacementStateProcessor processor;
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ public class PaperweightLevelProxy extends ServerLevel {
|
|||||||
throw new IllegalStateException("Cannot be instantiated");
|
throw new IllegalStateException("Cannot be instantiated");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PaperweightLevelProxy getInstance(PaperweightPlacementStateProcessor processor) {
|
public static PaperweightLevelProxy getInstance(ServerLevel serverLevel, PaperweightPlacementStateProcessor processor) {
|
||||||
Unsafe unsafe = ReflectionUtils.getUnsafe();
|
Unsafe unsafe = ReflectionUtils.getUnsafe();
|
||||||
|
|
||||||
PaperweightLevelProxy newLevel;
|
PaperweightLevelProxy newLevel;
|
||||||
@ -39,6 +40,7 @@ public class PaperweightLevelProxy extends ServerLevel {
|
|||||||
}
|
}
|
||||||
newLevel.processor = processor;
|
newLevel.processor = processor;
|
||||||
newLevel.adapter = ((PaperweightFaweAdapter) WorldEditPlugin.getInstance().getBukkitImplAdapter());
|
newLevel.adapter = ((PaperweightFaweAdapter) WorldEditPlugin.getInstance().getBukkitImplAdapter());
|
||||||
|
newLevel.serverLevel = serverLevel;
|
||||||
return newLevel;
|
return newLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,4 +96,14 @@ public class PaperweightLevelProxy extends ServerLevel {
|
|||||||
return getBlockState(pos).getFluidState().is(FluidTags.WATER);
|
return getBlockState(pos).getFluidState().is(FluidTags.WATER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHeight() {
|
||||||
|
return serverLevel.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMinBuildHeight() {
|
||||||
|
return serverLevel.getMinBuildHeight();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R3;
|
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R3;
|
||||||
|
|
||||||
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
|
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
|
||||||
|
import com.fastasyncworldedit.core.util.ExtentTraverser;
|
||||||
|
import com.fastasyncworldedit.core.wrappers.WorldWrapper;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||||
@ -8,12 +11,14 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -29,7 +34,18 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
|
|||||||
|
|
||||||
public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region region) {
|
public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region region) {
|
||||||
super(extent, mask, region);
|
super(extent, mask, region);
|
||||||
this.proxyLevel = PaperweightLevelProxy.getInstance(this);
|
World world = ExtentTraverser.getWorldFromExtent(extent);
|
||||||
|
if (world == null) {
|
||||||
|
throw new UnsupportedOperationException(
|
||||||
|
"World is required for PlacementStateProcessor but none found in given extent.");
|
||||||
|
}
|
||||||
|
BukkitWorld bukkitWorld;
|
||||||
|
if (world instanceof WorldWrapper wrapper) {
|
||||||
|
bukkitWorld = (BukkitWorld) wrapper.getParent();
|
||||||
|
} else {
|
||||||
|
bukkitWorld = (BukkitWorld) world;
|
||||||
|
}
|
||||||
|
this.proxyLevel = PaperweightLevelProxy.getInstance(((CraftWorld) bukkitWorld.getWorld()).getHandle(), this);
|
||||||
this.mutableBlockPlaceContext = new PaperweightFaweMutableBlockPlaceContext(proxyLevel);
|
this.mutableBlockPlaceContext = new PaperweightFaweMutableBlockPlaceContext(proxyLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +58,18 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
|
|||||||
AtomicBoolean finished
|
AtomicBoolean finished
|
||||||
) {
|
) {
|
||||||
super(extent, mask, crossChunkSecondPasses, threadProcessors, region, finished);
|
super(extent, mask, crossChunkSecondPasses, threadProcessors, region, finished);
|
||||||
this.proxyLevel = PaperweightLevelProxy.getInstance(this);
|
World world = ExtentTraverser.getWorldFromExtent(extent);
|
||||||
|
if (world == null) {
|
||||||
|
throw new UnsupportedOperationException(
|
||||||
|
"World is required for PlacementStateProcessor but none found in given extent.");
|
||||||
|
}
|
||||||
|
BukkitWorld bukkitWorld;
|
||||||
|
if (world instanceof WorldWrapper wrapper) {
|
||||||
|
bukkitWorld = (BukkitWorld) wrapper.getParent();
|
||||||
|
} else {
|
||||||
|
bukkitWorld = (BukkitWorld) world;
|
||||||
|
}
|
||||||
|
this.proxyLevel = PaperweightLevelProxy.getInstance(((CraftWorld) bukkitWorld.getWorld()).getHandle(), this);
|
||||||
this.mutableBlockPlaceContext = new PaperweightFaweMutableBlockPlaceContext(proxyLevel);
|
this.mutableBlockPlaceContext = new PaperweightFaweMutableBlockPlaceContext(proxyLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,4 +96,14 @@ public class PaperweightLevelProxy extends ServerLevel {
|
|||||||
return getBlockState(pos).getFluidState().is(FluidTags.WATER);
|
return getBlockState(pos).getFluidState().is(FluidTags.WATER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHeight() {
|
||||||
|
return serverLevel.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMinBuildHeight() {
|
||||||
|
return serverLevel.getMinBuildHeight();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -96,4 +96,14 @@ public class PaperweightLevelProxy extends ServerLevel {
|
|||||||
return getBlockState(pos).getFluidState().is(FluidTags.WATER);
|
return getBlockState(pos).getFluidState().is(FluidTags.WATER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHeight() {
|
||||||
|
return serverLevel.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMinBuildHeight() {
|
||||||
|
return serverLevel.getMinBuildHeight();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -392,6 +392,10 @@ public abstract class PlacementStateProcessor extends AbstractDelegateExtent imp
|
|||||||
}
|
}
|
||||||
|
|
||||||
private char getBlockOrdinal(int blockX, int blockY, int blockZ, BlockState state) {
|
private char getBlockOrdinal(int blockX, int blockY, int blockZ, BlockState state) {
|
||||||
|
char override = getOverrideBlockOrdinal(blockX, blockY, blockZ, state);
|
||||||
|
if (override != BlockTypesCache.ReservedIDs.__RESERVED__) {
|
||||||
|
return override;
|
||||||
|
}
|
||||||
EnumSet<Direction> dirs = Direction.getDirections(state);
|
EnumSet<Direction> dirs = Direction.getDirections(state);
|
||||||
Direction clickedFaceDirection = null; // This should be always be set by the below.
|
Direction clickedFaceDirection = null; // This should be always be set by the below.
|
||||||
Set<String> states = state.getStates().keySet().stream().map(Property::getName).collect(Collectors.toSet());
|
Set<String> states = state.getStates().keySet().stream().map(Property::getName).collect(Collectors.toSet());
|
||||||
@ -436,6 +440,17 @@ public abstract class PlacementStateProcessor extends AbstractDelegateExtent imp
|
|||||||
return getStateAtFor(blockX, blockY, blockZ, state, clickPos, clickedFaceDirection, clickedBlock);
|
return getStateAtFor(blockX, blockY, blockZ, state, clickPos, clickedFaceDirection, clickedBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected char getOverrideBlockOrdinal(int blockX, int blockY, int blockZ, BlockState state) {
|
||||||
|
if (BlockCategories.TALL_FLOWERS.contains(state)) {
|
||||||
|
PropertyKey propertyKey = PropertyKey.HALF;
|
||||||
|
BlockState plantState = extent.getBlock(blockX, blockY - 1, blockZ).getBlockType().equals(state.getBlockType())
|
||||||
|
? state.with(propertyKey, "upper")
|
||||||
|
: state.with(propertyKey, "lower");
|
||||||
|
return plantState.getOrdinalChar();
|
||||||
|
}
|
||||||
|
return BlockTypesCache.ReservedIDs.__RESERVED__;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyBlock(FilterBlock block) {
|
public void applyBlock(FilterBlock block) {
|
||||||
if (finished.get()) {
|
if (finished.get()) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren