Skip to content

Commit 628fc86

Browse files
"Implement Shadow Inventory and Tag Support for Items"
Extend functionality of ShadowStoneItem and add a custom inventory ShadowStoneInventory. Also, added DarkenDepthsItemTag file that provides tag support for darken depth items. For managing these changes, ShadowCoreItem is added and Armor changing function is removed from ShadowStoneItem, as now it supports custom inventory. The ShadowStoneInventory read and write NBT data, which is necessary to persist the inventory across sessions. Made additional changes in PlayerEntityMixin to support custom inventory opening and item saving. Version is updated to reflect these substantial changes.ing"
1 parent 4bd2ecf commit 628fc86

File tree

14 files changed

+175
-28
lines changed

14 files changed

+175
-28
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ jobs:
4444
modrinth-id: walrejrR
4545
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
4646
modrinth-files: "build/libs/darkendepths-${{ steps.build.outputs.version }}.jar"
47-
name: Darken Depths 1.20.2-1.0.0
47+
name: "Darken Depths ${{ steps.build.outputs.version }}"
4848
version: ${{ steps.build.outputs.version }}
4949
version-type: beta
50-
changelog: "${{steps.build.outputs.changelog}}"
50+
changelog: ${{steps.build.outputs.changelog}}
5151
game-version: 1.20.2
5252
loaders: fabric
5353
dependencies:

build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,12 @@ publishing {
113113
// The repositories here will be used for publishing your artifact, not for
114114
// retrieving dependencies.
115115
}
116+
117+
118+
}
119+
120+
if (!System.properties['os.name'].toLowerCase().contains('windows')) {
116121
exec {
117-
commandLine "echo", "##[set-output name=version;]${project.version}";
122+
commandLine "echo", "##[set-output name=version;]${project.version}"
118123
}
119124
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ org.gradle.jvmargs=-Xmx1G
1010

1111

1212
# Mod Properties
13-
mod_version = beta-1.20.2-1.1.0
13+
mod_version = beta-1.20.2-1.2.0
1414
maven_group = me.codecraft
1515
archives_base_name = darkendepths
1616
modid=darkendepths

src/main/generated/assets/darkendepths/lang/en_us.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
"item.darkendepths.dark_pickaxe": "§5§lDarkened Pickaxe",
1313
"item.darkendepths.dark_shovel": "§5§lDarkened Shovel",
1414
"item.darkendepths.dark_sword": "§5§lDarkened Sword",
15-
"item.darkendepths.shadow_stone": "Shadow Stone"
15+
"item.darkendepths.shadow_stone": "Shadow Stone",
16+
"screen.darkendepths.shadowstone_inventory": "Shadow's Inventory"
1617
}

src/main/java/me/codecraft/darkendepths/DarkenDepthsDataGenerator.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
import me.codecraft.darkendepths.datagen.*;
44
import me.codecraft.darkendepths.datagen.loottables.DarkenDepthsBlockLootTablesGenerator;
5-
import me.codecraft.darkendepths.datagen.tags.DarkenDepthsBlockMiningLevelGenerator;
5+
import me.codecraft.darkendepths.datagen.tags.DarkenDepthsBlockTag;
6+
import me.codecraft.darkendepths.datagen.tags.DarkenDepthsItemTag;
67
import me.codecraft.darkendepths.world.DarkenDepthsConfiguredFeatures;
78
import me.codecraft.darkendepths.world.DarkenDepthsPlacedFeatures;
89
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
910
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
1011
import net.minecraft.registry.RegistryBuilder;
1112
import net.minecraft.registry.RegistryKeys;
13+
import net.minecraft.world.gen.feature.OrePlacedFeatures;
1214
import org.jetbrains.annotations.Nullable;
1315

1416
public class DarkenDepthsDataGenerator implements DataGeneratorEntrypoint {
@@ -20,15 +22,16 @@ public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
2022
pack.addProvider(DarkenDepthsRecipesGenerator::new);
2123
pack.addProvider(DarkenDepthsAdvancementGenerator::new);
2224
pack.addProvider(DarkenDepthsBlockLootTablesGenerator::new);
23-
pack.addProvider(DarkenDepthsBlockMiningLevelGenerator::new);
25+
pack.addProvider(DarkenDepthsBlockTag::new);
26+
pack.addProvider(DarkenDepthsItemTag::new);
2427
pack.addProvider(DarkenDepthsWorldGenerator::new);
2528
// pack.addProvider(DarkenDepthsBiomesGenerator::new);
2629
}
2730
@Override
2831
public void buildRegistry(RegistryBuilder registryBuilder) {
2932
registryBuilder.addRegistry(RegistryKeys.CONFIGURED_FEATURE, DarkenDepthsConfiguredFeatures::bootstrap);
3033
registryBuilder.addRegistry(RegistryKeys.PLACED_FEATURE, DarkenDepthsPlacedFeatures::bootstrap);
31-
// OrePlacedFeatures
34+
// OrePlacedFeatures.
3235
}
3336

