Skip to content

Commit

Permalink
[Fabric] 1.21.2
Browse files Browse the repository at this point in the history
  • Loading branch information
octylFractal committed Oct 22, 2024
1 parent 31a795a commit 9bf8d51
Show file tree
Hide file tree
Showing 15 changed files with 124 additions and 135 deletions.
14 changes: 7 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[plugins]
codecov = "org.enginehub.codecov:0.2.0"
neogradle-userdev = "net.neoforged.gradle.userdev:7.0.142"
fabric-loom = "fabric-loom:1.6.12"
sponge-spongegradle = "org.spongepowered.gradle.plugin:2.2.0"
sponge-vanillagradle = { id = "org.spongepowered.gradle.vanilla", version.ref = "sponge-vanillagradle" }

Expand All @@ -11,7 +10,7 @@ piston = "0.5.10"
autoValue = "1.10.4"
antlr = "4.13.1"

fabric-api = "0.100.3+1.21"
fabric-api = "0.106.1+1.21.2"

neoforge-minecraft = "1.21"

Expand All @@ -21,8 +20,8 @@ sponge-api = "12.0.0-20240616.151530-3"
sponge-api-major = "12"

# https://parchmentmc.org/docs/getting-started; note that we use older MC versions some times which is OK
parchment-minecraft = "1.20.6"
parchment-mappings = "2024.06.16"
parchment-minecraft = "1.21"
parchment-mappings = "2024.07.28"

# https://repo.spongepowered.org/service/rest/repository/browse/maven-public/org/spongepowered/vanillagradle/
sponge-vanillagradle = "0.2.1-20240617.053350-83"
Expand All @@ -45,7 +44,8 @@ japicmp = "me.champeau.gradle:japicmp-gradle-plugin:0.4.2"
shadow = "com.github.johnrengelman:shadow:8.1.1"
jfrog-buildinfo = "org.jfrog.buildinfo:build-info-extractor-gradle:5.2.0"

fabric-mixin = "net.fabricmc:sponge-mixin:0.13.3+mixin.0.8.5"
# https://maven.fabricmc.net/net/fabricmc/sponge-mixin/
fabric-mixin = "net.fabricmc:sponge-mixin:0.15.3+mixin.0.8.7"

paperweight = "io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.7.2"

Expand Down Expand Up @@ -86,8 +86,8 @@ rhino = "org.mozilla:rhino-runtime:1.7.13"
jchronic = "com.sk89q:jchronic:0.2.4a"
jlibnoise = "com.sk89q.lib:jlibnoise:1.0.0"

fabric-minecraft = "com.mojang:minecraft:1.21"
fabric-loader = "net.fabricmc:fabric-loader:0.15.11"
fabric-minecraft = "com.mojang:minecraft:1.21.2"
fabric-loader = "net.fabricmc:fabric-loader:0.16.7"
fabric-permissions-api = "me.lucko:fabric-permissions-api:0.3.1"

