Skip to content

Commit

Permalink
Add a DecoratorTypes accessor similar to PlacerTypes; Terrestria can …
Browse files Browse the repository at this point in the history
…use this.

- Add a DecoratorTypes accessor similar to PlacerTypes
  • Loading branch information
gniftygnome committed Mar 28, 2024
1 parent 9a0df86 commit 67395f1
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.parallel=true
fabric.loom.multiProjectOptimisation=true

maven_group=com.terraformersmc.terraform-api
version=10.0.0-alpha.8
version=10.0.0-alpha.9

minecraft_version=24w13a
yarn_mappings=24w13a+build.2
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.terraformersmc.terraform.tree.decorator;

import com.mojang.serialization.MapCodec;
import com.terraformersmc.terraform.tree.mixin.InvokerTreeDecoratorType;
import net.minecraft.util.Identifier;
import net.minecraft.world.gen.treedecorator.TreeDecorator;
import net.minecraft.world.gen.treedecorator.TreeDecoratorType;

public final class DecoratorTypes {
private DecoratorTypes() {
return;
}

// Deprecated annotation is just a warning for non-internal references
@SuppressWarnings("deprecation")
public static <D extends TreeDecorator> TreeDecoratorType<D> registerTreeDecorator(String id, MapCodec<D> codec) {
return InvokerTreeDecoratorType.callRegister(id, codec);
}

public static <D extends TreeDecorator> TreeDecoratorType<D> registerTreeDecorator(Identifier id, MapCodec<D> codec) {
return registerTreeDecorator(id.toString(), codec);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.terraformersmc.terraform.tree.mixin;

import com.mojang.serialization.MapCodec;
import net.minecraft.world.gen.treedecorator.TreeDecorator;
import net.minecraft.world.gen.treedecorator.TreeDecoratorType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

@Mixin(TreeDecoratorType.class)
public interface InvokerTreeDecoratorType {
@Invoker
@Deprecated
static <D extends TreeDecorator> TreeDecoratorType<D> callRegister(String id, MapCodec<D> codec) {
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"compatibilityLevel": "JAVA_17",
"mixins": [
"InvokerFoliagePlacerType",
"InvokerTreeDecoratorType",
"InvokerTrunkPlacerType",
"MixinTrunkPlacer"
],
Expand Down

0 comments on commit 67395f1

Please sign in to comment.