3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-16 16:10:07 +01:00

Adjustment for tall flowers - add capability to forcefully override block updates

Dieser Commit ist enthalten in:
dordsor21 2024-07-13 16:12:36 +01:00
Ursprung 875b1dbac0
Commit 27f56deaef
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
7 geänderte Dateien mit 119 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -19,6 +19,7 @@ import javax.annotation.Nullable;
public class PaperweightLevelProxy extends ServerLevel {
protected ServerLevel serverLevel;
private PaperweightFaweAdapter adapter;
private PaperweightPlacementStateProcessor processor;
@ -28,7 +29,7 @@ public class PaperweightLevelProxy extends ServerLevel {
throw new IllegalStateException("Cannot be instantiated");
}
public static PaperweightLevelProxy getInstance(PaperweightPlacementStateProcessor processor) {
public static PaperweightLevelProxy getInstance(ServerLevel serverLevel, PaperweightPlacementStateProcessor processor) {
Unsafe unsafe = ReflectionUtils.getUnsafe();
PaperweightLevelProxy newLevel;
@ -39,6 +40,7 @@ public class PaperweightLevelProxy extends ServerLevel {
}
newLevel.processor = processor;
newLevel.adapter = ((PaperweightFaweAdapter) WorldEditPlugin.getInstance().getBukkitImplAdapter());
newLevel.serverLevel = serverLevel;
return newLevel;
}
@ -94,4 +96,14 @@ public class PaperweightLevelProxy extends ServerLevel {
return getBlockState(pos).getFluidState().is(FluidTags.WATER);
}
@Override
public int getHeight() {
return serverLevel.getHeight();
}
@Override
public int getMinBuildHeight() {
return serverLevel.getMinBuildHeight();
}
}

Datei anzeigen

@ -1,6 +1,9 @@
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R2;
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.extent.Extent;
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.regions.Region;
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.BlockTypesCache;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import org.bukkit.craftbukkit.v1_20_R2.CraftWorld;
import javax.annotation.Nullable;
import java.util.Map;
@ -29,7 +34,18 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region 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);
}
@ -42,7 +58,18 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
AtomicBoolean 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);
}

Datei anzeigen

@ -19,6 +19,7 @@ import javax.annotation.Nullable;
public class PaperweightLevelProxy extends ServerLevel {
protected ServerLevel serverLevel;
private PaperweightFaweAdapter adapter;
private PaperweightPlacementStateProcessor processor;
@ -28,7 +29,7 @@ public class PaperweightLevelProxy extends ServerLevel {
throw new IllegalStateException("Cannot be instantiated");
}
public static PaperweightLevelProxy getInstance(PaperweightPlacementStateProcessor processor) {
public static PaperweightLevelProxy getInstance(ServerLevel serverLevel, PaperweightPlacementStateProcessor processor) {
Unsafe unsafe = ReflectionUtils.getUnsafe();
PaperweightLevelProxy newLevel;
@ -39,6 +40,7 @@ public class PaperweightLevelProxy extends ServerLevel {
}
newLevel.processor = processor;
newLevel.adapter = ((PaperweightFaweAdapter) WorldEditPlugin.getInstance().getBukkitImplAdapter());
newLevel.serverLevel = serverLevel;
return newLevel;
}
@ -94,4 +96,14 @@ public class PaperweightLevelProxy extends ServerLevel {
return getBlockState(pos).getFluidState().is(FluidTags.WATER);
}
@Override
public int getHeight() {
return serverLevel.getHeight();
}
@Override
public int getMinBuildHeight() {
return serverLevel.getMinBuildHeight();
}
}

Datei anzeigen

@ -1,6 +1,9 @@
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R3;
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.extent.Extent;
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.regions.Region;
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.BlockTypesCache;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import javax.annotation.Nullable;
import java.util.Map;
@ -29,7 +34,18 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region 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);
}
@ -42,7 +58,18 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
AtomicBoolean 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);
}

Datei anzeigen

@ -96,4 +96,14 @@ public class PaperweightLevelProxy extends ServerLevel {
return getBlockState(pos).getFluidState().is(FluidTags.WATER);
}
@Override
public int getHeight() {
return serverLevel.getHeight();
}
@Override
public int getMinBuildHeight() {
return serverLevel.getMinBuildHeight();
}
}

Datei anzeigen

@ -96,4 +96,14 @@ public class PaperweightLevelProxy extends ServerLevel {
return getBlockState(pos).getFluidState().is(FluidTags.WATER);
}
@Override
public int getHeight() {
return serverLevel.getHeight();
}
@Override
public int getMinBuildHeight() {
return serverLevel.getMinBuildHeight();
}
}

Datei anzeigen

@ -392,6 +392,10 @@ public abstract class PlacementStateProcessor extends AbstractDelegateExtent imp
}
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);
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());
@ -436,6 +440,17 @@ public abstract class PlacementStateProcessor extends AbstractDelegateExtent imp
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
public void applyBlock(FilterBlock block) {
if (finished.get()) {