neoforge = "net.neoforged:neoforge:21.0.16-beta"
Expand Down
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,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pluginManagement {
}
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
id("fabric-loom") version "1.6.12"
id("fabric-loom") version "1.8.10"
}
dependencyResolutionManagement {
repositories {
Expand Down
14 changes: 9 additions & 5 deletions worldedit-fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import net.fabricmc.loom.task.RemapJarTask
import net.fabricmc.loom.task.RunGameTask

plugins {
alias(libs.plugins.fabric.loom)
id("fabric-loom")
`java-library`
id("buildlogic.platform")
}
Expand All @@ -17,7 +17,7 @@ platform {

val fabricApiConfiguration: Configuration = configurations.create("fabricApi")

configure<LoomGradleExtensionAPI> {
loom {
accessWidenerPath.set(project.file("src/main/resources/worldedit.accesswidener"))
}

Expand All @@ -35,7 +35,10 @@ dependencies {
"api"(project(":worldedit-core"))

"minecraft"(libs.fabric.minecraft)
"mappings"(project.the<LoomGradleExtensionAPI>().officialMojangMappings())
"mappings"(loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${libs.versions.parchment.minecraft.get()}:${libs.versions.parchment.mappings.get()}@zip")
})
"modImplementation"(libs.fabric.loader)


Expand Down Expand Up @@ -73,10 +76,11 @@ configure<PublishingExtension> {
}

tasks.named<Copy>("processResources") {
val internalVersion = project.ext["internalVersion"]
// this will ensure that this task is redone when the versions change.
inputs.property("version", project.ext["internalVersion"])
inputs.property("version", internalVersion)
filesMatching("fabric.mod.json") {
this.expand("version" to project.ext["internalVersion"])
this.expand("version" to internalVersion)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.phys.Vec3;
import org.enginehub.linbus.tree.LinCompoundTag;

Expand Down Expand Up @@ -93,7 +92,7 @@ public static net.minecraft.world.level.Level adapt(World world) {

public static Biome adapt(BiomeType biomeType) {
return FabricWorldEdit.getRegistry(Registries.BIOME)
.get(ResourceLocation.parse(biomeType.id()));
.getValue(ResourceLocation.parse(biomeType.id()));
}

public static BiomeType adapt(Biome biome) {
Expand All @@ -115,42 +114,28 @@ public static Vec3 toVec3(BlockVector3 vector) {
}

public static net.minecraft.core.Direction adapt(Direction face) {
switch (face) {
case NORTH:
return net.minecraft.core.Direction.NORTH;
case SOUTH:
return net.minecraft.core.Direction.SOUTH;
case WEST:
return net.minecraft.core.Direction.WEST;
case EAST:
return net.minecraft.core.Direction.EAST;
case DOWN:
return net.minecraft.core.Direction.DOWN;
case UP:
default:
return net.minecraft.core.Direction.UP;
}
return switch (face) {
case NORTH -> net.minecraft.core.Direction.NORTH;
case SOUTH -> net.minecraft.core.Direction.SOUTH;
case WEST -> net.minecraft.core.Direction.WEST;
case EAST -> net.minecraft.core.Direction.EAST;
case DOWN -> net.minecraft.core.Direction.DOWN;
default -> net.minecraft.core.Direction.UP;
};
}

public static Direction adaptEnumFacing(@Nullable net.minecraft.core.Direction face) {
if (face == null) {
return null;
}
switch (face) {
case NORTH:
return Direction.NORTH;
case SOUTH:
return Direction.SOUTH;
case WEST:
return Direction.WEST;
case EAST:
return Direction.EAST;
case DOWN:
return Direction.DOWN;
case UP:
default:
return Direction.UP;
}
return switch (face) {
case NORTH -> Direction.NORTH;
case SOUTH -> Direction.SOUTH;
case WEST -> Direction.WEST;
case EAST -> Direction.EAST;
case DOWN -> Direction.DOWN;
default -> Direction.UP;
};
}

public static BlockPos toBlockPos(BlockVector3 vector) {
Expand All @@ -177,10 +162,12 @@ public static Map<Property<?>, Object> adaptProperties(BlockType block, Map<net.
Map<Property<?>, Object> props = new TreeMap<>(Comparator.comparing(Property::getName));
for (Map.Entry<net.minecraft.world.level.block.state.properties.Property<?>, Comparable<?>> prop : mcProps.entrySet()) {
Object value = prop.getValue();
if (prop.getKey() instanceof DirectionProperty) {
value = adaptEnumFacing((net.minecraft.core.Direction) value);
} else if (prop.getKey() instanceof net.minecraft.world.level.block.state.properties.EnumProperty) {
value = ((StringRepresentable) value).getSerializedName();
if (prop.getKey() instanceof net.minecraft.world.level.block.state.properties.EnumProperty) {
if (prop.getKey().getValueClass() == net.minecraft.core.Direction.class) {
value = adaptEnumFacing((net.minecraft.core.Direction) value);
} else {
value = ((StringRepresentable) value).getSerializedName();
}
}
props.put(block.getProperty(prop.getKey().getName()), value);
}
Expand Down Expand Up @@ -219,15 +206,15 @@ public static BaseBlock adapt(BlockEntity blockEntity) {
}

public static Block adapt(BlockType blockType) {
return FabricWorldEdit.getRegistry(Registries.BLOCK).get(ResourceLocation.parse(blockType.id()));
return FabricWorldEdit.getRegistry(Registries.BLOCK).getValue(ResourceLocation.parse(blockType.id()));
}

public static BlockType adapt(Block block) {
return BlockTypes.get(FabricWorldEdit.getRegistry(Registries.BLOCK).getKey(block).toString());
}

public static Item adapt(ItemType itemType) {
return FabricWorldEdit.getRegistry(Registries.ITEM).get(ResourceLocation.parse(itemType.id()));
return FabricWorldEdit.getRegistry(Registries.ITEM).getValue(ResourceLocation.parse(itemType.id()));
}

public static ItemType adapt(Item item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class FabricBlockCategoryRegistry implements BlockCategoryRegistry {
@Override
public Set<BlockType> getCategorisedByName(String category) {
return FabricWorldEdit.getRegistry(Registries.BLOCK)
.getTag(TagKey.create(Registries.BLOCK, ResourceLocation.parse(category)))
.get(TagKey.create(Registries.BLOCK, ResourceLocation.parse(category)))
.stream()
.flatMap(HolderSet.Named::stream)
.map(Holder::value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class FabricItemCategoryRegistry implements ItemCategoryRegistry {
@Override
public Set<ItemType> getCategorisedByName(String category) {
return FabricWorldEdit.getRegistry(Registries.ITEM)
.getTag(TagKey.create(Registries.ITEM, ResourceLocation.parse(category)))
.get(TagKey.create(Registries.ITEM, ResourceLocation.parse(category)))
.stream()
.flatMap(HolderSet.Named::stream)
.map(Holder::value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Component getRichName(ItemType itemType) {
@Override
public Component getRichName(BaseItemStack itemStack) {
return TranslatableComponent.of(
FabricAdapter.adapt(itemStack).getDescriptionId()
FabricAdapter.adapt(itemStack).getItem().getDescriptionId()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.enginehub.linbus.tree.LinCompoundTag;

import java.util.Locale;
import java.util.Set;
import java.util.UUID;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -103,7 +104,9 @@ public boolean setLocation(Location location) {
this.player.teleportTo(
level,
location.getX(), location.getY(), location.getZ(),
location.getYaw(), location.getPitch()
Set.of(),
location.getYaw(), location.getPitch(),
true
);
// This check doesn't really ever get to be false in Fabric
// Since Fabric API doesn't allow cancelling the teleport.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
import net.minecraft.world.Clearable;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.EntitySpawnReason;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -142,7 +143,7 @@ public class FabricWorld extends AbstractWorld {
private static ResourceLocation getDimensionRegistryKey(Level world) {
return Objects.requireNonNull(world.getServer(), "server cannot be null")
.registryAccess()
.registryOrThrow(Registries.DIMENSION_TYPE)
.lookupOrThrow(Registries.DIMENSION_TYPE)
.getKey(world.dimensionType());
}

Expand Down Expand Up @@ -247,11 +248,11 @@ public boolean setBiome(BlockVector3 position, BiomeType biome) {
var biomeArray = (PalettedContainer<Holder<Biome>>) chunk.getSection(chunk.getSectionIndex(position.y())).getBiomes();
biomeArray.getAndSetUnchecked(
position.x() & 3, position.y() & 3, position.z() & 3,
getWorld().registryAccess().registry(Registries.BIOME)
getWorld().registryAccess().lookup(Registries.BIOME)
.orElseThrow()
.getHolderOrThrow(ResourceKey.create(Registries.BIOME, ResourceLocation.parse(biome.id())))
.getOrThrow(ResourceKey.create(Registries.BIOME, ResourceLocation.parse(biome.id())))
);
chunk.setUnsaved(true);
chunk.markUnsaved();
return true;
}

Expand All @@ -278,11 +279,10 @@ public boolean useItem(BlockVector3 position, BaseItem item, Direction face) {
InteractionResult used = stack.useOn(itemUseContext);
if (used != InteractionResult.SUCCESS) {
// try activating the block
used = getWorld().getBlockState(blockPos).useItemOn(stack, world, fakePlayer, InteractionHand.MAIN_HAND, rayTraceResult)
.result();
used = getWorld().getBlockState(blockPos).useItemOn(stack, world, fakePlayer, InteractionHand.MAIN_HAND, rayTraceResult);
}
if (used != InteractionResult.SUCCESS) {
used = stack.use(world, fakePlayer, InteractionHand.MAIN_HAND).getResult();
used = stack.use(world, fakePlayer, InteractionHand.MAIN_HAND);
}
return used == InteractionResult.SUCCESS;
}
Expand Down Expand Up @@ -473,7 +473,7 @@ private List<CompletableFuture<ChunkAccess>> submitChunkLoadTasks(Region region,
public boolean generateTree(TreeType type, EditSession editSession, BlockVector3 position) {
ServerLevel world = (ServerLevel) getWorld();
ConfiguredFeature<?, ?> generator = Optional.ofNullable(createTreeFeatureGenerator(type))
.map(k -> world.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).get(k))
.map(k -> world.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).getValue(k))
.orElse(null);
ServerChunkCache chunkManager = world.getChunkSource();
if (type == TreeType.CHORUS_PLANT) {
Expand All @@ -488,7 +488,7 @@ public boolean generateTree(TreeType type, EditSession editSession, BlockVector3

public boolean generateFeature(ConfiguredFeatureType type, EditSession editSession, BlockVector3 position) {
ServerLevel world = (ServerLevel) getWorld();
ConfiguredFeature<?, ?> k = world.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).get(ResourceLocation.tryParse(type.id()));
ConfiguredFeature<?, ?> k = world.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).getValue(ResourceLocation.tryParse(type.id()));
ServerChunkCache chunkManager = world.getChunkSource();
WorldGenLevel proxyLevel = FabricServerLevelDelegateProxy.newInstance(editSession, world);
return k != null && k.place(proxyLevel, chunkManager.getGenerator(), random, FabricAdapter.toBlockPos(position));
Expand All @@ -497,7 +497,7 @@ public boolean generateFeature(ConfiguredFeatureType type, EditSession editSessi
@Override
public boolean generateStructure(StructureType type, EditSession editSession, BlockVector3 position) {
ServerLevel world = (ServerLevel) getWorld();
Structure k = world.registryAccess().registryOrThrow(Registries.STRUCTURE).get(ResourceLocation.tryParse(type.id()));
Structure k = world.registryAccess().lookupOrThrow(Registries.STRUCTURE).getValue(ResourceLocation.tryParse(type.id()));
if (k == null) {
return false;
}
Expand All @@ -513,7 +513,7 @@ public boolean generateStructure(StructureType type, EditSession editSession, Bl
BoundingBox boundingBox = structureStart.getBoundingBox();
ChunkPos min = new ChunkPos(SectionPos.blockToSectionCoord(boundingBox.minX()), SectionPos.blockToSectionCoord(boundingBox.minZ()));
ChunkPos max = new ChunkPos(SectionPos.blockToSectionCoord(boundingBox.maxX()), SectionPos.blockToSectionCoord(boundingBox.maxZ()));
ChunkPos.rangeClosed(min, max).forEach((chunkPosx) -> structureStart.placeInChunk(proxyLevel, world.structureManager(), chunkManager.getGenerator(), world.getRandom(), new BoundingBox(chunkPosx.getMinBlockX(), world.getMinBuildHeight(), chunkPosx.getMinBlockZ(), chunkPosx.getMaxBlockX(), world.getMaxBuildHeight(), chunkPosx.getMaxBlockZ()), chunkPosx));
ChunkPos.rangeClosed(min, max).forEach((chunkPosx) -> structureStart.placeInChunk(proxyLevel, world.structureManager(), chunkManager.getGenerator(), world.getRandom(), new BoundingBox(chunkPosx.getMinBlockX(), world.getMinY(), chunkPosx.getMinBlockZ(), chunkPosx.getMaxBlockX(), world.getMaxY(), chunkPosx.getMaxBlockZ()), chunkPosx));
return true;
}
}
Expand Down Expand Up @@ -603,12 +603,12 @@ public void setWeather(WeatherType weatherType, long duration) {

@Override
public int getMinY() {
return getWorld().getMinBuildHeight();
return getWorld().getMinY();
}

@Override
public int getMaxY() {
return getWorld().getMaxBuildHeight() - 1;
return getWorld().getMaxY() - 1;
}

@Override
Expand Down Expand Up @@ -704,7 +704,7 @@ public Entity createEntity(Location location, BaseEntity entity) {
}
tag.putString("id", entityId);

net.minecraft.world.entity.Entity createdEntity = EntityType.loadEntityRecursive(tag, world, (loadedEntity) -> {
net.minecraft.world.entity.Entity createdEntity = EntityType.loadEntityRecursive(tag, world, EntitySpawnReason.COMMAND, (loadedEntity) -> {
loadedEntity.absMoveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
return loadedEntity;
});
Expand Down
Loading

0 comments on commit 9bf8d51

Please sign in to comment.