Skip to content

Commit

Permalink
fix integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
PinkGoosik committed Jul 11, 2024
1 parent 753da61 commit 322c7f8
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 20 deletions.
3 changes: 2 additions & 1 deletion winterly-fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ dependencies {
modImplementation("net.fabricmc:fabric-loader:${rootProject.property("fabric_loader_version")}")
modApi("net.fabricmc.fabric-api:fabric-api:${rootProject.property("fabric_api_version")}")

modCompileOnly("dev.emi:trinkets:${rootProject.property("trinkets_version")}")
// modLocalRuntime("dev.emi:trinkets:${rootProject.property("trinkets_version")}")
modApi(files("trinkets-3.10.0.jar"))
modImplementation("dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${rootProject.property("cca_version")}")

modImplementation("dev.onyxstudios.cardinal-components-api:cardinal-components-base:${rootProject.property("cca_version")}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ public void onInitialize() {
WinterlyBlockEntities.init();
WinterlyFeatures.init();

if(FabricLoader.getInstance().isModLoaded("owo")) {
WinterlyOwoLibIntegration.initItemGroup();
ItemGroupEvents.modifyEntriesEvent(BuiltInRegistries.CREATIVE_MODE_TAB.getResourceKey(itemGroup).get()).register(entries -> {
CommonWinterlyItems.ITEMS.forEach((id, sup) -> entries.accept(BuiltInRegistries.ITEM.get(id)));
CommonWinterlyBlocks.BLOCKS.forEach((id, sup) -> entries.accept(BuiltInRegistries.ITEM.get(id)));
});
}
// if(FabricLoader.getInstance().isModLoaded("owo")) {
// WinterlyOwoLibIntegration.initItemGroup();
// ItemGroupEvents.modifyEntriesEvent(BuiltInRegistries.CREATIVE_MODE_TAB.getResourceKey(itemGroup).get()).register(entries -> {
// CommonWinterlyItems.ITEMS.forEach((id, sup) -> entries.accept(BuiltInRegistries.ITEM.get(id)));
// CommonWinterlyBlocks.BLOCKS.forEach((id, sup) -> entries.accept(BuiltInRegistries.ITEM.get(id)));
// });
// }
}

private static CreativeModeTab createItemGroup() {
if(FabricLoader.getInstance().isModLoaded("owo")) {
return WinterlyOwoLibIntegration.createItemGroup();
}
// if(FabricLoader.getInstance().isModLoaded("owo")) {
// return WinterlyOwoLibIntegration.createItemGroup();
// }
var group = FabricItemGroup.builder().title(Component.translatable("itemGroup.winterly.items"))
.icon(() -> BuiltInRegistries.ITEM.get(Winterly.id("snowguy")).getDefaultInstance())
.displayItems((displayContext, entries) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public void onInitializeClient() {
map.putBlock(BuiltInRegistries.BLOCK.get(Winterly.id("icicle_bars")), RenderType.cutout());

if(FabricLoader.getInstance().isModLoaded("trinkets")) {
CommonWinterlyItems.ITEMS.forEach((id, item) -> {
if(item instanceof CommonScarfItem scarf) {
CommonWinterlyItems.ITEMS.forEach((id, sup) -> {
if(BuiltInRegistries.ITEM.get(id) instanceof CommonScarfItem scarf) {
WinterlyTrinketsIntegration.registerScarfRenderer(scarf);
}
if(item instanceof CommonSantaHatItem hat) {
if(BuiltInRegistries.ITEM.get(id) instanceof CommonSantaHatItem hat) {
WinterlyTrinketsIntegration.registerSantaHatRenderer(hat);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.mojang.blaze3d.vertex.VertexConsumer;
import dev.emi.trinkets.api.SlotReference;
import dev.emi.trinkets.api.Trinket;
import dev.emi.trinkets.api.TrinketComponent;
import dev.emi.trinkets.api.TrinketsApi;
import dev.emi.trinkets.api.client.TrinketRenderer;
import dev.emi.trinkets.api.client.TrinketRendererRegistry;
Expand All @@ -12,28 +13,32 @@
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.util.Tuple;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import ru.pinkgoosik.winterly.Winterly;
import ru.pinkgoosik.winterly.client.model.WinterlyModels;
import ru.pinkgoosik.winterly.fabric.item.SantaHatItem;
import ru.pinkgoosik.winterly.item.CommonSantaHatItem;
import ru.pinkgoosik.winterly.item.CommonScarfItem;

import java.util.Optional;

public class WinterlyTrinketsIntegration {

public static void registerTrinket(Item item) {
TrinketsApi.registerTrinket(item, new Trinket() {});
}

public static boolean hasHatOn(Player player) {
// Optional<TrinketComponent> component = TrinketsApi.getTrinketComponent(player);
// if(component.isPresent()) {
// for(Tuple<SlotReference, ItemStack> pair : component.get().getAllEquipped()) {
// if(pair.getB().getItem() instanceof SantaHatItem) return true;
// }
// }
Optional<TrinketComponent> component = TrinketsApi.getTrinketComponent(player);
if(component.isPresent()) {
for(Tuple<SlotReference, ItemStack> pair : component.get().getAllEquipped()) {
if(pair.getB().getItem() instanceof SantaHatItem) return true;
}
}
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.ladysnake.cca.api.v3.component.ComponentV3;
import ru.pinkgoosik.winterly.data.CachedFlowers;

@SuppressWarnings("NullableProblems")
public class WorldData implements ComponentV3 {

public Level world;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import java.util.List;

@SuppressWarnings("NullableProblems")
public class SantaHatItem extends CommonSantaHatItem {

public SantaHatItem(Item.Properties settings, String color) {
Expand Down
Binary file added winterly-fabric/trinkets-3.10.0.jar
Binary file not shown.

0 comments on commit 322c7f8

Please sign in to comment.