Skip to content

Commit

Permalink
WIN!Many 大饼
Browse files Browse the repository at this point in the history
  • Loading branch information
Chemiofitor4096 committed Nov 29, 2024
1 parent 3528aec commit 41e6be6
Show file tree
Hide file tree
Showing 56 changed files with 468 additions and 785 deletions.
8 changes: 2 additions & 6 deletions blockentity/common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,5 @@ base.archivesName = rootProject.name + "-blockentity"

kessoku {
module("base", "common")
module("platform", "common")
}

dependencies {
implementation libs.aj4j
}
module("data", "common")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package band.kessoku.lib.api.blockentity;

public class BlockEntityAccess {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package band.kessoku.lib.api.blockentity;

import org.slf4j.Marker;
import org.slf4j.MarkerFactory;

public class KessokuBlockEntity {
public static final String MOD_ID = "kessoku_blockentity";
public static final String NAME = "Kessoku Block Entity API";
public static final Marker MARKER = MarkerFactory.getMarker("[" + NAME +"]");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"required": true,
"package": "band.kessoku.lib.mixin.blockentity",
"compatibilityLevel": "JAVA_21",
"injectors": {
"defaultRequire": 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
*/
package band.kessoku.lib.impl.blockentity.fabric;

import band.kessoku.lib.api.KessokuLib;
import band.kessoku.lib.api.blockentity.KessokuBlockEntity;
import net.fabricmc.api.ModInitializer;

public class KessokuBlockEntityFabric implements ModInitializer {
@Override
public void onInitialize() {

KessokuLib.loadModule(KessokuBlockEntity.class);
}
}
2 changes: 1 addition & 1 deletion blockentity/fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": "kessoku_blockentity",
"version": "${version}",
"name": "Kessoku Block Entity",
"description": "Common blockentity API.",
"description": "A API of Block Entity Building.",
"authors": [
"Kessoku Tea Time"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package band.kessoku.lib.api.data;
package band.kessoku.lib.impl.blockentity.forge;

import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.RegistryWrapper;
import band.kessoku.lib.api.KessokuLib;
import band.kessoku.lib.api.blockentity.KessokuBlockEntity;
import net.neoforged.fml.common.Mod;

/**
* An interface used to normalize serialization of {@link NbtCompound NBT}.
*/
public interface NBTSerializable {
void write(NbtCompound nbt, RegistryWrapper.WrapperLookup registries);
void read(NbtCompound nbt, RegistryWrapper.WrapperLookup registries);
@Mod(KessokuBlockEntity.MOD_ID)
public final class KessokuBlockEntityNeoforge {
public KessokuBlockEntityNeoforge() {
KessokuLib.loadModule(KessokuBlockEntity.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ modId = "kessoku_blockentity"
version = "${version}"
displayName = "Kessoku Block Entity"
description = '''
Common blockentity API.
A API of Block Entity Building.
'''
logoFile = "icon.png"
authors = "Kessoku Tea Time"
Expand Down
10 changes: 10 additions & 0 deletions component/common/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apply from: rootProject.file("gradle/scripts/klib-common.gradle")

base.archivesName = rootProject.name + "-component"

kessoku {
module("base", "common")
module("registry", "common")
module("data", "common")
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package band.kessoku.lib.api.component;

import band.kessoku.lib.api.registry.KessokuRegistry;
import band.kessoku.lib.impl.Progress;
import net.minecraft.component.ComponentType;
import net.minecraft.util.Identifier;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;

public class KessokuComponent {
public static final String MOD_ID = "kessoku_component";
public static final String NAME = "Kessoku Component API";
public static final Marker MARKER = MarkerFactory.getMarker("[" + NAME +"]");

public static final ComponentType<Progress> PROGRESS_COMPONENT_TYPE;

public static void init() {

}

static {
PROGRESS_COMPONENT_TYPE = KessokuRegistry.registerComponentType(
Identifier.of("kessoku", "progress"),
builder -> builder.codec(Progress.CODEC).packetCodec(Progress.PACKET_CODEC)
);
}
}
Binary file added component/common/src/main/resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions component/fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import net.fabricmc.loom.util.ModPlatform

apply from: rootProject.file("gradle/scripts/klib-fabric.gradle")

base.archivesName = rootProject.name + "-component"

kessoku {
module("base", "common")

common("component", ModPlatform.FABRIC)
shadowBundle("component", ModPlatform.FABRIC)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package band.kessoku.lib.impl.component.fabric;

import band.kessoku.lib.api.KessokuLib;
import band.kessoku.lib.api.component.KessokuComponent;
import net.fabricmc.api.ModInitializer;

public class KessokuComponentFabric implements ModInitializer {
@Override
public void onInitialize() {
KessokuLib.loadModule(KessokuComponent.class);
KessokuComponent.init();
}
}
36 changes: 36 additions & 0 deletions component/fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"schemaVersion": 1,
"id": "kessoku_data",
"version": "${version}",
"name": "Kessoku Component",
"description": "A API about component in Minecraft.",
"authors": [
"Kessoku Tea Time"
],
"contact": {
"homepage": "https://modrinth.com/mod/kessoku-lib",
"sources": "https://github.com/KessokuTeaTime/KessokuLib",
"issues": "https://github.com/KessokuTeaTime/KessokuLib/issues"
},
"license": "LGPL-3.0-only",
"icon": "icon.png",
"entrypoints": {
"main": [
"band.kessoku.lib.impl.component.fabric.KessokuComponentFabric"
]
},
"environment": "*",
"depends": {
"fabricloader": ">=0.16.0",
"minecraft": "1.21",
"java": ">=21",
"fabric-api": "*"
},
"custom": {
"modmenu": {
"badges": [
"library"
]
}
}
}
12 changes: 12 additions & 0 deletions component/neo/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import net.fabricmc.loom.util.ModPlatform

apply from: rootProject.file("gradle/scripts/klib-neo.gradle")

base.archivesName = rootProject.name + "-component"

kessoku {
module("base", "common")

common("component", ModPlatform.NEOFORGE)
shadowBundle("component", ModPlatform.NEOFORGE)
}
1 change: 1 addition & 0 deletions component/neo/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loom.platform=neoforge
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package band.kessoku.lib.impl.component.forge;

import band.kessoku.lib.api.KessokuLib;
import band.kessoku.lib.api.component.KessokuComponent;
import net.neoforged.fml.common.Mod;

@Mod(KessokuComponent.MOD_ID)
public class KessokuComponentForge {
public KessokuComponentForge() {
KessokuLib.loadModule(KessokuComponent.class);
KessokuComponent.init();
}
}
29 changes: 29 additions & 0 deletions component/neo/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
modLoader = "javafml"
loaderVersion = "[4,)"
license = "LGPL-3.0-only"
issueTrackerURL = "https://github.com/KessokuTeaTime/KessokuLib/issues"

[[mods]]
modId = "kessoku_data"
version = "${version}"
displayName = "Kessoku Data"
description = '''
A API about component in Minecraft.
'''
logoFile = "icon.png"
authors = "Kessoku Tea Time"
displayURL = "https://modrinth.com/mod/kessoku-lib"

[[dependencies.kessoku_data]]
modId = "neoforge"
type = "required"
versionRange = "[21.0,)"
ordering = "NONE"
side = "BOTH"

[[dependencies.kessoku_data]]
modId = "minecraft"
type = "required"
versionRange = "[1.21,)"
ordering = "NONE"
side = "BOTH"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package band.kessoku.lib.api.data;

@FunctionalInterface
public interface DataAccess<T, S extends DataStructure> {
S get(T target);
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
/*
* Copyright (c) 2024 KessokuTeaTime
*
* Licensed under the GNU Lesser General Pubic License, Version 3 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/lgpl-3.0.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package band.kessoku.lib.api.data;

/**
* This is an interface used to abstract a structure holding some data and implement processing logic.
* <p>
* When building structure, data must be member variable and {@link DataStructure#integrate(Data) "integrate()"}
* can be used to hold data for other usages.
* </p>
*/
public interface DataStructure {
<T, K extends Data<T>> K integrate(K data);
<K extends DataStructure> K integrate(K dataStructure);

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ public final class KessokuData {
public static final String MOD_ID = "kessoku_data";
public static final String NAME = "Kessoku Data API";
public static final Marker MARKER = MarkerFactory.getMarker("[" + NAME +"]");

public static void init() {

}
}
66 changes: 66 additions & 0 deletions data/common/src/main/java/band/kessoku/lib/impl/Progress.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package band.kessoku.lib.impl;

import band.kessoku.lib.api.data.DataStructure;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.network.RegistryByteBuf;
import net.minecraft.network.codec.PacketCodec;

public class Progress implements DataStructure {
public static final Codec<Progress> CODEC = RecordCodecBuilder.create(instance -> instance.group(
Codec.INT.fieldOf("time").forGetter(Progress::time),
Codec.INT.fieldOf("totalTime").forGetter(Progress::totalTime)
).apply(instance, Progress::new));
public static final PacketCodec<RegistryByteBuf, Progress> PACKET_CODEC = new PacketCodec<>() {
@Override
public Progress decode(RegistryByteBuf buf) {
return new Progress(buf.readInt(), buf.readInt());
}

@Override
public void encode(RegistryByteBuf buf, Progress value) {
buf.writeInt(value.time());
buf.writeInt(value.totalTime());
}
};

private int time = 0;
private int totalTime;

private Progress(int time, int totalTime) {
this.time = time;
this.totalTime = totalTime;

}

public Progress(int totalTime) {
this.totalTime = totalTime;
}

public void process() {
process(1);
}

public void process(int time) {
this.time += time;
}

public void reset(int totalTime) {
this.time = 0;
this.totalTime = totalTime;
}

public int time() {
return this.time;
}

public int totalTime() {
return this.totalTime;
}

public float decimal() {
if (totalTime == 0)
return 0.0f;
return ((float) time) / totalTime;
}
}
Loading

0 comments on commit 41e6be6

Please sign in to comment.