Skip to content

Commit

Permalink
Re-add trinkets compat
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometrically committed Jun 25, 2020
1 parent 705e80d commit 09038ad
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies {
modImplementation "me.sargunvohra.mcmods:autoconfig1u:${project.auto_config_version}"
//Compat Mods
modImplementation "io.github.prospector:modmenu:${project.mod_menu_version}"
modImplementation "com.github.emilyploszaj:trinkets:${trinkets_version}"

include "me.shedaniel.cloth:config-2:${project.cloth_config_version}"
include "me.sargunvohra.mcmods:autoconfig1u:${project.auto_config_version}"
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ yarn_mappings=1.16.1+build.4
loader_version=0.8.8+build.202

# Mod Properties
mod_version = 1.3.0
mod_version = 1.3.2
maven_group = net.guavy
archives_base_name = gravestones

Expand All @@ -18,3 +18,4 @@ fabric_version=0.13.1+build.370-1.16
cloth_config_version=4.5.6
auto_config_version=3.2.0-unstable
mod_menu_version=1.12.1+build.15
trinkets_version=2.6.1
4 changes: 4 additions & 0 deletions src/main/java/net/guavy/gravestones/Gravestones.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.guavy.gravestones.api.GravestonesApi;
import net.guavy.gravestones.block.GravestoneBlock;
import net.guavy.gravestones.block.entity.GravestoneBlockEntity;
import net.guavy.gravestones.compat.TrinketsCompat;
import net.guavy.gravestones.config.GravestonesConfig;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
Expand Down Expand Up @@ -44,6 +45,9 @@ public void onInitialize() {

AutoConfig.register(GravestonesConfig.class, GsonConfigSerializer::new);

if(FabricLoader.getInstance().isModLoaded("trinkets"))
apiMods.add(new TrinketsCompat());

apiMods.addAll(FabricLoader.getInstance().getEntrypoints("gravestones", GravestonesApi.class));
}

Expand Down
37 changes: 37 additions & 0 deletions src/main/java/net/guavy/gravestones/compat/TrinketsCompat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package net.guavy.gravestones.compat;

import dev.emi.trinkets.api.TrinketsApi;
import net.guavy.gravestones.api.GravestonesApi;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;

import java.util.ArrayList;
import java.util.List;

public class TrinketsCompat implements GravestonesApi {
@Override
public List<ItemStack> getInventory(PlayerEntity entity) {
Inventory inventory = TrinketsApi.getTrinketsInventory(entity);
List<ItemStack> itemStacks = new ArrayList<>();

for(int i = 0; i < inventory.size(); i++) {
itemStacks.add(inventory.getStack(i));
}

return itemStacks;
}

@Override
public List<ItemStack> setInventory(List<ItemStack> inventory, PlayerEntity entity) {
for(ItemStack itemStack : inventory) {
TrinketsApi.getTrinketComponent(entity).equip(itemStack);
}
return null;
}

@Override
public int getInventorySize(PlayerEntity entity) {
return TrinketsApi.getTrinketsInventory(entity).size();
}
}
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
],
"contact": {
"homepage": "https://guavy.net/",
"sources": "https://github.com/FabricMC/fabric-example-mod"
"sources": "https://github.com/Geometrically/Gravestones"
},

"license": "CC0-1.0",
"icon": "assets/guavy/icon.png",
"icon": "assets/gravestones/icon.png",

"environment": "*",
"entrypoints": {
Expand Down

0 comments on commit 09038ad

Please sign in to comment.