mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-01 15:37:24 +00:00
Added initial wolf variant support (not functional)
This commit is contained in:
parent
ad9d16f48c
commit
f4db7fc507
@ -18,20 +18,32 @@
|
||||
package com.dfsek.terra.bukkit.listeners;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.bukkit.generator.BukkitChunkGeneratorWrapper;
|
||||
import com.dfsek.terra.bukkit.hooks.MultiverseGeneratorPluginHook;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.entity.Wolf.Variant;
|
||||
import org.bukkit.event.EventHandler;
|
||||
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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Listener for events on all implementations.
|
||||
*/
|
||||
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
|
||||
);
|
||||
private final Platform platform;
|
||||
|
||||
public CommonListener(Platform platform) {
|
||||
@ -51,4 +63,35 @@ public class CommonListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWolfSpawn(CreatureSpawnEvent event) {
|
||||
if (!(event.getEntity() instanceof Wolf wolf)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
ConfigPack pack = platform.getConfigRegistry().get(wrapper.getPack().getRegistryKey()).orElse(null);
|
||||
if (pack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Implement logic to calculate variant
|
||||
if (wolf.getWorld().getBiome(wolf.getLocation()).getKey().toString().equalsIgnoreCase("terra:overworld/overworld/taiga")) {
|
||||
wolf.setVariant(Variant.RUSTY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user