Skip to content

Commit

Permalink
Merge version/7.2.x into master
Browse files Browse the repository at this point in the history
  • Loading branch information
me4502 committed Jun 4, 2022
1 parent 6e72ee0 commit 1e618e3
Show file tree
Hide file tree
Showing 122 changed files with 6,985 additions and 1,471 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -46,7 +46,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -60,4 +60,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
distribution: 'temurin'
- name: Build with Gradle
run: ./gradlew build -s
- uses: actions/upload-artifact@v2.2.4
- uses: actions/upload-artifact@v2
name: Archive Reports
if: always()
with:
Expand Down
22 changes: 22 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
7.2.10
- [Forge] Fixed a bug where the max world height would not always be read correctly
- [Bukkit] Fixed detection of other plugins bundling WorldEdit for newer Spigot versions
- [Forge] [Fabric] Improve fluid masks to properly detect mod fluids
- [Forge] Fixed the UPDATE side effect
- Update to 1.18.2
- Moved external links away from tinyurl to EngineHub URL shortener
- Allowed biome commands to be used by non-player actors (console, command block, etc)
- Fixed the UPDATE side effect not applying when called later on by API or FAST reorder mode
- Fixed entity passenger and riding status not being copied correctly

7.2.9
- [Forge] Add support for the UPDATE side effect
- [Forge] Fixed regen on recent Forge builds
- [Fabric] Fixed regen outside of Overworld
- [Sponge] Update to Sponge API8 (MC 1.16.5)
- [Bukkit] Fixed regen when biomes are used
- Fixed snapshots in 1.18
- Fixed smooth functions below y=0
- Tweak command usage label correctness for Bukkit API usage
- Fixed legacy error message output for plugins utilising our legacy APIs (Eg, WorldGuard and CraftBook)

7.2.8
- Update to 1.18.1
- Fixed issues with certain imports in craftscripts
Expand Down
12 changes: 7 additions & 5 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ val mixinVersion: String = properties.getProperty("mixin.version")
dependencies {
implementation(gradleApi())
implementation("gradle.plugin.org.cadixdev.gradle:licenser:0.6.1")
implementation("org.ajoberstar.grgit:grgit-gradle:4.1.0")
implementation("gradle.plugin.com.github.johnrengelman:shadow:7.1.0")
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.24.23")
implementation("org.spongepowered:SpongeGradle:0.11.5")
implementation("net.minecraftforge.gradle:ForgeGradle:5.1.26")
implementation("org.ajoberstar.grgit:grgit-gradle:4.1.1")
implementation("gradle.plugin.com.github.johnrengelman:shadow:7.1.2")
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.27.1")
implementation("org.spongepowered:spongegradle-plugin-development:2.0.1")
implementation("org.spongepowered:vanillagradle:0.2")
implementation("net.minecraftforge.gradle:ForgeGradle:5.1.31")
implementation("net.fabricmc:fabric-loom:$loomVersion")
implementation("net.fabricmc:sponge-mixin:$mixinVersion")
implementation("org.enginehub.gradle:gradle-codecov-plugin:0.1.0")
implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.3.5")
implementation("org.spongepowered:mixingradle:0.7.32")
}
3 changes: 3 additions & 0 deletions buildSrc/src/main/kotlin/LibsConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ fun Project.applyLibrariesConfiguration() {
exclude(dependency("org.checkerframework:checker-qual"))
exclude(dependency("org.apache.logging.log4j:log4j-api"))
exclude(dependency("com.google.code.findbugs:jsr305"))
exclude {
it.moduleGroup == "org.jetbrains.kotlin"
}
}

