Skip to content

Commit d85d95c

Browse files
committed
Start porting
1 parent 2522dec commit d85d95c

File tree

14 files changed

+80
-68
lines changed

14 files changed

+80
-68
lines changed

build.gradle.kts

+10-14
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@ architectury {
1717
}
1818

1919
allprojects {
20-
apply(plugin = "java")
21-
2220
version = modVersion
2321
group = "dev.tonimatas"
2422

2523
repositories {
24+
maven("https://maven.neoforged.net")
2625
maven("https://maven.blamejared.com")
27-
maven("https://maven.architectury.dev")
28-
maven("https://maven.neoforged.net/")
26+
maven("https://maven.resourcefulbees.com/repository/maven-public")
2927
}
3028
}
3129

@@ -73,10 +71,16 @@ subprojects {
7371
neoForge()
7472
}
7573
}
74+
75+
val architecturyVersion: String by extra
76+
val rlMinecraftVersion: String by extra
77+
78+
dependencies {
79+
"modApi"("com.teamresourceful.resourcefullib:resourcefullib-$name-$rlMinecraftVersion:$architecturyVersion")
80+
}
7681

7782
if (name != "common") {
7883
val loaderName = if (name == "fabric") "Fabric" else "NeoForge"
79-
val architecturyVersion: String by extra
8084

8185
val common: Configuration by configurations.creating
8286
val shadowCommon: Configuration by configurations.creating
@@ -86,8 +90,6 @@ subprojects {
8690
configurations["development$loaderName"].extendsFrom(common)
8791

8892
dependencies {
89-
"modApi"("dev.architectury:architectury-$name:$architecturyVersion")
90-
9193
common(project(path = ":common", configuration = "namedElements")) { isTransitive = false }
9294
shadowCommon(project(path = ":common", configuration = "transformProduction$loaderName")) { isTransitive = false }
9395
}
@@ -99,7 +101,7 @@ subprojects {
99101

100102
tasks.withType<RemapJarTask> {
101103
val shadowTask = tasks.getByName<ShadowJar>("shadowJar")
102-
input.set(shadowTask.archiveFile)
104+
inputFile.set(shadowTask.archiveFile)
103105
dependsOn(shadowTask)
104106
archiveClassifier.set("")
105107
}
@@ -108,12 +110,6 @@ subprojects {
108110
archiveClassifier.set("dev")
109111
}
110112

111-
//tasks.sourcesJar {
112-
// val commonSources = project(":common").tasks.sourcesJar.get()
113-
// dependsOn(commonSources)
114-
// from(commonSources.archiveFile.map { zipTree(it) })
115-
//}
116-
117113
components.getByName<AdhocComponentWithVariants>("java").apply {
118114
withVariantsFromConfiguration(project.configurations["shadowRuntimeElements"]) {
119115
skip()

common/build.gradle.kts

-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
val minecraftVersion: String by extra
22
val fabricLoaderVersion: String by extra
3-
val architecturyVersion: String by extra
43
val jeiVersion: String by extra
54

65
dependencies {
76
modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion")
8-
9-
modApi("dev.architectury:architectury:$architecturyVersion")
107

118
modCompileOnly("mezz.jei:jei-$minecraftVersion-common-api:$jeiVersion")
129
modRuntimeOnly("mezz.jei:jei-$minecraftVersion-common:$jeiVersion")

common/src/main/java/dev/tonimatas/krystalcraft/block/AbstractMachineBlock.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package dev.tonimatas.krystalcraft.block;
22

3+
import com.teamresourceful.resourcefullib.common.menu.ContentMenuProvider;
4+
import com.teamresourceful.resourcefullib.common.menu.MenuContentHelper;
35
import com.teamresourceful.resourcefullib.common.registry.RegistryEntry;
46
import earth.terrarium.botarium.common.energy.EnergyApi;
57
import earth.terrarium.botarium.common.menu.MenuHooks;
@@ -76,7 +78,7 @@ protected boolean useFacing() {
7678
public @NotNull InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
7779
if (!level.isClientSide) {
7880
if (level.getBlockEntity(pos) instanceof BaseBlockEntity machineBlock) {
79-
MenuHooks.openMenu((ServerPlayer) player, machineBlock);
81+
MenuContentHelper.open((ServerPlayer) player, machineBlock);
8082
}
8183
}
8284

common/src/main/java/dev/tonimatas/krystalcraft/blockentity/CombustionGeneratorBlockEntity.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import earth.terrarium.botarium.common.energy.impl.WrappedBlockEnergyContainer;
66
import earth.terrarium.botarium.util.CommonHooks;
77
import net.minecraft.core.BlockPos;
8+
import net.minecraft.core.HolderLookup;
89
import net.minecraft.nbt.CompoundTag;
910
import net.minecraft.world.entity.player.Inventory;
1011
import net.minecraft.world.entity.player.Player;
@@ -27,15 +28,15 @@ public CombustionGeneratorBlockEntity(BlockPos blockPos, BlockState blockState)
2728
}
2829

2930
@Override
30-
public void load(CompoundTag compoundTag) {
31-
super.load(compoundTag);
31+
protected void loadAdditional(CompoundTag compoundTag, HolderLookup.Provider provider) {
32+
super.loadAdditional(compoundTag, provider);
3233
this.burnTime = compoundTag.getInt("BurnTime");
3334
this.totalBurnTime = compoundTag.getInt("TotalBurnTime");
3435
}
3536

3637
@Override
37-
public void saveAdditional(CompoundTag compoundTag) {
38-
super.saveAdditional(compoundTag);
38+
protected void saveAdditional(CompoundTag compoundTag, HolderLookup.Provider provider) {
39+
super.saveAdditional(compoundTag, provider);
3940
compoundTag.putInt("BurnTime", this.burnTime);
4041
compoundTag.putInt("TotalBurnTime", this.totalBurnTime);
4142
}

common/src/main/java/dev/tonimatas/krystalcraft/blockentity/util/BaseBlockEntity.java

+14-11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import net.minecraft.MethodsReturnNonnullByDefault;
55
import net.minecraft.core.BlockPos;
66
import net.minecraft.core.Direction;
7+
import net.minecraft.core.HolderLookup;
78
import net.minecraft.core.NonNullList;
89
import net.minecraft.nbt.CompoundTag;
910
import net.minecraft.network.FriendlyByteBuf;
@@ -19,6 +20,7 @@
1920
import net.minecraft.world.level.block.entity.BlockEntityType;
2021
import net.minecraft.world.level.block.state.BlockState;
2122
import dev.tonimatas.krystalcraft.inventory.ModInventory;
23+
import org.jetbrains.annotations.Nullable;
2224

2325
@MethodsReturnNonnullByDefault
2426
public abstract class BaseBlockEntity extends BlockEntity implements ExtraDataMenuProvider, ModInventory, WorldlyContainer {
@@ -32,7 +34,7 @@ public BaseBlockEntity(BlockEntityType<?> blockEntityType, BlockPos blockPos, Bl
3234
public abstract void tick();
3335

3436
@Override
35-
public AbstractContainerMenu createMenu(int i, Inventory inventory, Player player) {
37+
public @Nullable AbstractContainerMenu createMenu(int i, Inventory inventory, Player player) {
3638
return null;
3739
}
3840

@@ -50,19 +52,21 @@ public void writeExtraData(ServerPlayer player, FriendlyByteBuf buffer) {
5052
buffer.writeBlockPos(this.getBlockPos());
5153
}
5254

55+
5356
@Override
54-
public void load(CompoundTag compoundTag) {
55-
super.load(compoundTag);
57+
protected void loadAdditional(CompoundTag compoundTag, HolderLookup.Provider provider) {
58+
super.loadAdditional(compoundTag, provider);
59+
5660
if (getInventorySize() > 0) {
57-
ContainerHelper.loadAllItems(compoundTag, this.inventory);
61+
ContainerHelper.loadAllItems(compoundTag, this.inventory, provider);
5862
}
5963
}
6064

6165
@Override
62-
protected void saveAdditional(CompoundTag compoundTag) {
63-
super.saveAdditional(compoundTag);
66+
protected void saveAdditional(CompoundTag compoundTag, HolderLookup.Provider provider) {
67+
super.saveAdditional(compoundTag, provider);
6468
if (getInventorySize() > 0) {
65-
ContainerHelper.saveAllItems(compoundTag, this.inventory);
69+
ContainerHelper.saveAllItems(compoundTag, this.inventory, provider);
6670
}
6771
}
6872

@@ -90,10 +94,9 @@ public NonNullList<ItemStack> getItems() {
9094
return inventory;
9195
}
9296

97+
9398
@Override
94-
public CompoundTag getUpdateTag() {
95-
return this.saveWithoutMetadata();
99+
public CompoundTag getUpdateTag(HolderLookup.Provider provider) {
100+
return this.saveWithoutMetadata(provider);
96101
}
97-
98-
99102
}

common/src/main/java/dev/tonimatas/krystalcraft/blockentity/util/BurnBlockEntity.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import net.minecraft.core.BlockPos;
44
import net.minecraft.core.Direction;
5+
import net.minecraft.core.HolderLookup;
56
import net.minecraft.nbt.CompoundTag;
67
import net.minecraft.world.item.ItemStack;
78
import net.minecraft.world.level.block.entity.BlockEntityType;
@@ -17,16 +18,16 @@ public BurnBlockEntity(BlockEntityType<?> blockEntityType, BlockPos blockPos, Bl
1718
}
1819

1920
@Override
20-
public void load(CompoundTag compoundTag) {
21-
super.load(compoundTag);
21+
protected void loadAdditional(CompoundTag compoundTag, HolderLookup.Provider provider) {
22+
super.loadAdditional(compoundTag, provider);
2223
this.progress = compoundTag.getInt("Progress");
2324
this.burnTime = compoundTag.getInt("BurnTime");
2425
this.burnTimeTotal = compoundTag.getInt("BurnTimeTotal");
2526
}
2627

2728
@Override
28-
public void saveAdditional(CompoundTag compoundTag) {
29-
super.saveAdditional(compoundTag);
29+
protected void saveAdditional(CompoundTag compoundTag, HolderLookup.Provider provider) {
30+
super.saveAdditional(compoundTag, provider);
3031
compoundTag.putInt("Progress", this.progress);
3132
compoundTag.putInt("BurnTime", this.burnTime);
3233
compoundTag.putInt("BurnTimeTotal", this.burnTimeTotal);

common/src/main/java/dev/tonimatas/krystalcraft/blockentity/util/EnergyBlockEntity.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import earth.terrarium.botarium.common.item.ItemStackHolder;
77
import net.minecraft.core.BlockPos;
88
import net.minecraft.core.Direction;
9+
import net.minecraft.core.HolderLookup;
910
import net.minecraft.nbt.CompoundTag;
1011
import net.minecraft.world.level.Level;
1112
import net.minecraft.world.level.block.entity.BlockEntity;
@@ -30,14 +31,14 @@ public WrappedBlockEnergyContainer getEnergyStorage() {
3031
}
3132

3233
@Override
33-
public void load(CompoundTag compoundTag) {
34-
super.load(compoundTag);
34+
protected void loadAdditional(CompoundTag compoundTag, HolderLookup.Provider provider) {
35+
super.loadAdditional(compoundTag, provider);
3536
energyContainer.setEnergy(compoundTag.getLong("Energy"));
3637
}
3738

3839
@Override
39-
public void saveAdditional(CompoundTag compoundTag) {
40-
super.saveAdditional(compoundTag);
40+
protected void saveAdditional(CompoundTag compoundTag, HolderLookup.Provider provider) {
41+
super.saveAdditional(compoundTag, provider);
4142
compoundTag.putLong("Energy", energyContainer.getStoredEnergy());
4243
}
4344

common/src/main/java/dev/tonimatas/krystalcraft/blockentity/util/FactoryBlockEntity.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import net.minecraft.core.BlockPos;
44
import net.minecraft.core.Direction;
5+
import net.minecraft.core.HolderLookup;
56
import net.minecraft.nbt.CompoundTag;
67
import net.minecraft.world.item.ItemStack;
78
import net.minecraft.world.level.block.entity.BlockEntityType;
@@ -15,14 +16,14 @@ public FactoryBlockEntity(BlockEntityType<?> blockEntityType, BlockPos blockPos,
1516
}
1617

1718
@Override
18-
public void load(CompoundTag compoundTag) {
19-
super.load(compoundTag);
19+
protected void loadAdditional(CompoundTag compoundTag, HolderLookup.Provider provider) {
20+
super.loadAdditional(compoundTag, provider);
2021
this.progress = compoundTag.getInt("Progress");
2122
}
2223

2324
@Override
24-
public void saveAdditional(CompoundTag compoundTag) {
25-
super.saveAdditional(compoundTag);
25+
protected void saveAdditional(CompoundTag compoundTag, HolderLookup.Provider provider) {
26+
super.saveAdditional(compoundTag, provider);
2627
compoundTag.putInt("Progress", this.progress);
2728
}
2829

common/src/main/java/dev/tonimatas/krystalcraft/client/KrystalCraftClient.java

-17
This file was deleted.

fabric/build.gradle.kts

+5
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ tasks.withType<ProcessResources> {
2929
}
3030
}
3131

32+
tasks.sourcesJar {
33+
val commonSources = project(":common").tasks.sourcesJar.get()
34+
dependsOn(commonSources)
35+
from(commonSources.archiveFile.map { zipTree(it) })
36+
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
package dev.tonimatas.krystalcraft.fabric;
22

3-
import dev.tonimatas.krystalcraft.client.KrystalCraftClient;
3+
import dev.tonimatas.krystalcraft.client.screen.*;
4+
import dev.tonimatas.krystalcraft.registry.ModMenus;
45
import net.fabricmc.api.ClientModInitializer;
6+
import net.minecraft.client.gui.screens.MenuScreens;
57

68
public class KrystalCraftClientFabric implements ClientModInitializer {
79
@Override
810
public void onInitializeClient() {
9-
KrystalCraftClient.init();
11+
MenuScreens.register(ModMenus.COMBINING_STATION_MENU.get(), CombiningStationScreen::new);
12+
MenuScreens.register(ModMenus.COMBINING_FACTORY_MENU.get(), CombiningFactoryScreen::new);
13+
MenuScreens.register(ModMenus.CRUSHING_STATION_MENU.get(), CrushingStationScreen::new);
14+
MenuScreens.register(ModMenus.CRUSHING_FACTORY_MENU.get(), CrushingFactoryScreen::new);
15+
MenuScreens.register(ModMenus.CUTTING_STATION_MENU.get(), CuttingStationScreen::new);
16+
MenuScreens.register(ModMenus.CUTTING_FACTORY_MENU.get(), CuttingFactoryScreen::new);
17+
MenuScreens.register(ModMenus.COMBUSTION_GENERATOR_MENU.get(), CombustionGeneratorScreen::new);
1018
}
1119
}

gradle.properties

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ org.gradle.jvmargs=-Xmx3G
44
modVersion=0.0.4.4
55

66
# Dependencies
7-
architecturyVersion=13.0.8
8-
architecturyRange=13.0.0
7+
architecturyVersion=3.0.11
8+
rlMinecraftVersion=1.21
9+
architecturyRange=3.0.0
910

1011
# To update
1112
jeiVersion=19.21.0.247

neoforge/build.gradle.kts

+6
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@ tasks.withType<ProcessResources> {
2525
expand(replaceProperties)
2626
}
2727
}
28+
29+
tasks.sourcesJar {
30+
val commonSources = project(":common").tasks.sourcesJar.get()
31+
dependsOn(commonSources)
32+
from(commonSources.archiveFile.map { zipTree(it) })
33+
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package dev.tonimatas.krystalcraft.neoforge;
22

33
import dev.tonimatas.krystalcraft.KrystalCraft;
4-
import dev.tonimatas.krystalcraft.client.KrystalCraftClient;
4+
import dev.tonimatas.krystalcraft.client.screen.*;
5+
import dev.tonimatas.krystalcraft.registry.ModMenus;
56
import net.neoforged.api.distmarker.Dist;
67
import net.neoforged.bus.api.SubscribeEvent;
78
import net.neoforged.fml.common.EventBusSubscriber;
@@ -11,6 +12,12 @@
1112
public class KrystalCraftClientForge {
1213
@SubscribeEvent
1314
public static void onClientSetup(RegisterMenuScreensEvent event) {
14-
KrystalCraftClient.init();
15+
event.register(ModMenus.COMBINING_STATION_MENU.get(), CombiningStationScreen::new);
16+
event.register(ModMenus.COMBINING_FACTORY_MENU.get(), CombiningFactoryScreen::new);
17+
event.register(ModMenus.CRUSHING_STATION_MENU.get(), CrushingStationScreen::new);
18+
event.register(ModMenus.CRUSHING_FACTORY_MENU.get(), CrushingFactoryScreen::new);
19+
event.register(ModMenus.CUTTING_STATION_MENU.get(), CuttingStationScreen::new);
20+
event.register(ModMenus.CUTTING_FACTORY_MENU.get(), CuttingFactoryScreen::new);
21+
event.register(ModMenus.COMBUSTION_GENERATOR_MENU.get(), CombustionGeneratorScreen::new);
1522
}
1623
}

0 commit comments

Comments
 (0)