Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for allay platform #474

Open
wants to merge 61 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
02a7363
feat: init work on allay
smartcmd Jun 15, 2024
b29ba2d
feat: more works
smartcmd Jun 15, 2024
d81f886
feat: more works
smartcmd Jun 15, 2024
59d7632
feat: add mapping files
smartcmd Jun 15, 2024
2b12541
feat: more works
smartcmd Jun 15, 2024
62e5898
feat: more works
smartcmd Jun 16, 2024
3d4aec4
chores: improve imports
smartcmd Jun 16, 2024
d861d3e
feat: more works
smartcmd Jun 16, 2024
1f937a2
feat: fake entity
smartcmd Jun 16, 2024
133df45
feat: make it works!
smartcmd Jun 16, 2024
6ff0903
fix: fix an mistake
smartcmd Jun 16, 2024
4a3678c
feat: update to 1.21
smartcmd Jun 17, 2024
e68f928
feat: use OtherChunkAccessibleContext directly
smartcmd Jun 18, 2024
2d0e4a8
fix: OtherChunkAccessibleContext.get/setBlockState() should use level…
smartcmd Jun 18, 2024
5fa7007
fix: fix a typo
smartcmd Jun 19, 2024
d490324
feat: support waterlogged
smartcmd Jun 19, 2024
cd767a6
feat: fetch allay's changes
smartcmd Jul 16, 2024
2443fff
feat: fetch allay's changes
smartcmd Jul 16, 2024
4acd0de
feat: fetch allay's changes
smartcmd Jul 24, 2024
a34946c
feat: return air if block type not found
smartcmd Aug 18, 2024
28c689d
feat: fetch allay's changes
smartcmd Aug 18, 2024
c97f25c
feat: support 1.21.20 and newer versions
smartcmd Aug 23, 2024
2e709da
feat: sync allay
smartcmd Aug 27, 2024
5f70ecb
feat: use jitpack
smartcmd Sep 4, 2024
bbf0915
build: use org.allaymc.allay as the group id
smartcmd Sep 7, 2024
732a894
ci: trigger github action
smartcmd Sep 17, 2024
1acdad5
ci: run github action when pushing
smartcmd Sep 17, 2024
f73eadd
ci: use jdk 21
smartcmd Sep 17, 2024
b432a4e
build: use jdk21 for allay platform
smartcmd Sep 17, 2024
2c476a2
build: fix build for allay platform
smartcmd Sep 17, 2024
328ebf5
build: disable cli platform
smartcmd Sep 17, 2024
c6df3c3
build: disable fabric platform
smartcmd Sep 17, 2024
ca4461b
build: disable bukkit platform
smartcmd Sep 17, 2024
6c8a7da
build: disable mixin platform
smartcmd Sep 17, 2024
2f2d43e
build: disable mixin platform
smartcmd Sep 17, 2024
18a2456
ci: upload jar
smartcmd Sep 17, 2024
1f01b99
ci: should check allay branch
smartcmd Sep 17, 2024
ce9fb53
build: disable useless modules
smartcmd Sep 17, 2024
76f12e0
build: prepare for merging
smartcmd Sep 18, 2024
4bad8f7
docs: format javadoc
smartcmd Sep 18, 2024
af2ac64
feat: using the new safe getter api
smartcmd Sep 20, 2024
6042f1c
build: update build.gradle.kts
smartcmd Sep 20, 2024
1496f2c
build: update jitpack repo link
smartcmd Oct 13, 2024
61ed302
feat: adapting terra 6.5.1 (WIP)
smartcmd Oct 14, 2024
4fc24f0
Merge branch 'PolyhedralDev:master' into allay
smartcmd Oct 14, 2024
6261f08
feat: remove java version declaration in allay platform as all platfo…
smartcmd Oct 14, 2024
0ca7171
docs: add README.md to allay platform
smartcmd Oct 14, 2024
a01f700
build: rollback github action file changes
smartcmd Oct 14, 2024
ece5213
feat: use macro in plugin.json and update author list
smartcmd Oct 14, 2024
cc14c71
build: move repo declaration to DependencyConfig.kt
smartcmd Oct 14, 2024
8a6ad95
refactor: delombok and move version info to Versions.kt
smartcmd Oct 14, 2024
f5de882
build: use fixed allay api version
smartcmd Oct 14, 2024
f2c5c15
refactor: use com.dfsek as the new package name
smartcmd Oct 14, 2024
b0bc37c
refactor: remove version info in mapping files
smartcmd Oct 14, 2024
8d63c40
refactor: replace 'var' with explicit type
smartcmd Oct 14, 2024
67fc2ba
docs: remove useless TODOs
smartcmd Oct 14, 2024
84fe879
fix: fix entrance in plugin.json
smartcmd Oct 14, 2024
f0d03d4
feat: fallback to FLAT generator if config pack name is missing
smartcmd Oct 14, 2024
df3e623
feat: implement config pack reloading
smartcmd Oct 14, 2024
d2107fd
fix: chunkGenerator should be overwritten after reloading
smartcmd Oct 14, 2024
071f9d3
docs: fix a typo in README.md
smartcmd Oct 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions buildSrc/src/main/kotlin/DependencyConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ fun Project.configureDependencies() {
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") {
name = "Sonatype Snapshots"
}
maven("https://repo.opencollab.dev/maven-releases/") {
name = "OpenCollab Releases"
}
maven("https://repo.opencollab.dev/maven-snapshots/") {
name = "OpenCollab Snapshots"
}
maven("https://storehouse.okaeri.eu/repository/maven-public/") {
name = "Okaeri"
}
}