relocations.forEach { (from, to) ->
Expand Down
8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ object Versions {
const val TEXT = "3.0.4"
const val TEXT_EXTRAS = "3.0.6"
const val PISTON = "0.5.7"
const val AUTO_VALUE = "1.8.2"
const val AUTO_VALUE = "1.9"
const val JUNIT = "5.8.1"
const val MOCKITO = "4.0.0"
const val MOCKITO = "4.3.1"
const val FAST_UTIL = "8.5.6"
const val GUAVA = "31.0.1-jre"
const val GSON = "2.8.8"
const val LOG4J = "2.15.0"
const val GSON = "2.8.9"
const val LOG4J = "2.17.0"
}

// Properties that need a project reference to resolve:
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ version=7.3.0-SNAPSHOT
org.gradle.jvmargs=-Xmx1512M
org.gradle.parallel=true

loom.version=0.10.55
mixin.version=0.10.6+mixin.0.8.4
loom.version=0.11.32
mixin.version=0.11.2+mixin.0.8.5
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include("worldedit-libs")

include("worldedit-bukkit:adapters:adapter-1.17.1")
include("worldedit-bukkit:adapters:adapter-1.18")
include("worldedit-bukkit:adapters:adapter-1.18.2")

listOf("bukkit", "core", "sponge", "fabric", "forge", "cli").forEach {
include("worldedit-libs:$it")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.Futures;
import com.mojang.datafixers.util.Either;
import com.mojang.serialization.Codec;
import com.mojang.serialization.Dynamic;
import com.mojang.serialization.Lifecycle;
import com.sk89q.jnbt.AdventureNBTConverter;
import com.sk89q.jnbt.ByteArrayTag;
Expand Down Expand Up @@ -85,11 +82,8 @@
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.nbt.NbtOps;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.network.protocol.game.ClientboundEntityEventPacket;
import net.minecraft.resources.RegistryReadOps;
import net.minecraft.resources.RegistryWriteOps;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
Expand Down Expand Up @@ -151,13 +145,14 @@
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.OptionalInt;
import java.util.OptionalLong;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
Expand Down Expand Up @@ -428,6 +423,11 @@ public BaseEntity getEntity(org.bukkit.entity.Entity entity) {
CraftEntity craftEntity = ((CraftEntity) entity);
Entity mcEntity = craftEntity.getHandle();

// Do not allow creating of passenger entity snapshots, passengers are included in the vehicle entity
if (mcEntity.isPassenger()) {
return null;
}

String id = getEntityId(mcEntity);

net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
Expand All @@ -444,27 +444,48 @@ public org.bukkit.entity.Entity createEntity(Location location, BaseEntity state
CraftWorld craftWorld = ((CraftWorld) location.getWorld());
ServerLevel worldServer = craftWorld.getHandle();

Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle());
String entityId = state.getType().getId();

if (createdEntity != null) {
CompoundTag nativeTag = state.getNbtData();
if (nativeTag != null) {
net.minecraft.nbt.CompoundTag tag = (net.minecraft.nbt.CompoundTag) fromNative(nativeTag);
for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
tag.remove(name);
}
readTagIntoEntity(tag, createdEntity);
}
CompoundTag nativeTag = state.getNbtData();
net.minecraft.nbt.CompoundTag tag;
if (nativeTag != null) {
tag = (net.minecraft.nbt.CompoundTag) fromNative(nativeTag);
removeUnwantedEntityTagsRecursively(tag);
} else {
tag = new net.minecraft.nbt.CompoundTag();
}

tag.putString("id", entityId);

createdEntity.absMoveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
Entity createdEntity = EntityType.loadEntityRecursive(tag, craftWorld.getHandle(), (loadedEntity) -> {
loadedEntity.absMoveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
return loadedEntity;
});

worldServer.addEntity(createdEntity, SpawnReason.CUSTOM);
if (createdEntity != null) {
worldServer.addAllEntities(createdEntity, SpawnReason.CUSTOM);
return createdEntity.getBukkitEntity();
} else {
return null;
}
}

// This removes all unwanted tags from the main entity and all its passengers
private void removeUnwantedEntityTagsRecursively(net.minecraft.nbt.CompoundTag tag) {
for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
tag.remove(name);
}

// Adapted from net.minecraft.world.entity.EntityType#loadEntityRecursive
if (tag.contains("Passengers", NBTConstants.TYPE_LIST)) {
net.minecraft.nbt.ListTag nbttaglist = tag.getList("Passengers", NBTConstants.TYPE_COMPOUND);

for (int i = 0; i < nbttaglist.size(); ++i) {
removeUnwantedEntityTagsRecursively(nbttaglist.getCompound(i));
}
}
}

@Override
public Component getRichBlockName(BlockType blockType) {
return TranslatableComponent.of(getBlockFromType(blockType).getDescriptionId());
Expand All @@ -481,28 +502,34 @@ public Component getRichItemName(BaseItemStack itemStack) {
}

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
Map<String, Property<?>> properties = Maps.newTreeMap(String::compareTo);
Block block = getBlockFromType(blockType);
StateDefinition<Block, net.minecraft.world.level.block.state.BlockState> blockStateList =
block.getStateDefinition();
for (net.minecraft.world.level.block.state.properties.Property state : blockStateList.getProperties()) {
Property property;
private static final LoadingCache<net.minecraft.world.level.block.state.properties.Property, Property<?>> PROPERTY_CACHE = CacheBuilder.newBuilder().build(new CacheLoader<net.minecraft.world.level.block.state.properties.Property, Property<?>>() {
@Override
public Property<?> load(net.minecraft.world.level.block.state.properties.Property state) throws Exception {
if (state instanceof net.minecraft.world.level.block.state.properties.BooleanProperty) {
property = new BooleanProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
return new BooleanProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
} else if (state instanceof DirectionProperty) {
property = new DirectionalProperty(state.getName(),
return new DirectionalProperty(state.getName(),
(List<Direction>) state.getPossibleValues().stream().map(e -> Direction.valueOf(((StringRepresentable) e).getSerializedName().toUpperCase(Locale.ROOT))).collect(Collectors.toList()));
} else if (state instanceof net.minecraft.world.level.block.state.properties.EnumProperty) {
property = new EnumProperty(state.getName(),
return new EnumProperty(state.getName(),
(List<String>) state.getPossibleValues().stream().map(e -> ((StringRepresentable) e).getSerializedName()).collect(Collectors.toList()));
} else if (state instanceof net.minecraft.world.level.block.state.properties.IntegerProperty) {
property = new IntegerProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
return new IntegerProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
} else {
throw new IllegalArgumentException("WorldEdit needs an update to support " + state.getClass().getSimpleName());
}
}
});

@SuppressWarnings({ "rawtypes" })
@Override
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
Map<String, Property<?>> properties = new TreeMap<>();
Block block = getBlockFromType(blockType);
StateDefinition<Block, net.minecraft.world.level.block.state.BlockState> blockStateList =
block.getStateDefinition();
for (net.minecraft.world.level.block.state.properties.Property state : blockStateList.getProperties()) {
Property<?> property = PROPERTY_CACHE.getUnchecked(state);
properties.put(property.getName(), property);
}
return properties;
Expand Down Expand Up @@ -610,7 +637,7 @@ private void doRegen(org.bukkit.World bukkitWorld, Region region, Extent extent,

long seed = options.getSeed().orElse(originalWorld.getSeed());
WorldGenSettings newOpts = options.getSeed().isPresent()
? replaceSeed(originalWorld, seed, originalOpts)
? originalOpts.withSeed(levelProperties.isHardcore(), OptionalLong.of(seed))
: originalOpts;

LevelSettings newWorldSettings = new LevelSettings(
Expand Down Expand Up @@ -655,49 +682,6 @@ private void doRegen(org.bukkit.World bukkitWorld, Region region, Extent extent,
}
}

private WorldGenSettings replaceSeed(ServerLevel originalWorld, long seed, WorldGenSettings originalOpts) {
RegistryWriteOps<net.minecraft.nbt.Tag> nbtReadRegOps = RegistryWriteOps.create(
NbtOps.INSTANCE,
originalWorld.getServer().registryAccess()
);
RegistryReadOps<net.minecraft.nbt.Tag> nbtRegOps = RegistryReadOps.createAndLoad(
NbtOps.INSTANCE,
originalWorld.getServer().getResourceManager(),
originalWorld.getServer().registryAccess()
);
Codec<WorldGenSettings> dimCodec = WorldGenSettings.CODEC;
return dimCodec
.encodeStart(nbtReadRegOps, originalOpts)
.flatMap(tag ->
dimCodec.parse(
recursivelySetSeed(new Dynamic<>(nbtRegOps, tag), seed, new HashSet<>())
)
)
.get()
.map(
l -> l,
error -> {
throw new IllegalStateException("Unable to map GeneratorOptions: " + error.message());
}
);
}

@SuppressWarnings("unchecked")
private Dynamic<net.minecraft.nbt.Tag> recursivelySetSeed(Dynamic<net.minecraft.nbt.Tag> dynamic, long seed, Set<Dynamic<net.minecraft.nbt.Tag>> seen) {
if (!seen.add(dynamic)) {
return dynamic;
}
return dynamic.updateMapValues(pair -> {
if (pair.getFirst().asString("").equals("seed")) {
return pair.mapSecond(v -> v.createLong(seed));
}
if (pair.getSecond().getValue() instanceof net.minecraft.nbt.CompoundTag) {
return pair.mapSecond(v -> recursivelySetSeed((Dynamic<net.minecraft.nbt.Tag>) v, seed, seen));
}
return pair;
});
}

private BiomeType adapt(ServerLevel serverWorld, Biome origBiome) {
ResourceLocation key = serverWorld.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getKey(origBiome);
if (key == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ public void notifyNeighbors(BlockPos pos, net.minecraft.world.level.block.state.
}
}

@Override
public void updateBlock(BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) {
ServerLevel world = getWorld();
newState.onPlace(world, pos, oldState, false);
}

private void fireNeighborChanged(BlockPos pos, ServerLevel world, Block block, BlockPos neighborPos) {
world.getBlockState(neighborPos).neighborChanged(world, neighborPos, block, pos, false);
}
Expand Down
6 changes: 6 additions & 0 deletions worldedit-bukkit/adapters/adapter-1.18.2/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
applyPaperweightAdapterConfiguration()

dependencies {
// https://papermc.io/repo/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/
paperDevBundle("1.18.2-R0.1-20220304.102823-4")
}
Loading

0 comments on commit 1e618e3

Please sign in to comment.