3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-17 08:30:04 +01:00
Minecraft has a lot of different methods between private and public to determine if structures can be placed. We cannot possibly cover all of them whilst also ensuring issues do not arise with generic "true"s
Dieser Commit ist enthalten in:
dordsor21 2024-06-07 20:51:45 +01:00
Ursprung f2f13f8c2f
Commit d2d8e7a932
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
12 geänderte Dateien mit 29 neuen und 102 gelöschten Zeilen

Datei anzeigen

@ -9,7 +9,6 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.flag.FeatureFlagSet;
import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeManager; import net.minecraft.world.level.biome.BiomeManager;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.border.WorldBorder; import net.minecraft.world.level.border.WorldBorder;
import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkAccess;
@ -122,22 +121,7 @@ public class FaweBlockStateListPopulator extends BlockStateListPopulator {
@Override @Override
public BlockState getBlockState(final BlockPos pos) { public BlockState getBlockState(final BlockPos pos) {
BlockState state = world.getBlockState(pos); return world.getBlockState(pos);
try {
state = new BlockState(
state.getBlock(),
state.getValues(),
PaperweightPlatformAdapter.getStatePropertiesCodec(state)
) {
@Override
public boolean is(Block block) {
return true;
}
};
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return state;
} }
@Override @Override

Datei anzeigen

@ -551,7 +551,12 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
)) { )) {
return null; return null;
} }
return new HashMap<>(populator.getLevel().capturedBlockStates); Map<BlockPos, CraftBlockState> placedBlocks = populator.getList().stream().collect(Collectors.toMap(
CraftBlockState::getPosition,
craftBlockState -> craftBlockState
));
placedBlocks.putAll(serverLevel.capturedBlockStates);
return placedBlocks;
} finally { } finally {
serverLevel.captureBlockStates = false; serverLevel.captureBlockStates = false;
serverLevel.captureTreeGeneration = false; serverLevel.captureTreeGeneration = false;

Datei anzeigen

@ -11,7 +11,6 @@ import com.fastasyncworldedit.core.math.IntPair;
import com.fastasyncworldedit.core.util.MathMan; import com.fastasyncworldedit.core.util.MathMan;
import com.fastasyncworldedit.core.util.TaskManager; import com.fastasyncworldedit.core.util.TaskManager;
import com.mojang.datafixers.util.Either; import com.mojang.datafixers.util.Either;
import com.mojang.serialization.MapCodec;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.bukkit.adapter.Refraction; import com.sk89q.worldedit.bukkit.adapter.Refraction;
@ -712,12 +711,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
return List.of(); return List.of();
} }
public static MapCodec<net.minecraft.world.level.block.state.BlockState> getStatePropertiesCodec(
net.minecraft.world.level.block.state.BlockState state
) throws IllegalAccessException {
return (MapCodec<net.minecraft.world.level.block.state.BlockState>) fieldPropertiesCodec.get(state);
}
record FakeIdMapBlock(int size) implements IdMap<net.minecraft.world.level.block.state.BlockState> { record FakeIdMapBlock(int size) implements IdMap<net.minecraft.world.level.block.state.BlockState> {
@Override @Override

Datei anzeigen

@ -9,7 +9,6 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.flag.FeatureFlagSet;
import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeManager; import net.minecraft.world.level.biome.BiomeManager;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.border.WorldBorder; import net.minecraft.world.level.border.WorldBorder;
import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkAccess;
@ -122,22 +121,7 @@ public class FaweBlockStateListPopulator extends BlockStateListPopulator {
@Override @Override
public BlockState getBlockState(final BlockPos pos) { public BlockState getBlockState(final BlockPos pos) {
BlockState state = world.getBlockState(pos); return world.getBlockState(pos);
try {
state = new BlockState(
state.getBlock(),
state.getValues(),
PaperweightPlatformAdapter.getStatePropertiesCodec(state)
) {
@Override
public boolean is(Block block) {
return true;
}
};
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return state;
} }
@Override @Override

Datei anzeigen

@ -552,7 +552,12 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
return null; return null;
} }
return new HashMap<>(populator.getLevel().capturedBlockStates); Map<BlockPos, CraftBlockState> placedBlocks = populator.getList().stream().collect(Collectors.toMap(
CraftBlockState::getPosition,
craftBlockState -> craftBlockState
));
placedBlocks.putAll(serverLevel.capturedBlockStates);
return placedBlocks;
} finally { } finally {
serverLevel.captureBlockStates = false; serverLevel.captureBlockStates = false;
serverLevel.captureTreeGeneration = false; serverLevel.captureTreeGeneration = false;
@ -596,6 +601,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
populator, populator,
biome -> true biome -> true
); );
if (!structureStart.isValid()) { if (!structureStart.isValid()) {
return null; return null;
} else { } else {

Datei anzeigen

@ -11,7 +11,6 @@ import com.fastasyncworldedit.core.math.IntPair;
import com.fastasyncworldedit.core.util.MathMan; import com.fastasyncworldedit.core.util.MathMan;
import com.fastasyncworldedit.core.util.TaskManager; import com.fastasyncworldedit.core.util.TaskManager;
import com.mojang.datafixers.util.Either; import com.mojang.datafixers.util.Either;
import com.mojang.serialization.MapCodec;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.bukkit.adapter.Refraction; import com.sk89q.worldedit.bukkit.adapter.Refraction;
@ -712,12 +711,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
return List.of(); return List.of();
} }
public static MapCodec<net.minecraft.world.level.block.state.BlockState> getStatePropertiesCodec(
net.minecraft.world.level.block.state.BlockState state
) throws IllegalAccessException {
return (MapCodec<net.minecraft.world.level.block.state.BlockState>) fieldPropertiesCodec.get(state);
}
record FakeIdMapBlock(int size) implements IdMap<net.minecraft.world.level.block.state.BlockState> { record FakeIdMapBlock(int size) implements IdMap<net.minecraft.world.level.block.state.BlockState> {
@Override @Override

Datei anzeigen

@ -1,6 +1,5 @@
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4; package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4;
import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
@ -10,9 +9,7 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.flag.FeatureFlagSet;
import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeManager; import net.minecraft.world.level.biome.BiomeManager;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.border.WorldBorder; import net.minecraft.world.level.border.WorldBorder;
import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkSource; import net.minecraft.world.level.chunk.ChunkSource;
@ -124,22 +121,7 @@ public class FaweBlockStateListPopulator extends BlockStateListPopulator {
@Override @Override
public BlockState getBlockState(final BlockPos pos) { public BlockState getBlockState(final BlockPos pos) {
BlockState state = world.getBlockState(pos); return world.getBlockState(pos);
try {
state = new BlockState(
state.getBlock(),
(Reference2ObjectArrayMap<Property<?>, Comparable<?>>) state.getValues(),
PaperweightPlatformAdapter.getStatePropertiesCodec(state)
) {
@Override
public boolean is(Block block) {
return true;
}
};
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return state;
} }
@Override @Override

Datei anzeigen

@ -565,7 +565,12 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
)) { )) {
return null; return null;
} }
return new HashMap<>(populator.getLevel().capturedBlockStates); Map<BlockPos, CraftBlockState> placedBlocks = populator.getList().stream().collect(Collectors.toMap(
CraftBlockState::getPosition,
craftBlockState -> craftBlockState
));
placedBlocks.putAll(serverLevel.capturedBlockStates);
return placedBlocks;
} finally { } finally {
serverLevel.captureBlockStates = false; serverLevel.captureBlockStates = false;
serverLevel.captureTreeGeneration = false; serverLevel.captureTreeGeneration = false;

Datei anzeigen

@ -11,7 +11,6 @@ import com.fastasyncworldedit.core.math.IntPair;
import com.fastasyncworldedit.core.util.MathMan; import com.fastasyncworldedit.core.util.MathMan;
import com.fastasyncworldedit.core.util.TaskManager; import com.fastasyncworldedit.core.util.TaskManager;
import com.mojang.datafixers.util.Either; import com.mojang.datafixers.util.Either;
import com.mojang.serialization.MapCodec;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.bukkit.adapter.Refraction; import com.sk89q.worldedit.bukkit.adapter.Refraction;
@ -707,12 +706,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
return List.of(); return List.of();
} }
public static MapCodec<net.minecraft.world.level.block.state.BlockState> getStatePropertiesCodec(
net.minecraft.world.level.block.state.BlockState state
) throws IllegalAccessException {
return (MapCodec<net.minecraft.world.level.block.state.BlockState>) fieldPropertiesCodec.get(state);
}
record FakeIdMapBlock(int size) implements IdMap<net.minecraft.world.level.block.state.BlockState> { record FakeIdMapBlock(int size) implements IdMap<net.minecraft.world.level.block.state.BlockState> {
@Override @Override

Datei anzeigen

@ -9,7 +9,6 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeManager; import net.minecraft.world.level.biome.BiomeManager;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.Property; import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.border.WorldBorder; import net.minecraft.world.level.border.WorldBorder;
@ -118,22 +117,7 @@ public class FaweBlockStateListPopulator extends BlockStateListPopulator {
@Override @Override
public BlockState getBlockState(final BlockPos pos) { public BlockState getBlockState(final BlockPos pos) {
BlockState state = world.getBlockState(pos); return world.getBlockState(pos);
try {
state = new BlockState(
state.getBlock(),
(Reference2ObjectArrayMap<Property<?>, Comparable<?>>) state.getValues(),
PaperweightPlatformAdapter.getStatePropertiesCodec(state)
) {
@Override
public boolean is(Block block) {
return true;
}
};
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return state;
} }
@Override @Override

Datei anzeigen

@ -566,7 +566,12 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
)) { )) {
return null; return null;
} }
return new HashMap<>(populator.getLevel().capturedBlockStates); Map<BlockPos, CraftBlockState> placedBlocks = populator.getList().stream().collect(Collectors.toMap(
CraftBlockState::getPosition,
craftBlockState -> craftBlockState
));
placedBlocks.putAll(serverLevel.capturedBlockStates);
return placedBlocks;
} finally { } finally {
serverLevel.captureBlockStates = false; serverLevel.captureBlockStates = false;
serverLevel.captureTreeGeneration = false; serverLevel.captureTreeGeneration = false;

Datei anzeigen

@ -12,7 +12,6 @@ import com.fastasyncworldedit.core.math.IntPair;
import com.fastasyncworldedit.core.util.MathMan; import com.fastasyncworldedit.core.util.MathMan;
import com.fastasyncworldedit.core.util.TaskManager; import com.fastasyncworldedit.core.util.TaskManager;
import com.mojang.datafixers.util.Either; import com.mojang.datafixers.util.Either;
import com.mojang.serialization.MapCodec;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.bukkit.adapter.Refraction; import com.sk89q.worldedit.bukkit.adapter.Refraction;
@ -681,12 +680,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
} }
} }
public static MapCodec<net.minecraft.world.level.block.state.BlockState> getStatePropertiesCodec(
net.minecraft.world.level.block.state.BlockState state
) throws IllegalAccessException {
return (MapCodec<net.minecraft.world.level.block.state.BlockState>) fieldPropertiesCodec.get(state);
}
record FakeIdMapBlock(int size) implements IdMap<net.minecraft.world.level.block.state.BlockState> { record FakeIdMapBlock(int size) implements IdMap<net.minecraft.world.level.block.state.BlockState> {
@Override @Override