dependencies {
Expand Down
4 changes: 4 additions & 0 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,8 @@ object Versions {
const val nbt = "6.1"
const val logback = "1.5.8"
}

object Allay {
const val api = "1cb3bb69c6"
}
}
10 changes: 10 additions & 0 deletions platforms/allay/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Allay platform

## Resource files

Current mapping version: je 1.21 to be 1.21.30

- `mapping/biomes.json` obtain from GeyserMC/mappings.
- `mapping/items.json` obtain from GeyserMC/mappings.
- `mapping/blocks.json` generated by using GeyserMC/mappings-generator, and it's origin name is `generator_blocks.json`.
- `je_block_default_states.json` converted from https://zh.minecraft.wiki/w/Module:Block_state_values.
5 changes: 5 additions & 0 deletions platforms/allay/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dependencies {
shadedApi(project(":common:implementation:base"))

compileOnly("org.allaymc.allay", "api", Versions.Allay.api)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package com.dfsek.terra.allay;

import com.dfsek.tectonic.api.TypeRegistry;
import com.dfsek.tectonic.api.depth.DepthTracker;
import com.dfsek.tectonic.api.exception.LoadException;
import org.allaymc.api.server.Server;
import org.allaymc.api.world.biome.BiomeId;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.util.HashSet;
import java.util.Set;

import com.dfsek.terra.AbstractPlatform;
import com.dfsek.terra.allay.delegate.AllayBiome;
import com.dfsek.terra.allay.generator.AllayGeneratorWrapper;
import com.dfsek.terra.allay.handle.AllayItemHandle;
import com.dfsek.terra.allay.handle.AllayWorldHandle;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.handle.ItemHandle;
import com.dfsek.terra.api.handle.WorldHandle;
import com.dfsek.terra.api.world.biome.PlatformBiome;

/**
* @author daoge_cmd
*/
public class AllayPlatform extends AbstractPlatform {

public static final Set<AllayGeneratorWrapper> GENERATOR_WRAPPERS = new HashSet<>();

protected static final AllayWorldHandle ALLAY_WORLD_HANDLE = new AllayWorldHandle();
protected static final AllayItemHandle ALLAY_ITEM_HANDLE = new AllayItemHandle();

public AllayPlatform() {
load();
}

@Override
public boolean reload() {
getTerraConfig().load(this);
getRawConfigRegistry().clear();
boolean succeed = getRawConfigRegistry().loadAll(this);

GENERATOR_WRAPPERS.forEach(wrapper -> {
getConfigRegistry().get(wrapper.getConfigPack().getRegistryKey()).ifPresent(pack -> {
wrapper.setConfigPack(pack);
var dimension = wrapper.getAllayWorldGenerator().getDimension();
TerraAllayPlugin.INSTANCE.getPluginLogger().info(
"Replaced pack in chunk generator for world {}",
dimension.getWorld().getWorldData().getName() + ":" + dimension.getDimensionInfo().dimensionId()
);
});
});
return succeed;
}

@Override
public @NotNull String platformName() {
return "Allay";
}

@Override
public @NotNull WorldHandle getWorldHandle() {
return ALLAY_WORLD_HANDLE;
}

@Override
public @NotNull ItemHandle getItemHandle() {
return ALLAY_ITEM_HANDLE;
}

@Override
public @NotNull File getDataFolder() {
return TerraAllayPlugin.INSTANCE.getPluginContainer().dataFolder().toFile();
}

@Override
public void runPossiblyUnsafeTask(@NotNull Runnable task) {
Server.getInstance().getScheduler().runLater(Server.getInstance(), task);
}

@Override
public void register(TypeRegistry registry) {
super.register(registry);
registry.registerLoader(BlockState.class, (type, o, loader, depthTracker) -> ALLAY_WORLD_HANDLE.createBlockState((String) o))
.registerLoader(PlatformBiome.class, (type, o, loader, depthTracker) -> parseBiome((String) o, depthTracker));
}

protected AllayBiome parseBiome(String id, DepthTracker depthTracker) throws LoadException {
if(!id.startsWith("minecraft:")) throw new LoadException("Invalid biome identifier " + id, depthTracker);
return new AllayBiome(BiomeId.fromId(Mapping.biomeIdJeToBe(id)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.dfsek.terra.allay;

import org.allaymc.api.utils.HashUtils;

import java.util.Map;
import java.util.TreeMap;


/**
* @author daoge_cmd
*/
public class JeBlockState {
protected final String identifier;
protected final TreeMap<String, String> properties;
protected int hash = Integer.MAX_VALUE;

public static JeBlockState fromString(String data) {
return new JeBlockState(data);
}

public static JeBlockState create(String identifier, TreeMap<String, String> properties) {
return new JeBlockState(identifier, properties);
}

private JeBlockState(String data) {
String[] strings = data.replace("[", ",").replace("]", ",").replace(" ", "").split(",");
this.identifier = strings[0];
this.properties = new TreeMap<>();
if (strings.length > 1) {
for (int i = 1; i < strings.length; i++) {
final String tmp = strings[i];
final int index = tmp.indexOf("=");
properties.put(tmp.substring(0, index), tmp.substring(index + 1));
}
}
completeMissingProperties();
}

public String getPropertyValue(String key) {
return properties.get(key);
}

private void completeMissingProperties() {
Map<String, String> defaultProperties = Mapping.getJeBlockDefaultProperties(identifier);
if(properties.size() == defaultProperties.size()) {
return;
}
defaultProperties.entrySet().stream().filter(entry -> !properties.containsKey(entry.getKey())).forEach(
entry -> properties.put(entry.getKey(), entry.getValue()));
}

private JeBlockState(String identifier, TreeMap<String, String> properties) {
this.identifier = identifier;
this.properties = properties;
}

public String toString(boolean includeProperties) {
if(!includeProperties) return identifier;
StringBuilder builder = new StringBuilder(identifier).append(";");
properties.forEach((k, v) -> builder.append(k).append("=").append(v).append(";"));
String str = builder.toString();
if (hash == Integer.MAX_VALUE) {
hash = HashUtils.fnv1a_32(str.getBytes());
}
return str;
}

public int getHash() {
if (hash == Integer.MAX_VALUE) {
hash = HashUtils.fnv1a_32(toString(true).getBytes());
}
return hash;
}

@Override
public String toString() {
return toString(true);
}
}
Loading