Compare commits

..

39 Commits

Author SHA1 Message Date
Zoë Gidiere 0990df0620 Merge branch 'master' into dev/1.21.9 2025-10-03 00:48:43 -06:00
Zoë Gidiere 451683aff5 spooky month (bump version to 6.6.6) 2025-10-03 00:35:24 -06:00
OakLoaf 41e9c2f55f Disabled AllayMC platform 2025-10-02 17:45:21 -06:00
Zoë Gidiere 4873b321cb update fabric build version 2025-10-02 17:33:31 -06:00
OakLoaf 64546bb154 Migrated to modern PaperCommandManager 2025-09-30 19:36:50 +01:00
OakLoaf d97478d2c4 Added separate version definition for runPaper task 2025-09-30 19:36:24 +01:00
OakLoaf 359b4826bc Corrected version in fabric.mod.json 2025-09-30 19:31:34 +01:00
OakLoaf 4b218a65f6 Refactored bukkit nms package 2025-09-30 19:00:36 +01:00
OakLoaf b88712e569 Fixed compilation errors 2025-09-30 18:51:25 +01:00
OakLoaf af509ebc3b Disabled AllayMC platform 2025-09-30 18:43:11 +01:00
OakLoaf a5c3733568 Updated dependencies for 1.21.9 2025-09-30 18:42:58 +01:00
Zoë Gidiere 1ef12fdec0 Merge pull request #525 from PolyhedralDev/dev/wolves
More wolf fixes
2025-08-13 14:36:50 -06:00
OakLoaf 4e890f96e4 Corrected wolf variant spawn reasons list 2025-08-13 20:22:25 +01:00
OakLoaf 4e70ee99c9 Adjusted log scope 2025-08-13 20:22:03 +01:00
Zoë Gidiere b149497c60 Merge pull request #521 from PolyhedralDev/deps/cloud
Updated cloud-paper to resolve warning message
2025-08-11 21:34:11 -06:00
Zoë Gidiere d9f591bdb4 Merge pull request #524 from PolyhedralDev/dev/wolves
Made wolves generated with chunks correctly inherit variants
2025-08-11 21:34:01 -06:00
Zoë Gidiere a4b74e2e7f Merge pull request #522 from PolyhedralDev/dev/1.21.8
Added 1.21.8 support
2025-08-11 21:33:51 -06:00
OakLoaf b53d475f42 Made wolves generated with chunks correctly inherit variants 2025-08-01 16:53:32 +01:00
OakLoaf 4ddb741d0d Refactored packages for 1.21.8 2025-07-19 18:23:32 +01:00
OakLoaf 852f5aa610 Bumped dependencies 2025-07-18 16:02:54 +01:00
OakLoaf 953895a8d4 Bumped dependencies 2025-07-18 16:00:58 +01:00
OakLoaf 8788eab839 Added 1.21.8 bukkit support 2025-07-17 15:13:01 +01:00
Oak 2b62473372 Update Versions.kt 2025-07-17 14:13:40 +01:00
Zoë Gidiere 9f546370cd Merge pull request #519 from PolyhedralDev/feat/nmsplatform
Fixed NMSPlatform implementation
2025-07-13 16:44:10 -06:00
Zoë Gidiere 428bf341ef Better handling of internal addon 2025-07-13 15:47:48 -06:00
OakLoaf 8a61571ceb Fixed biome registering 2025-07-13 14:48:56 +01:00
OakLoaf b669f87b79 Merge branch 'refs/heads/master' into feat/nmsplatform 2025-07-13 14:22:00 +01:00
OakLoaf e507675ef6 Removed unused import 2025-07-13 14:21:45 +01:00
Zoë Gidiere 3322a16f09 Fix particle releated crash on bukkit 2025-07-10 19:50:54 -06:00
Zoë Gidiere c658d1a81b Merge remote-tracking branch 'origin/master' 2025-07-10 19:42:38 -06:00
Zoë Gidiere 56a7234494 Merge pull request #518 from PolyhedralDev/feat/nmsplatform
Implemented vanilla biome config options
2025-07-10 19:40:22 -06:00
Zoë Gidiere 217b708177 Update NMSPlatform.java 2025-07-10 19:40:05 -06:00
OakLoaf 7d86a41f65 Updates to particles 2025-07-10 11:29:31 +01:00
OakLoaf 753574fc9b Implemented vanilla biome config options 2025-07-10 11:14:22 +01:00
Zoë Gidiere 95f89ed2b6 reformat tesf test 2025-07-09 21:59:13 -06:00
Zoë Gidiere cb8aefe8d2 updates to particles 2025-07-09 19:31:48 -06:00
Zoë Gidiere 79f9488380 Merge pull request #515 from PolyhedralDev/dev/1.21.7
Bumped Cloud for Paper and Fabric version
2025-07-09 16:42:23 -06:00
Zoë Gidiere 4c2ce65cdc Some fixes to biome config 2025-07-09 16:41:53 -06:00
Zoë Gidiere 70c448dd0d Fix particles 2025-07-09 15:06:40 -06:00
47 changed files with 347 additions and 258 deletions
+3 -3
View File
@@ -1,8 +1,8 @@
preRelease(true)
versionProjects(":common:api", version("6.6.5"))
versionProjects(":common:implementation", version("6.6.5"))
versionProjects(":platforms", version("6.6.5"))
versionProjects(":common:api", version("6.6.6"))
versionProjects(":common:implementation", version("6.6.6"))
versionProjects(":platforms", version("6.6.6"))
allprojects {
+9 -8
View File
@@ -28,7 +28,7 @@ object Versions {
}
object Fabric {
const val fabricAPI = "0.128.1+${Mod.minecraft}"
const val fabricAPI = "0.133.14+${Mod.minecraft}"
const val cloud = "2.0.0-beta.11"
}
//
@@ -41,12 +41,12 @@ object Versions {
const val mixin = "0.15.5+mixin.0.8.7"
const val mixinExtras = "0.4.1"
const val minecraft = "1.21.7"
const val minecraft = "1.21.9"
const val yarn = "$minecraft+build.1"
const val fabricLoader = "0.16.14"
const val fabricLoader = "0.17.2"
const val architecuryLoom = "1.10.431"
const val architecturyPlugin = "3.4.161"
const val architecuryLoom = "1.11.440"
const val architecturyPlugin = "3.4.162"
}
//
@@ -56,15 +56,16 @@ object Versions {
// }
object Bukkit {
const val minecraft = "1.21.7-R0.1"
const val paperBuild = "$minecraft-20250630.144242-1"
const val minecraft = "1.21.9-rc1-R0.1"
const val paperBuild = "$minecraft-20250930.133904-13"
const val paper = paperBuild
const val paperLib = "1.0.8"
const val reflectionRemapper = "0.1.2"
const val paperDevBundle = paperBuild
const val runPaper = "2.3.1"
const val runPaperMinecraft = "1.21.9"
const val paperWeight = "2.0.0-beta.17"
const val cloud = "2.0.0-beta.10"
const val cloud = "2.0.0-beta.11"
const val multiverse = "5.0.2"
}
@@ -1,10 +1,10 @@
bool thing1 = 2 > (2+2) || false;
bool thing1 = 2 > (2 + 2) || false;
if(2 > 2 || 3 + 4 <= 2 && 4 + 5 > 2 / 3) {
if (2 > 2 || 3 + 4 <= 2 && 4 + 5 > 2 / 3) {
test("ok", 2);
}
test("minecraft:green_w" + "ool", (2 * (3+1) * (2 * (1+1))));
test("minecraft:green_w" + "ool", (2 * (3 + 1) * (2 * (1 + 1))));
//
num testVar = 3.4;
@@ -21,7 +21,7 @@ bool iftest = false;
bool truetest = false;
num iterator = 0;
num thing = 4 - 2-2+2-2+2;
num thing = 4 - 2 - 2 + 2 - 2 + 2;
test("4 - 2 = " + thing, 2);
thing = -2;
@@ -31,54 +31,54 @@ test("--2 = " + thing, 2);
for(num i = 0; i < 5; i = i + 1) {
for (num i = 0; i < 5; i = i + 1) {
test("i = " + i, iterator);
if(i > 1 + 1) {
if (i > 1 + 1) {
test("more than 2", iterator);
continue;
}
}
for(num i = 0; i < 5; i = i + 1) {
for (num i = 0; i < 5; i = i + 1) {
test("i = " + i, iterator);
}
for(num j = 0; j < 5; j = j + 1) test("single statement j = " + j, iterator);
for (num j = 0; j < 5; j = j + 1) test("single statement j = " + j, iterator);
if(4 + 2 == 2 + 4) {
if (4 + 2 == 2 + 4) {
test("new thing " + 2, iterator);
}
while(iterator < 5) {
while (iterator < 5) {
test("always, even after " + 2, iterator);
iterator = iterator + 1;
if(iterator > 2) {
if (iterator > 2) {
continue;
}
test("not after " + 2, iterator);
}
if(true) test("single statement" + 2, iterator);
else if(true) test("another single statement" + 2, iterator);
if (true) test("single statement" + 2, iterator);
else if (true) test("another single statement" + 2, iterator);
if(true) {
test("true!" + 2, iterator);
} else {
test("false!" + 2, iterator);
}
if(false) {
if (true) {
test("true!" + 2, iterator);
} else {
test("false!" + 2, iterator);
}
if(false) {
test("true again!" + 2, iterator);
} else if(true == true) {
test("false again!" + 2, iterator);
if (false) {
test("true!" + 2, iterator);
} else {
test("not logged!" + 2, iterator);
test("false!" + 2, iterator);
}
if (false) {
test("true again!" + 2, iterator);
} else if (true == true) {
test("false again!" + 2, iterator);
} else {
test("not logged!" + 2, iterator);
}
@@ -91,7 +91,7 @@ fsdfsd
test("fdsgdf" + 2, 1 + testVar);
if(true && !(boolean && false) && true) {
if (true && !(boolean && false) && true) {
num scopedVar = 2;
test("if statement" + 2 + stringVar, 1 + testVar + scopedVar);
}
@@ -108,7 +108,7 @@ public abstract class AbstractPlatform implements Platform {
return Collections.emptySet();
}
protected void load() {
protected InternalAddon load() {
if(LOADED.get()) {
throw new IllegalStateException(
"Someone tried to initialize Terra, but Terra has already initialized. This is most likely due to a broken platform " +
@@ -159,6 +159,8 @@ public abstract class AbstractPlatform implements Platform {
logger.info("Terra addons successfully loaded.");
logger.info("Finished initialization.");
return internalAddon;
}
protected InternalAddon loadAddons() {
+2 -2
View File
@@ -8,7 +8,7 @@ dependencies {
paperweight.paperDevBundle(Versions.Bukkit.paperDevBundle)
shaded(project(":platforms:bukkit:common"))
shaded(project(":platforms:bukkit:nms:v1_21_7"))
shaded(project(":platforms:bukkit:nms:v1_21_9"))
shaded("xyz.jpenilla", "reflection-remapper", Versions.Bukkit.reflectionRemapper)
}
@@ -27,7 +27,7 @@ tasks {
}
runServer {
minecraftVersion(Versions.Bukkit.minecraft)
minecraftVersion(Versions.Bukkit.runPaperMinecraft)
dependsOn(shadowJar)
pluginJars(shadowJar.get().archiveFile)
@@ -1,62 +0,0 @@
/*
* This file is part of Terra.
*
* Terra is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Terra is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Terra. If not, see <https://www.gnu.org/licenses/>.
*/
package com.dfsek.terra.bukkit;
import org.bukkit.ChatColor;
import java.util.Optional;
import com.dfsek.terra.api.command.CommandSender;
import com.dfsek.terra.api.entity.Entity;
import com.dfsek.terra.api.entity.Player;
import com.dfsek.terra.bukkit.world.BukkitAdapter;
public class BukkitCommandSender implements CommandSender {
private final org.bukkit.command.CommandSender delegate;
public BukkitCommandSender(org.bukkit.command.CommandSender delegate) {
this.delegate = delegate;
}
@Override
public void sendMessage(String message) {
delegate.sendMessage(ChatColor.translateAlternateColorCodes('&', message));
}
@Override
public Optional<Entity> getEntity() {
if(delegate instanceof org.bukkit.entity.Entity entity) {
return Optional.of(BukkitAdapter.adapt(entity));
}
return Optional.empty();
}
@Override
public Optional<Player> getPlayer() {
if(delegate instanceof org.bukkit.entity.Player player) {
return Optional.of(BukkitAdapter.adapt(player));
}
return Optional.empty();
}
@Override
public org.bukkit.command.CommandSender getHandle() {
return delegate;
}
}
@@ -0,0 +1,46 @@
package com.dfsek.terra.bukkit;
import com.dfsek.terra.api.command.CommandSender;
import com.dfsek.terra.api.entity.Entity;
import com.dfsek.terra.api.entity.Player;
import com.dfsek.terra.bukkit.world.BukkitAdapter;
import io.papermc.paper.command.brigadier.CommandSourceStack;
import org.bukkit.ChatColor;
import java.util.Optional;
public class CloudCommandSender implements CommandSender {
private final CommandSourceStack delegate;
public CloudCommandSender(CommandSourceStack delegate) {
this.delegate = delegate;
}
@Override
public void sendMessage(String message) {
delegate.getSender().sendMessage(ChatColor.translateAlternateColorCodes('&', message));
}
@Override
public Optional<Entity> getEntity() {
if(delegate instanceof org.bukkit.entity.Entity entity) {
return Optional.of(BukkitAdapter.adapt(entity));
}
return Optional.empty();
}
@Override
public Optional<Player> getPlayer() {
if(delegate instanceof org.bukkit.entity.Player player) {
return Optional.of(BukkitAdapter.adapt(player));
}
return Optional.empty();
}
@Override
public CommandSourceStack getHandle() {
return delegate;
}
}
@@ -21,8 +21,6 @@ import com.dfsek.tectonic.api.TypeRegistry;
import com.dfsek.tectonic.api.depth.DepthTracker;
import com.dfsek.tectonic.api.exception.LoadException;
import com.dfsek.terra.bukkit.nms.Initializer;
import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryKey;
import org.bukkit.Bukkit;
@@ -33,10 +31,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.List;
import com.dfsek.terra.AbstractPlatform;
import com.dfsek.terra.api.addon.BaseAddon;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.handle.ItemHandle;
import com.dfsek.terra.api.handle.WorldHandle;
@@ -99,11 +95,6 @@ public class PlatformImpl extends AbstractPlatform {
plugin.getGlobalRegionScheduler().run(plugin, task -> runnable.run());
}
@Override
protected Iterable<BaseAddon> platformAddon() {
return List.of(Initializer.nmsAddon(this));
}
@Override
public @NotNull WorldHandle getWorldHandle() {
return handle;
@@ -133,7 +124,7 @@ public class PlatformImpl extends AbstractPlatform {
}
private BukkitPlatformBiome parseBiome(String id, DepthTracker depthTracker) throws LoadException {
protected BukkitPlatformBiome parseBiome(String id, DepthTracker depthTracker) throws LoadException {
NamespacedKey key = NamespacedKey.fromString(id);
if(key == null || !key.namespace().equals("minecraft")) throw new LoadException("Invalid biome identifier " + id, depthTracker);
return new BukkitPlatformBiome(RegistryAccess.registryAccess().getRegistry(RegistryKey.BIOME).getOrThrow(key));
@@ -23,10 +23,8 @@ import org.bukkit.Bukkit;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.java.JavaPlugin;
import org.incendo.cloud.SenderMapper;
import org.incendo.cloud.brigadier.CloudBrigadierManager;
import org.incendo.cloud.bukkit.CloudBukkitCapabilities;
import org.incendo.cloud.execution.ExecutionCoordinator;
import org.incendo.cloud.paper.LegacyPaperCommandManager;
import org.incendo.cloud.paper.PaperCommandManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
@@ -51,7 +49,7 @@ import com.dfsek.terra.bukkit.world.BukkitAdapter;
public class TerraBukkitPlugin extends JavaPlugin {
private static final Logger logger = LoggerFactory.getLogger(TerraBukkitPlugin.class);
private final PlatformImpl platform = new PlatformImpl(this);
private PlatformImpl platform;
private final Map<String, com.dfsek.terra.api.world.chunk.generation.ChunkGenerator> generatorMap = new HashMap<>();
private AsyncScheduler asyncScheduler = this.getServer().getAsyncScheduler();
@@ -64,15 +62,16 @@ public class TerraBukkitPlugin extends JavaPlugin {
return;
}
platform.getEventManager().callEvent(new PlatformInitializationEvent());
if(!Initializer.init(platform)) {
platform = Initializer.init(this);
if(platform == null) {
Bukkit.getPluginManager().disablePlugin(this);
return;
}
platform.getEventManager().callEvent(new PlatformInitializationEvent());
try {
LegacyPaperCommandManager<CommandSender> commandManager = getCommandSenderPaperCommandManager();
PaperCommandManager<CommandSender> commandManager = getCommandSenderPaperCommandManager();
platform.getEventManager().callEvent(new CommandRegistrationEvent(commandManager));
@@ -92,25 +91,15 @@ public class TerraBukkitPlugin extends JavaPlugin {
}
@NotNull
private LegacyPaperCommandManager<CommandSender> getCommandSenderPaperCommandManager() throws Exception {
// TODO: Update to PaperCommandManager
LegacyPaperCommandManager<CommandSender> commandManager = new LegacyPaperCommandManager<>(
this,
ExecutionCoordinator.simpleCoordinator(),
SenderMapper.create(
private PaperCommandManager<CommandSender> getCommandSenderPaperCommandManager() throws Exception {
PaperCommandManager<CommandSender> commandManager = PaperCommandManager.builder(SenderMapper.create(
BukkitAdapter::adapt,
BukkitAdapter::adapt
));
))
.executionCoordinator(ExecutionCoordinator.simpleCoordinator())
.buildOnEnable(this);
if(commandManager.hasCapability(CloudBukkitCapabilities.NATIVE_BRIGADIER)) {
commandManager.registerBrigadier();
final CloudBrigadierManager<?, ?> brigManager = commandManager.brigadierManager();
if(brigManager != null) {
brigManager.setNativeNumberSuggestions(false);
}
} else if(commandManager.hasCapability(CloudBukkitCapabilities.ASYNCHRONOUS_COMPLETION)) {
commandManager.registerAsynchronousCompletions();
}
commandManager.brigadierManager().setNativeNumberSuggestions(false);
return commandManager;
}
@@ -27,6 +27,7 @@ import com.dfsek.terra.bukkit.world.BukkitPlatformBiome;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Wolf;
import org.bukkit.entity.Wolf.Variant;
import org.bukkit.event.EventHandler;
@@ -34,6 +35,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,7 +48,7 @@ import java.util.List;
public class CommonListener implements Listener {
private static final Logger logger = LoggerFactory.getLogger(CommonListener.class);
private static final List<SpawnReason> WOLF_VARIANT_SPAWN_REASONS = List.of(
SpawnReason.SPAWNER, SpawnReason.TRIAL_SPAWNER, SpawnReason.SPAWNER_EGG, SpawnReason.DEFAULT
SpawnReason.SPAWNER, SpawnReason.TRIAL_SPAWNER, SpawnReason.SPAWNER_EGG, SpawnReason.NATURAL
);
private final Platform platform;
@@ -68,21 +70,12 @@ public class CommonListener implements Listener {
}
}
@EventHandler
public void onWolfSpawn(CreatureSpawnEvent event) {
if (!(event.getEntity() instanceof Wolf wolf)) {
return;
}
private void applyWolfVariant(Wolf wolf) {
// Doesn't apply if variant has already been applied
if (wolf.getVariant() != Variant.PALE) {
return;
}
if (!WOLF_VARIANT_SPAWN_REASONS.contains(event.getSpawnReason())) {
return;
}
World world = wolf.getWorld();
if (!(world.getGenerator() instanceof BukkitChunkGeneratorWrapper wrapper)) {
return;
@@ -113,4 +106,31 @@ public class CommonListener implements Listener {
}
});
}
@EventHandler
public void onWolfSpawn(CreatureSpawnEvent event) {
if (!(event.getEntity() instanceof Wolf wolf)) {
return;
}
if (!WOLF_VARIANT_SPAWN_REASONS.contains(event.getSpawnReason())) {
logger.debug("Ignoring wolf spawned with reason: " + event.getSpawnReason());
return;
}
applyWolfVariant(wolf);
}
@EventHandler
public void onChunkGenerate(ChunkLoadEvent event) {
if (!event.isNewChunk()) {
return;
}
for (Entity entity : event.getChunk().getEntities()) {
if (entity instanceof Wolf wolf) {
applyWolfVariant(wolf);
}
}
}
}
@@ -1,6 +1,6 @@
package com.dfsek.terra.bukkit.nms;
import com.dfsek.terra.bukkit.BukkitAddon;
import com.dfsek.terra.bukkit.TerraBukkitPlugin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -13,13 +13,11 @@ public interface Initializer {
String NMS = VersionUtil.getMinecraftVersionInfo().toString().replace(".", "_");
String TERRA_PACKAGE = Initializer.class.getPackageName();
static boolean init(PlatformImpl platform) {
static PlatformImpl init(TerraBukkitPlugin plugin) {
Logger logger = LoggerFactory.getLogger(Initializer.class);
Initializer initializer = constructInitializer();
if(initializer != null) {
initializer.initialize(platform);
} else {
PlatformImpl platform = constructPlatform(plugin);
if (platform == null) {
logger.error("NMS bindings for version {} do not exist. Support for this version is limited.", NMS);
logger.error("This is usually due to running Terra on an unsupported Minecraft version.");
String bypassKey = "IKnowThereAreNoNMSBindingsFor" + NMS + "ButIWillProceedAnyway";
@@ -27,7 +25,7 @@ public interface Initializer {
logger.error("Because of this **TERRA HAS BEEN DISABLED**.");
logger.error("Do not come ask us why it is not working.");
logger.error("If you wish to proceed anyways, you can add the JVM System Property \"{}\" to enable the plugin.", bypassKey);
return false;
return null;
} else {
logger.error("");
logger.error("");
@@ -43,24 +41,16 @@ public interface Initializer {
}
}
return true;
return platform;
}
static BukkitAddon nmsAddon(PlatformImpl platform) {
Initializer initializer = constructInitializer();
return initializer != null ? initializer.getNMSAddon(platform) : new BukkitAddon(platform);
}
private static Initializer constructInitializer() {
private static PlatformImpl constructPlatform(TerraBukkitPlugin plugin) {
try {
String packageVersion = NMS;
if (NMS.equals("v1_21_5") || NMS.equals("v1_21_6")) {
packageVersion = "v1_21_7";
}
Class<?> initializerClass = Class.forName(TERRA_PACKAGE + "." + packageVersion + ".NMSInitializer");
Class<?> platformClass = Class.forName(TERRA_PACKAGE + "." + NMS + ".NMSPlatform");
try {
return (Initializer) initializerClass.getConstructor().newInstance();
return (PlatformImpl) platformClass
.getConstructor(TerraBukkitPlugin.class)
.newInstance(plugin);
} catch(ReflectiveOperationException e) {
throw new RuntimeException("Error initializing NMS bindings. Report this to Terra.", e);
}
@@ -68,8 +58,4 @@ public interface Initializer {
return null;
}
}
void initialize(PlatformImpl plugin);
BukkitAddon getNMSAddon(PlatformImpl plugin);
}
@@ -18,6 +18,9 @@
package com.dfsek.terra.bukkit.world;
import com.dfsek.terra.bukkit.CloudCommandSender;
import io.papermc.paper.command.brigadier.CommandSourceStack;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@@ -38,7 +41,6 @@ import com.dfsek.terra.api.util.vector.Vector3;
import com.dfsek.terra.api.world.ServerWorld;
import com.dfsek.terra.api.world.chunk.Chunk;
import com.dfsek.terra.api.world.info.WorldProperties;
import com.dfsek.terra.bukkit.BukkitCommandSender;
import com.dfsek.terra.bukkit.BukkitEntity;
import com.dfsek.terra.bukkit.BukkitPlayer;
import com.dfsek.terra.bukkit.world.block.BukkitBlockTypeAndItem;
@@ -157,16 +159,16 @@ public final class BukkitAdapter {
return Vector3.of(vector.getX(), vector.getY(), vector.getZ());
}
public static CommandSender adapt(org.bukkit.command.CommandSender sender) {
return new BukkitCommandSender(sender);
public static CommandSender adapt(CommandSourceStack sender) {
return new CloudCommandSender(sender);
}
public static Entity adapt(org.bukkit.entity.Entity entity) {
return new BukkitEntity(entity);
}
public static org.bukkit.command.CommandSender adapt(CommandSender sender) {
return ((BukkitCommandSender) sender).getHandle();
public static CommandSourceStack adapt(CommandSender sender) {
return ((CloudCommandSender) sender).getHandle();
}
public static ServerWorld adapt(org.bukkit.World world) {
@@ -1,22 +0,0 @@
package com.dfsek.terra.bukkit.nms.v1_21_7;
import com.dfsek.terra.bukkit.BukkitAddon;
import org.bukkit.Bukkit;
import com.dfsek.terra.bukkit.PlatformImpl;
import com.dfsek.terra.bukkit.nms.Initializer;
public class NMSInitializer implements Initializer {
@Override
public void initialize(PlatformImpl platform) {
AwfulBukkitHacks.registerBiomes(platform.getRawConfigRegistry());
Bukkit.getPluginManager().registerEvents(new NMSInjectListener(), platform.getPlugin());
}
@Override
public BukkitAddon getNMSAddon(PlatformImpl plugin) {
return new NMSAddon(plugin);
}
}
@@ -1,6 +1,6 @@
package com.dfsek.terra.bukkit.nms.v1_21_7;
package com.dfsek.terra.bukkit.nms.v1_21_9;
import com.dfsek.terra.bukkit.nms.v1_21_7.config.VanillaBiomeProperties;
import com.dfsek.terra.bukkit.nms.v1_21_9.config.VanillaBiomeProperties;
import com.dfsek.terra.bukkit.world.BukkitBiomeInfo;
@@ -14,6 +14,7 @@ import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.npc.VillagerType;
import net.minecraft.world.level.biome.Biome;
import org.bukkit.NamespacedKey;
import org.slf4j.Logger;
@@ -24,6 +25,7 @@ import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
@@ -48,6 +50,7 @@ public class AwfulBukkitHacks {
configRegistry.forEach(pack -> pack.getRegistry(com.dfsek.terra.api.world.biome.Biome.class).forEach((key, biome) -> {
try {
BukkitPlatformBiome platformBiome = (BukkitPlatformBiome) biome.getPlatformBiome();
NamespacedKey vanillaBukkitKey = platformBiome.getHandle().getKey();
ResourceLocation vanillaMinecraftKey = ResourceLocation.fromNamespaceAndPath(vanillaBukkitKey.getNamespace(),
vanillaBukkitKey.getKey());
@@ -66,6 +69,12 @@ public class AwfulBukkitHacks {
platformBiome.getContext().put(new BukkitBiomeInfo(delegateBukkitKey));
platformBiome.getContext().put(new NMSBiomeInfo(delegateKey));
Map<ResourceKey<Biome>, ResourceKey<VillagerType>> villagerMap = Reflection.VILLAGER_TYPE.getByBiome();
villagerMap.put(delegateKey,
Objects.requireNonNullElse(vanillaBiomeProperties.getVillagerType(),
villagerMap.getOrDefault(delegateKey, VillagerType.PLAINS)));
terraBiomeMap.computeIfAbsent(vanillaMinecraftKey, i -> new ArrayList<>()).add(delegateKey.location());
LOGGER.debug("Registered biome: " + delegateKey);
@@ -1,11 +1,11 @@
package com.dfsek.terra.bukkit.nms.v1_21_7;
package com.dfsek.terra.bukkit.nms.v1_21_9;
import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.bukkit.BukkitAddon;
import com.dfsek.terra.bukkit.PlatformImpl;
import com.dfsek.terra.bukkit.nms.v1_21_7.config.VanillaBiomeProperties;
import com.dfsek.terra.bukkit.nms.v1_21_9.config.VanillaBiomeProperties;
public class NMSAddon extends BukkitAddon {
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21_7;
package com.dfsek.terra.bukkit.nms.v1_21_9;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.biome.Biome;
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21_7;
package com.dfsek.terra.bukkit.nms.v1_21_9;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
@@ -12,7 +12,7 @@ import java.util.Objects;
import java.util.Optional;
import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.bukkit.nms.v1_21_7.config.VanillaBiomeProperties;
import com.dfsek.terra.bukkit.nms.v1_21_9.config.VanillaBiomeProperties;
public class NMSBiomeInjector {
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21_7;
package com.dfsek.terra.bukkit.nms.v1_21_9;
import com.mojang.serialization.MapCodec;
import net.minecraft.core.Holder;
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21_7;
package com.dfsek.terra.bukkit.nms.v1_21_9;
import com.mojang.serialization.MapCodec;
import net.minecraft.core.BlockPos;
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21_7;
package com.dfsek.terra.bukkit.nms.v1_21_9;
import net.minecraft.server.level.ChunkMap;
import net.minecraft.server.level.ServerLevel;
@@ -0,0 +1,108 @@
package com.dfsek.terra.bukkit.nms.v1_21_9;
import com.dfsek.tectonic.api.TypeRegistry;
import com.dfsek.tectonic.api.exception.LoadException;
import com.dfsek.terra.addon.InternalAddon;
import com.dfsek.terra.api.addon.BaseAddon;
import com.dfsek.terra.api.event.events.platform.PlatformInitializationEvent;
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
import com.dfsek.terra.api.world.biome.PlatformBiome;
import com.dfsek.terra.bukkit.PlatformImpl;
import com.dfsek.terra.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.bukkit.nms.v1_21_9.config.BiomeAdditionsSoundTemplate;
import com.dfsek.terra.bukkit.nms.v1_21_9.config.BiomeMoodSoundTemplate;
import com.dfsek.terra.bukkit.nms.v1_21_9.config.BiomeParticleConfigTemplate;
import com.dfsek.terra.bukkit.nms.v1_21_9.config.EntityTypeTemplate;
import com.dfsek.terra.bukkit.nms.v1_21_9.config.MusicSoundTemplate;
import com.dfsek.terra.bukkit.nms.v1_21_9.config.SoundEventTemplate;
import com.dfsek.terra.bukkit.nms.v1_21_9.config.SpawnCostConfig;
import com.dfsek.terra.bukkit.nms.v1_21_9.config.SpawnEntryConfig;
import com.dfsek.terra.bukkit.nms.v1_21_9.config.SpawnSettingsTemplate;
import com.dfsek.terra.bukkit.nms.v1_21_9.config.SpawnTypeConfig;
import com.dfsek.terra.bukkit.nms.v1_21_9.config.VillagerTypeTemplate;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.Music;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.entity.npc.VillagerType;
import net.minecraft.world.level.biome.AmbientAdditionsSettings;
import net.minecraft.world.level.biome.AmbientMoodSettings;
import net.minecraft.world.level.biome.AmbientParticleSettings;
import net.minecraft.world.level.biome.Biome.Precipitation;
import net.minecraft.world.level.biome.Biome.TemperatureModifier;
import net.minecraft.world.level.biome.BiomeSpecialEffects.GrassColorModifier;
import net.minecraft.world.level.biome.MobSpawnSettings;
import org.bukkit.Bukkit;
import java.util.List;
import java.util.Locale;
public class NMSPlatform extends PlatformImpl {
public NMSPlatform(TerraBukkitPlugin plugin) {
super(plugin);
Bukkit.getPluginManager().registerEvents(new NMSInjectListener(), plugin);
}
@Override
public void register(TypeRegistry registry) {
super.register(registry);
registry.registerLoader(PlatformBiome.class, (type, o, loader, depthTracker) -> parseBiome((String) o, depthTracker))
.registerLoader(ResourceLocation.class, (type, o, loader, depthTracker) -> {
ResourceLocation identifier = ResourceLocation.tryParse((String) o);
if(identifier == null)
throw new LoadException("Invalid identifier: " + o, depthTracker);
return identifier;
})
.registerLoader(Precipitation.class, (type, o, loader, depthTracker) -> Precipitation.valueOf(((String) o).toUpperCase(
Locale.ROOT)))
.registerLoader(GrassColorModifier.class,
(type, o, loader, depthTracker) -> GrassColorModifier.valueOf(((String) o).toUpperCase(
Locale.ROOT)))
.registerLoader(GrassColorModifier.class,
(type, o, loader, depthTracker) -> TemperatureModifier.valueOf(((String) o).toUpperCase(
Locale.ROOT)))
.registerLoader(MobCategory.class, (type, o, loader, depthTracker) -> MobCategory.valueOf((String) o))
.registerLoader(AmbientParticleSettings.class, BiomeParticleConfigTemplate::new)
.registerLoader(SoundEvent.class, SoundEventTemplate::new)
.registerLoader(AmbientMoodSettings.class, BiomeMoodSoundTemplate::new)
.registerLoader(AmbientAdditionsSettings.class, BiomeAdditionsSoundTemplate::new)
.registerLoader(Music.class, MusicSoundTemplate::new)
.registerLoader(EntityType.class, EntityTypeTemplate::new)
.registerLoader(SpawnCostConfig.class, SpawnCostConfig::new)
.registerLoader(SpawnEntryConfig.class, SpawnEntryConfig::new)
.registerLoader(SpawnTypeConfig.class, SpawnTypeConfig::new)
.registerLoader(MobSpawnSettings.class, SpawnSettingsTemplate::new)
.registerLoader(VillagerType.class, VillagerTypeTemplate::new);
}
@Override
protected InternalAddon load() {
InternalAddon internalAddon = super.load();
this.getEventManager().getHandler(FunctionalEventHandler.class)
.register(internalAddon, PlatformInitializationEvent.class)
.priority(1)
.then(event -> AwfulBukkitHacks.registerBiomes(this.getRawConfigRegistry()))
.global();
return internalAddon;
}
@Override
protected Iterable<BaseAddon> platformAddon() {
return List.of(new NMSAddon(this));
}
}
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21_7;
package com.dfsek.terra.bukkit.nms.v1_21_9;
import net.minecraft.world.level.LevelHeightAccessor;
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21_7;
package com.dfsek.terra.bukkit.nms.v1_21_9;
import net.minecraft.core.Holder;
import net.minecraft.core.Holder.Reference;
@@ -7,6 +7,7 @@ import net.minecraft.core.MappedRegistry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.ChunkMap;
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.npc.VillagerType;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.StructureManager;
import net.minecraft.world.level.biome.Biome;
@@ -36,6 +37,7 @@ public class Reflection {
public static final HolderReferenceProxy HOLDER_REFERENCE;
public static final HolderSetNamedProxy HOLDER_SET;
public static final BiomeProxy BIOME;
public static final VillagerTypeProxy VILLAGER_TYPE;
static {
ReflectionRemapper reflectionRemapper = ReflectionRemapper.forReobfMappingsInPaperJar();
@@ -50,6 +52,7 @@ public class Reflection {
HOLDER_REFERENCE = reflectionProxyFactory.reflectionProxy(HolderReferenceProxy.class);
HOLDER_SET = reflectionProxyFactory.reflectionProxy(HolderSetNamedProxy.class);
BIOME = reflectionProxyFactory.reflectionProxy(BiomeProxy.class);
VILLAGER_TYPE = reflectionProxyFactory.reflectionProxy(VillagerTypeProxy.class);
}
@@ -121,4 +124,11 @@ public class Reflection {
@MethodName("getGrassColorFromTexture")
int invokeGrassColorFromTexture(Biome instance);
}
@Proxies(VillagerType.class)
public interface VillagerTypeProxy {
@Static
@FieldGetter("BY_BIOME")
Map<ResourceKey<Biome>, ResourceKey<VillagerType>> getByBiome();
}
}
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21_7;
package com.dfsek.terra.bukkit.nms.v1_21_9;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21_7.config;
package com.dfsek.terra.bukkit.nms.v1_21_9.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21_7.config;
package com.dfsek.terra.bukkit.nms.v1_21_9.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21_7.config;
package com.dfsek.terra.bukkit.nms.v1_21_9.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
@@ -6,10 +6,12 @@ import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.commands.arguments.ParticleArgument;
import net.minecraft.core.HolderLookup.Provider;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.level.biome.AmbientParticleSettings;
import java.util.stream.Stream;
public class BiomeParticleConfigTemplate implements ObjectTemplate<AmbientParticleSettings> {
@Value("particle")
@@ -18,17 +20,18 @@ public class BiomeParticleConfigTemplate implements ObjectTemplate<AmbientPartic
@Value("probability")
@Default
private Integer probability = null;
private Float probability = 0.1f;
@Override
public AmbientParticleSettings get() {
if(particle == null || probability == null) {
if(particle == null) {
return null;
}
try {
return new AmbientParticleSettings(ParticleArgument.readParticle(new StringReader(particle),
(Provider) BuiltInRegistries.PARTICLE_TYPE.asHolderIdMap()), probability);
HolderLookup.Provider.create(Stream.of(BuiltInRegistries.PARTICLE_TYPE))), probability);
} catch(CommandSyntaxException e) {
throw new RuntimeException(e);
}
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21_7.config;
package com.dfsek.terra.bukkit.nms.v1_21_9.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21_7.config;
package com.dfsek.terra.bukkit.nms.v1_21_9.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21_7.config;
package com.dfsek.terra.bukkit.nms.v1_21_9.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21_7.config;
package com.dfsek.terra.bukkit.nms.v1_21_9.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21_7.config;
package com.dfsek.terra.bukkit.nms.v1_21_9.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
@@ -28,7 +28,7 @@ public class SpawnEntryConfig implements ObjectTemplate<SpawnEntryConfig> {
return weight;
}
public SpawnerData getSpawnerData() {
public SpawnerData getSpawnEntry() {
return new SpawnerData(type, minGroupSize, maxGroupSize);
}
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21_7.config;
package com.dfsek.terra.bukkit.nms.v1_21_9.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
@@ -33,7 +33,7 @@ public class SpawnSettingsTemplate implements ObjectTemplate<MobSpawnSettings> {
for(SpawnTypeConfig spawn : spawns) {
MobCategory group = spawn.getGroup();
for(SpawnEntryConfig entry : spawn.getEntries()) {
builder.addSpawn(group, entry.getWeight(), entry.getSpawnerData());
builder.addSpawn(group, entry.getWeight(), entry.getSpawnEntry());
}
}
for(SpawnCostConfig cost : costs) {
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21_7.config;
package com.dfsek.terra.bukkit.nms.v1_21_9.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
@@ -1,4 +1,4 @@
package com.dfsek.terra.bukkit.nms.v1_21_7.config;
package com.dfsek.terra.bukkit.nms.v1_21_9.config;
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
import com.dfsek.tectonic.api.config.template.annotations.Default;
@@ -6,6 +6,7 @@ import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.terra.api.properties.Properties;
import net.minecraft.resources.ResourceKey;
import net.minecraft.sounds.Music;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.npc.VillagerType;
@@ -96,7 +97,7 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
@Value("villager-type")
@Default
private VillagerType villagerType = null;
private ResourceKey<VillagerType> villagerType = null;
public Integer getFogColor() {
return fogColor;
@@ -174,7 +175,7 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
return spawnSettings;
}
public VillagerType getVillagerType() {
public ResourceKey<VillagerType> getVillagerType() {
return villagerType;
}
}
@@ -1,20 +1,21 @@
package com.dfsek.terra.bukkit.nms.v1_21_7.config;
package com.dfsek.terra.bukkit.nms.v1_21_9.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.npc.VillagerType;
public class VillagerTypeTemplate implements ObjectTemplate<VillagerType> {
public class VillagerTypeTemplate implements ObjectTemplate<ResourceKey<VillagerType>> {
@Value("id")
@Default
private ResourceLocation id = null;
@Override
public VillagerType get() {
return BuiltInRegistries.VILLAGER_TYPE.get(id).orElseThrow().value();
public ResourceKey<VillagerType> get() {
return ResourceKey.create(BuiltInRegistries.VILLAGER_TYPE.key(), id);
}
}
@@ -35,7 +35,7 @@
"depends": {
"fabricloader": ">=0.16.10",
"java": ">=21",
"minecraft": "1.21.7",
"minecraft": "1.21.9",
"fabric": "*"
}
}
@@ -90,7 +90,7 @@ public abstract class ModPlatform extends AbstractPlatform {
.registerLoader(MusicSound.class, MusicSoundTemplate::new)
.registerLoader(EntityType.class, EntityTypeTemplate::new)
.registerLoader(SpawnCostConfig.class, SpawnCostConfig::new)
.registerLoader(SpawnEntry.class, SpawnEntryConfig::new)
.registerLoader(SpawnEntryConfig.class, SpawnEntryConfig::new)
.registerLoader(SpawnTypeConfig.class, SpawnTypeConfig::new)
.registerLoader(SpawnSettings.class, SpawnSettingsTemplate::new)
.registerLoader(VillagerType.class, VillagerTypeTemplate::new);
@@ -10,6 +10,8 @@ import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.world.biome.BiomeParticleConfig;
import java.util.stream.Stream;
public class BiomeParticleConfigTemplate implements ObjectTemplate<BiomeParticleConfig> {
@Value("particle")
@@ -18,19 +20,19 @@ public class BiomeParticleConfigTemplate implements ObjectTemplate<BiomeParticle
@Value("probability")
@Default
private Integer probability = null;
private Float probability = 0.1f;
@Override
public BiomeParticleConfig get() {
if(particle == null || probability == null) {
if(particle == null) {
return null;
}
try {
return new BiomeParticleConfig(
ParticleEffectArgumentType.readParameters(new StringReader(particle),
(RegistryWrapper.WrapperLookup) Registries.PARTICLE_TYPE),
probability);
RegistryWrapper.WrapperLookup.of(Stream.of(Registries.PARTICLE_TYPE))),
probability);
} catch(CommandSyntaxException e) {
throw new RuntimeException(e);
}
@@ -7,7 +7,7 @@ import net.minecraft.entity.EntityType;
import net.minecraft.world.biome.SpawnSettings.SpawnEntry;
public class SpawnEntryConfig implements ObjectTemplate<SpawnEntry> {
public class SpawnEntryConfig implements ObjectTemplate<SpawnEntryConfig> {
@Value("type")
@Default
private EntityType<?> type = null;
@@ -28,8 +28,12 @@ public class SpawnEntryConfig implements ObjectTemplate<SpawnEntry> {
return weight;
}
@Override
public SpawnEntry get() {
public SpawnEntry getSpawnEntry() {
return new SpawnEntry(type, minGroupSize, maxGroupSize);
}
@Override
public SpawnEntryConfig get() {
return this;
}
}
@@ -27,8 +27,8 @@ public class SpawnSettingsTemplate implements ObjectTemplate<SpawnSettings> {
SpawnSettings.Builder builder = new SpawnSettings.Builder();
for(SpawnTypeConfig spawn : spawns) {
SpawnGroup group = spawn.getGroup();
for(SpawnEntryConfig entry : spawn.getEntry()) {
builder.spawn(group, entry.getWeight(), entry.get());
for(SpawnEntryConfig entry : spawn.getEntries()) {
builder.spawn(group, entry.getWeight(), entry.getSpawnEntry());
}
}
for(SpawnCostConfig cost : costs) {
@@ -15,14 +15,14 @@ public class SpawnTypeConfig implements ObjectTemplate<SpawnTypeConfig> {
@Value("entries")
@Default
private List<SpawnEntryConfig> entry = null;
private List<SpawnEntryConfig> entries = null;
public SpawnGroup getGroup() {
return group;
}
public List<SpawnEntryConfig> getEntry() {
return entry;
public List<SpawnEntryConfig> getEntries() {
return entries;
}
@Override
@@ -13,10 +13,10 @@ import net.minecraft.village.VillagerType;
public class VillagerTypeTemplate implements ObjectTemplate<RegistryKey<VillagerType>> {
@Value("id")
@Default
private String id = null;
private Identifier id = null;
@Override
public RegistryKey<VillagerType> get() {
return RegistryKey.of(RegistryKeys.VILLAGER_TYPE, Identifier.ofVanilla(id));
return RegistryKey.of(RegistryKeys.VILLAGER_TYPE, id);
}
}
@@ -7,6 +7,7 @@ import ca.solostudios.strata.version.Version;
import com.dfsek.terra.api.util.reflection.ReflectionUtil;
import net.minecraft.MinecraftVersion;
import net.minecraft.SharedConstants;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKeys;
@@ -107,7 +108,7 @@ public abstract class LifecyclePlatform extends ModPlatform {
super.platformAddon().forEach(addons::add);
String mcVersion = MinecraftVersion.CURRENT.name();
String mcVersion = SharedConstants.getGameVersion().name();
try {
addons.add(new EphemeralAddon(Versions.parseVersion(mcVersion), "minecraft"));
} catch(ParseException e) {
@@ -1,14 +1,11 @@
package com.dfsek.terra.lifecycle.mixin.lifecycle;
import com.dfsek.terra.mod.CommonPlatform;
import com.dfsek.terra.mod.ModPlatform;
import com.mojang.datafixers.DataFixer;
import net.minecraft.resource.ResourcePackManager;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.SaveLoader;
import net.minecraft.server.WorldGenerationProgressListenerFactory;
import net.minecraft.util.ApiServices;
import net.minecraft.world.chunk.ChunkLoadProgress;
import net.minecraft.world.level.storage.LevelStorage;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@@ -25,11 +22,11 @@ public class MinecraftServerMixin {
@Inject(method = "<init>(Ljava/lang/Thread;Lnet/minecraft/world/level/storage/LevelStorage$Session;" +
"Lnet/minecraft/resource/ResourcePackManager;Lnet/minecraft/server/SaveLoader;Ljava/net/Proxy;" +
"Lcom/mojang/datafixers/DataFixer;Lnet/minecraft/util/ApiServices;" +
"Lnet/minecraft/server/WorldGenerationProgressListenerFactory;)V",
"Lnet/minecraft/world/chunk/ChunkLoadProgress;)V",
at = @At("RETURN"))
private void injectConstructor(Thread serverThread, LevelStorage.Session session, ResourcePackManager dataPackManager,
SaveLoader saveLoader, Proxy proxy, DataFixer dataFixer, ApiServices apiServices,
WorldGenerationProgressListenerFactory worldGenerationProgressListenerFactory, CallbackInfo ci) {
ChunkLoadProgress chunkLoadProgress, CallbackInfo ci) {
LifecyclePlatform.setServer((MinecraftServer) (Object) this);
}
}