3437
@Override

src/main/java/me/codecraft/darkendepths/datagen/DarkenDepthsLangGenerator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import me.codecraft.darkendepths.DarkenDepths;
44
import me.codecraft.darkendepths.blocks.DarkenDepthsBlocks;
55
import me.codecraft.darkendepths.item.DarkenDepthsItems;
6+
import me.codecraft.darkendepths.status_effects.DarkenDepthsStatusEffect;
7+
import me.codecraft.darkendepths.status_effects.DarkenDepthsStatusEffects;
68
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
79
import net.fabricmc.fabric.api.datagen.v1.provider.FabricLanguageProvider;
810

@@ -14,6 +16,7 @@ public DarkenDepthsLangGenerator(FabricDataOutput dataOutput) {
1416
@Override
1517
public void generateTranslations(TranslationBuilder translationBuilder) {
1618
translationBuilder.add(DarkenDepthsItems.SHADOW_STONE, "Shadow Stone");
19+
translationBuilder.add(DarkenDepthsItems.DARKSHADOW_CORE, "DarkShadow's Core");
1720
translationBuilder.add(DarkenDepthsBlocks.DARKENED_STONE_ORE, "§5Darkened Stone Ore");
1821
translationBuilder.add(DarkenDepthsBlocks.DEEPSLATE_DARKENED_STONE_ORE, "§5Deepslate Darkened Stone Ore");
1922
translationBuilder.add(DarkenDepthsItems.DARK_ESSENCE, "§5§lDark Essence");
@@ -27,6 +30,8 @@ public void generateTranslations(TranslationBuilder translationBuilder) {
2730
translationBuilder.add(DarkenDepthsItems.DARK_LEGGINGS, "§5§lDarkened Leggings");
2831
translationBuilder.add(DarkenDepthsItems.DARK_BOOTS, "§5§lDarkened Boots");
2932
translationBuilder.add(DarkenDepths.MOD_ID+".advancement.get_darkness_armor", "Get Full Darkened Armor");
33+
translationBuilder.add("screen.darkendepths.shadowstone_inventory","Shadow's Inventory");
34+
translationBuilder.add(DarkenDepthsStatusEffects.SHADOW_PROTECTION,"Shadow's Protection");
3035
}
3136
}
3237

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package me.codecraft.darkendepths.datagen.tags;
22

3-
import me.codecraft.darkendepths.DarkenDepths;
43
import me.codecraft.darkendepths.blocks.DarkenDepthsBlocks;
54
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
65
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
@@ -12,12 +11,12 @@
1211

1312
import java.util.concurrent.CompletableFuture;
1413

15-
public class DarkenDepthsBlockMiningLevelGenerator extends FabricTagProvider.BlockTagProvider {
14+
public class DarkenDepthsBlockTag extends FabricTagProvider.BlockTagProvider {
1615

1716
private static final TagKey<Block> MINEABLE_PICKAXE = TagKey.of(RegistryKey.ofRegistry(new Identifier("minecraft:mineable/pickaxe")), new Identifier("minecraft:mineable/pickaxe"));
1817
private static final TagKey<Block> NEED_TOOL_LEVEL_3= TagKey.of(RegistryKey.ofRegistry(new Identifier("fabric:needs_tool_level_3")), new Identifier("fabric:needs_tool_level_3"));
1918

20-
public DarkenDepthsBlockMiningLevelGenerator(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
19+
public DarkenDepthsBlockTag(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
2120
super(output, registriesFuture);
2221
}
2322

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package me.codecraft.darkendepths.datagen.tags;
2+
3+
import me.codecraft.darkendepths.DarkenDepths;
4+
import me.codecraft.darkendepths.inventory.ShadowStoneInventory;
5+
import me.codecraft.darkendepths.item.DarkenDepthsItems;
6+
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
7+
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
8+
import net.minecraft.block.Block;
9+
import net.minecraft.item.Item;
10+
import net.minecraft.registry.RegistryKey;
11+
import net.minecraft.registry.RegistryWrapper;
12+
import net.minecraft.registry.tag.TagKey;
13+
import net.minecraft.util.Identifier;
14+
15+
import java.util.concurrent.CompletableFuture;
16+
17+
public class DarkenDepthsItemTag extends FabricTagProvider.ItemTagProvider {
18+
19+
public static final TagKey<Item> SHADOW_PROTECTION = TagKey.of(RegistryKey.ofRegistry(new Identifier(DarkenDepths.MOD_ID,"shadows_protection")), new Identifier(DarkenDepths.MOD_ID,"shadows_protection"));
20+
public DarkenDepthsItemTag(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> completableFuture) {
21+
super(output, completableFuture);
22+
}
23+
24+
@Override
25+
protected void configure(RegistryWrapper.WrapperLookup arg) {
26+
getOrCreateTagBuilder(SHADOW_PROTECTION).add(DarkenDepthsItems.DARK_PICKAXE,DarkenDepthsItems.DARK_AXE,DarkenDepthsItems.DARK_SWORD,DarkenDepthsItems.DARKSHADOW_CORE);
27+
28+
}
29+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package me.codecraft.darkendepths.inventory;
2+
3+
import net.minecraft.inventory.SimpleInventory;
4+
import net.minecraft.item.ItemStack;
5+
import net.minecraft.nbt.NbtCompound;
6+
import net.minecraft.nbt.NbtList;
7+
8+
public class ShadowStoneInventory extends SimpleInventory {
9+
public ShadowStoneInventory() {
10+
super(36);
11+
}
12+
13+
@Override
14+
public void readNbtList(NbtList nbtList) {
15+
int i;
16+
for (i = 0; i < this.size(); ++i) {
17+
this.setStack(i, ItemStack.EMPTY);
18+
}
19+
for (i = 0; i < nbtList.size(); ++i) {
20+
NbtCompound nbtCompound = nbtList.getCompound(i);
21+
int j = nbtCompound.getByte("Slot") & 0xFF;
22+
if (j < 0 || j >= this.size()) continue;
23+
this.setStack(j, ItemStack.fromNbt(nbtCompound));
24+
}
25+
}
26+
27+
@Override
28+
public NbtList toNbtList() {
29+
NbtList nbtList = new NbtList();
30+
for (int i = 0; i < this.size(); ++i) {
31+
ItemStack itemStack = this.getStack(i);
32+
if (itemStack.isEmpty()) continue;
33+
NbtCompound nbtCompound = new NbtCompound();
34+
nbtCompound.putByte("Slot", (byte)i);
35+
itemStack.writeNbt(nbtCompound);
36+
nbtList.add(nbtCompound);
37+
}
38+
return nbtList;
39+
}
40+
}

src/main/java/me/codecraft/darkendepths/item/DarkenDepthsItems.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
public class DarkenDepthsItems {
1010
public static final Item DARK_ESSENCE = Registry.registerItems("dark_essence", DarkenDepths.MOD_ID,new Item(new FabricItemSettings()), DarkenDepthsGroupItems.DARKEN_DEPTHS_GROUP);
11+
public static final Item DARKSHADOW_CORE = Registry.registerItems("darkshadow_core", DarkenDepths.MOD_ID,new Item(new FabricItemSettings()), DarkenDepthsGroupItems.DARKEN_DEPTHS_GROUP);
1112
public static final Item SHADOW_STONE = Registry.registerItems("shadow_stone", DarkenDepths.MOD_ID,new ShadowStoneItem(new FabricItemSettings()), DarkenDepthsGroupItems.DARKEN_DEPTHS_GROUP);
1213
public static final Item DARK_SWORD = Registry.registerItems("dark_sword", DarkenDepths.MOD_ID,new SwordItem(DarkenDepthsToolMaterials.DARKNESS,10,5.0f,new FabricItemSettings()), DarkenDepthsGroupItems.DARKEN_DEPTHS_GROUP);
1314
public static final Item DARK_AXE = Registry.registerItems("dark_axe", DarkenDepths.MOD_ID,new AxeItem(DarkenDepthsToolMaterials.DARKNESS,10,5.0f,new FabricItemSettings()), DarkenDepthsGroupItems.DARKEN_DEPTHS_GROUP);

0 commit comments

Comments
 (0)