Skip to content

Commit

Permalink
Working on a storage engine which is version aware.
Browse files Browse the repository at this point in the history
  • Loading branch information
marchermans committed Jan 4, 2022
1 parent 09b650b commit 6f52f0c
Show file tree
Hide file tree
Showing 11 changed files with 168 additions and 6 deletions.
14 changes: 11 additions & 3 deletions Common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import java.util.regex.Pattern

plugins {
id('java')
id('java-library')
id('org.spongepowered.gradle.vanilla') version '0.2.1-SNAPSHOT'
}

Expand All @@ -23,15 +23,23 @@ minecraft {

project.sourceSets.main.resources.srcDir "src/datagen/generated"

configurations {
shadow

api.extendsFrom shadow
}

dependencies {
compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.4'

implementation project(':API')
implementation project(':Platforms:Core')
api project(':API')
api project(':Platforms:Core')

testImplementation project(':API')
testImplementation project(':Platforms:Core')

shadow "org.lz4:lz4-pure-java:${project.lz4_version}"

compileOnly 'org.jetbrains:annotations:16.0.2'
testCompileOnly 'org.jetbrains:annotations:16.0.2'
}
Expand Down
1 change: 1 addition & 0 deletions Common/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ crowdInDownloadDirectory=src/main/resources/assets/chiselsandbits/lang
usesCrowdInBuildingWithFilteredBranches=true
usesCrowdInUploadWithFilteredBranches=true

lz4_version=1.8.0

Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,7 @@ public void initializeWith(final BlockState blockState)
),
this.positionSupplier.get(),
null
) * StateEntrySize.current().getBitsPerBlock());
) * StateEntrySize.current().getBitsPerLayer());


if (!ILevelBasedPropertyAccessor.getInstance().propagatesSkylightDown(new SingleBlockWorldReader(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ public void deserializeFrom(@NotNull final FriendlyByteBuf packetBuffer)
public CompoundTag serializeNBT()
{
return DataCompressionUtils.compress(compoundTag -> {
compoundTag.put(NbtConstants.COMPRESSED_STORAGE, compressedSection.serializeNBT());
compoundTag.put(NbtConstants.CHISELED_DATA, compressedSection.serializeNBT());
compoundTag.put(NbtConstants.STATISTICS, statistics.serializeNBT());
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package mod.chiselsandbits.storage;

import mod.chiselsandbits.api.util.INBTSerializable;
import net.minecraft.nbt.CompoundTag;

public interface IStorageVersion extends INBTSerializable<CompoundTag>
{

boolean matchesVersion(final CompoundTag tagToCheck);
}
43 changes: 43 additions & 0 deletions Common/src/main/java/mod/chiselsandbits/storage/StorageEngine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package mod.chiselsandbits.storage;

import mod.chiselsandbits.api.util.INBTSerializable;
import mod.chiselsandbits.api.util.IPacketBufferSerializable;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import org.jetbrains.annotations.NotNull;

import java.util.LinkedList;

public class StorageEngine implements IPacketBufferSerializable, INBTSerializable<CompoundTag>
{

private final LinkedList<IStorageVersion> versions;

public StorageEngine(

) {}

@Override
public CompoundTag serializeNBT()
{
return null;
}

@Override
public void deserializeNBT(final CompoundTag nbt)
{

}

@Override
public void serializeInto(final @NotNull FriendlyByteBuf packetBuffer)
{

}

@Override
public void deserializeFrom(final @NotNull FriendlyByteBuf packetBuffer)
{

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public static void setValue(final byte[] target, final int value, final int bitM
}

final byte[] newTarget = bitSet.toByteArray();
System.arraycopy(new byte[target.length], 0, target, 0, target.length);
System.arraycopy(newTarget, 0, target, 0, newTarget.length);
}

Expand Down
49 changes: 49 additions & 0 deletions Platforms/Fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
}

apply plugin: com.matthewprenger.cursegradle.CurseGradlePlugin
apply plugin: com.github.jengelman.gradle.plugins.shadow.ShadowPlugin

archivesBaseName = "${mod_name}-fabric-${minecraft_version}"

Expand Down Expand Up @@ -72,6 +73,54 @@ jar {
from("LICENSE") {
rename { "${it}_${mod_name}" }
}

classifier = "slim"
}

shadowJar { shadowJarTask ->
from(project(":Common").sourceSets.main.output)
from(project(":API").sourceSets.main.output)
from(project(":Platforms:Core").sourceSets.main.output)
from(sourceSets.main.output)

from("LICENSE") {
rename { "${it}_${mod_name}" }
}

shadowJarTask.configurations = [project(":Common").configurations.shadow]

if (project.hasProperty("shadowRenamedNamespaces") && !project.shadowRenamedNamespaces.trim().isEmpty()) {
project.shadowRenamedNamespaces.split(',').each { n ->
if (n.contains(':')) {
def namespaceSpecs = n.split(':');
project.logger.lifecycle "Shading ${namespaceSpecs[0]} to ${namespaceSpecs[1]}"
shadowJarTask.relocate namespaceSpecs[0], namespaceSpecs[1]
}
}
}

manifest {
attributes([
'Maven-Artifact' : "${project.group}:${project.archivesBaseName}:${project.version}",
"Specification-Title" : project.mod_id,
"Specification-Vendor" : "ldtteam",
"Specification-Version" : "1", // We are version 1 of ourselves
"Implementation-Title" : project.name,
"Implementation-Version" : "${project.version}",
"Implementation-Vendor" : "ldtteam",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"Automatic-Module-Name" : "chiselsandbits",
"MixinConfigs": "chiselsandbits.mixins.json"
])
}

shadowJarTask.classifier = "universal"
}

tasks.remapJar.configure { remapTask ->
remapTask.dependsOn(tasks.shadowJar)
remapTask.mustRunAfter(tasks.shadowJar)
input = tasks.shadowJar.archivePath
}

if ((opc.hasPropertySet("curseApiKey") || opc.hasPropertySet("CURSEAPIKEY"))) {
Expand Down
48 changes: 47 additions & 1 deletion Platforms/Forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'maven-publish'
apply plugin: com.matthewprenger.cursegradle.CurseGradlePlugin
apply plugin: com.github.jengelman.gradle.plugins.shadow.ShadowPlugin

repositories {
mavenCentral()
maven {
name 'LDTTeam - Modding'
url 'https://ldtteam.jfrog.io/ldtteam/modding/'
Expand Down Expand Up @@ -50,6 +52,10 @@ configurations { configContainer ->
}
}

configurations {
forgeLibrary.extendsFrom project(':Common').configurations.shadow
}

minecraft {
mappings channel: 'official', version: minecraft_version

Expand Down Expand Up @@ -171,6 +177,8 @@ processResources {
jar.finalizedBy('reobfJar')

jar {
classifier 'slim'

manifest {
attributes([
'Maven-Artifact' : "${project.group}:${project.archivesBaseName}:${project.version}",
Expand All @@ -187,6 +195,44 @@ jar {
}
}

shadowJar { shadowJarTask ->
from(project(":Common").sourceSets.main.output)
from(project(":API").sourceSets.main.output)
from(project(":Platforms:Core").sourceSets.main.output)
from(sourceSets.main.output)

shadowJarTask.configurations = [project(":Common").configurations.shadow]

if (project.hasProperty("shadowRenamedNamespaces") && !project.shadowRenamedNamespaces.trim().isEmpty()) {
project.shadowRenamedNamespaces.split(',').each { n ->
if (n.contains(':')) {
def namespaceSpecs = n.split(':');
project.logger.lifecycle "Shading ${namespaceSpecs[0]} to ${namespaceSpecs[1]}"
shadowJarTask.relocate namespaceSpecs[0], namespaceSpecs[1]
}
}
}

manifest {
attributes([
'Maven-Artifact' : "${project.group}:${project.archivesBaseName}:${project.version}",
"Specification-Title" : project.mod_id,
"Specification-Vendor" : "ldtteam",
"Specification-Version" : "1", // We are version 1 of ourselves
"Implementation-Title" : project.name,
"Implementation-Version" : "${project.version}",
"Implementation-Vendor" : "ldtteam",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"Automatic-Module-Name" : "chiselsandbits",
"MixinConfigs": "chiselsandbits.mixins.json"
])
}

shadowJarTask.classifier = "universal"
}

build.dependsOn shadowJar

mixin {
add sourceSets.main, "chiselsandbits.refmap.json"
}
Expand Down Expand Up @@ -219,7 +265,7 @@ if ((opc.hasPropertySet("curseApiKey") || opc.hasPropertySet("CURSEAPIKEY"))) {
cp.addGameVersion(v)
}

cp.mainArtifact(jar)
cp.mainArtifact(shadowJar)
}
}
}
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ apply from: 'https://raw.githubusercontent.com/ldtteam/OperaPublicaCreator/main/
apply from: 'https://raw.githubusercontent.com/ldtteam/OperaPublicaCreator/main/gradle/modules/util.gradle'

repositories {
mavenCentral()
maven {
name 'LDTTeam - Modding'
url 'https://ldtteam.jfrog.io/ldtteam/modding/'
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ gitUrl=https://github.com/ChiselsAndBits/Chisels-and-Bits.git
gitConnectUrl=https://github.com/ChiselsAndBits/Chisels-and-Bits.git
projectUrl=https://www.curseforge.com/minecraft/mc-mods/chisels-bits

# Shadow mapping
shadowRenamedNamespaces=net.jpountz:mod.chiselsandbits.shaded.net.jpountz

# Gradle
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

0 comments on commit 6f52f0c

Please sign in to comment.