Skip to content

Commit

Permalink
Added shredded squid variants; update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
squid233 committed Mar 16, 2024
1 parent 14fb177 commit 2157f5e
Show file tree
Hide file tree
Showing 29 changed files with 284 additions and 68 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# against bad commits.

name: build
on: [pull_request, push]
on: [pull_request, push, workflow_dispatch]

jobs:
build:
Expand All @@ -19,11 +19,11 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
uses: gradle/wrapper-validation-action@v2
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
Expand All @@ -34,7 +34,7 @@ jobs:
run: ./gradlew build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/libs/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 XenFork Union
Copyright (c) 2023-2024 XenFork Union

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# SquidCraft

![SquidCraft Downloads on CurseForge](https://cf.way2muchnoise.eu/full_squidcraft_downloads.svg)
![Available Versions](https://cf.way2muchnoise.eu/versions/squidcraft.svg)
![Title](https://cf.way2muchnoise.eu/title/squidcraft.svg)
![SquidCraft Downloads on CurseForge](https://img.shields.io/curseforge/dt/381843)

[![build](https://github.com/XenFork/SquidCraft/actions/workflows/build.yml/badge.svg?branch=main&event=push)](https://github.com/XenFork/SquidCraft/actions/workflows/build.yml)
![discord](https://img.shields.io/discord/699898538112450651)
Expand All @@ -13,6 +11,6 @@ Make squids useful.

## Additional Links

- [Discord](https://discord.gg/yDrFqRU)
- [CurseForge](https://www.curseforge.com/minecraft/mc-mods/squidcraft)
- [Modrinth](https://modrinth.com/mod/squidcraft)
- [Discord](https://discord.gg/yDrFqRU)
11 changes: 7 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.1-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.5-SNAPSHOT" apply false
}

architectury {
Expand All @@ -19,7 +19,7 @@ subprojects {
// The following line declares the mojmap mappings, you may use other mappings as well
mappings loom.officialMojangMappings()
// The following line declares the yarn mappings you may select this one as well.
// mappings "net.fabricmc:yarn:@YARN_MAPPINGS@:v2"
// mappings "net.fabricmc:yarn:1.20.1+build.10:v2"
}
}

Expand All @@ -28,8 +28,11 @@ allprojects {
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"

archivesBaseName = rootProject.archives_base_name
version = "${rootProject.mod_version}-${rootProject.minecraft_version}"
base {
archivesName = rootProject.archives_base_name
}

version = rootProject.mod_version
group = rootProject.maven_group

repositories {
Expand Down
12 changes: 8 additions & 4 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
architectury {
common(rootProject.enabled_platforms.split(","))
}

loom {
accessWidenerPath = file("src/main/resources/squidcraft.accesswidener")
}

dependencies {
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
// Do NOT use other classes from fabric loader
Expand All @@ -6,10 +14,6 @@ dependencies {
modApi "dev.architectury:architectury:${rootProject.architectury_version}"
}

architectury {
common("fabric", "forge")
}

publishing {
publications {
mavenCommon(MavenPublication) {
Expand Down
43 changes: 26 additions & 17 deletions common/src/main/java/io/github/xenfork/squidcraft/SquidCraft.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import net.minecraft.advancements.critereon.EntityFlagsPredicate;
import net.minecraft.advancements.critereon.EntityPredicate;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.LootPool;
import net.minecraft.world.level.storage.loot.entries.LootItem;
Expand All @@ -43,24 +44,32 @@ public static void init() {
ModItems.init();
ModItemGroups.init();
LootEvent.MODIFY_LOOT_TABLE.register((lootDataManager, id, context, builtin) -> {
if (builtin && EntityType.SQUID.getDefaultLootTable().equals(id)) {
context.addPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1f))
.add(LootItem.lootTableItem(ModItems.SHREDDED_SQUID.get())
.apply(SetItemCountFunction.setCount(UniformGenerator.between(1f, 8f)))
.apply(SmeltItemFunction.smelted().when(() ->
LootItemEntityPropertyCondition.hasProperties(
LootContext.EntityTarget.THIS,
EntityPredicate.Builder.entity()
.flags(EntityFlagsPredicate.Builder.flags()
.setOnFire(true)
.build())
).build())
)
.apply(LootingEnchantFunction.lootingMultiplier(UniformGenerator.between(1f, 4f)).setLimit(8))
)
);
if (builtin) {
if (EntityType.SQUID.getDefaultLootTable().equals(id)) {
addLootItem(context, ModItems.SHREDDED_SQUID.get());
} else if (EntityType.GLOW_SQUID.getDefaultLootTable().equals(id)) {
addLootItem(context, ModItems.GLOWING_SHREDDED_SQUID.get());
}
}
});
}

private static void addLootItem(LootEvent.LootTableModificationContext context, Item item) {
context.addPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1f))
.add(LootItem.lootTableItem(item)
.apply(SetItemCountFunction.setCount(UniformGenerator.between(1f, 8f)))
.apply(SmeltItemFunction.smelted().when(() ->
LootItemEntityPropertyCondition.hasProperties(
LootContext.EntityTarget.THIS,
EntityPredicate.Builder.entity()
.flags(EntityFlagsPredicate.Builder.flags()
.setOnFire(true)
.build())
).build())
)
.apply(LootingEnchantFunction.lootingMultiplier(UniformGenerator.between(1f, 4f)))
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ public final class ModItemGroups {
.icon(() -> new ItemStack(ModItems.SHREDDED_SQUID.get()))
.displayItems((itemDisplayParameters, output) -> {
output.accept(Items.SQUID_SPAWN_EGG);
output.accept(Items.GLOW_SQUID_SPAWN_EGG);
output.accept(ModItems.SHREDDED_SQUID.get());
output.accept(ModItems.COOKED_SHREDDED_SQUID.get());
output.accept(ModItems.GLOWING_SHREDDED_SQUID.get());
output.accept(ModItems.MAGMA_SHREDDED_SQUID.get());
})
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@
import dev.architectury.registry.registries.RegistrySupplier;
import io.github.xenfork.squidcraft.SquidCraft;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.Item;

import java.util.Locale;
import java.util.function.Consumer;
import java.util.function.Supplier;

/**
Expand All @@ -32,7 +35,9 @@
*/
public enum ModItems {
SHREDDED_SQUID(() -> ofSnack(1, 1f)),
COOKED_SHREDDED_SQUID(() -> ofSnack(2, 1f));
COOKED_SHREDDED_SQUID(() -> ofSnack(2, 1f)),
GLOWING_SHREDDED_SQUID(() -> ofMeat(1, 1f, builder -> builder.effect(new MobEffectInstance(MobEffects.GLOWING, 200, 0), 1f))),
MAGMA_SHREDDED_SQUID(() -> ofMeat(2, 0.5f, builder -> builder.effect(new MobEffectInstance(MobEffects.FIRE_RESISTANCE, 200, 0), 0.3f)));

private static final DeferredRegister<Item> REGISTER = DeferredRegister.create(SquidCraft.MOD_ID, Registries.ITEM);
private final String path;
Expand All @@ -56,13 +61,17 @@ public static void init() {
REGISTER.register();
}

private static Item ofSnack(int nutrition, float saturationMod) {
return new Item(new Item.Properties().food(new FoodProperties.Builder()
private static Item ofMeat(int nutrition, float saturationMod, Consumer<FoodProperties.Builder> consumer) {
final FoodProperties.Builder builder = new FoodProperties.Builder()
.nutrition(nutrition)
.saturationMod(saturationMod)
.fast()
.meat()
.build()));
.meat();
consumer.accept(builder);
return new Item(new Item.Properties().food(builder.build()));
}

private static Item ofSnack(int nutrition, float saturationMod) {
return ofMeat(nutrition, saturationMod, FoodProperties.Builder::fast);
}

public String path() {
Expand Down
10 changes: 8 additions & 2 deletions common/src/main/resources/assets/squidcraft/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
{
"advancements.squidcraft.root.title": "SquidCraft",
"advancements.squidcraft.root.description": "A beginning of the squids",
"advancements.squidcraft.root.description": "Get shredded squid",
"advancements.squidcraft.cooked_shredded_squid.title": "Cooked Shredded Squid",
"advancements.squidcraft.cooked_shredded_squid.description": "Snacks",
"advancements.squidcraft.cooked_shredded_squid.description": "Get cooked shredded squid",
"advancements.squidcraft.glowing_shredded_squid.title": "Glowing Shredded Squid",
"advancements.squidcraft.glowing_shredded_squid.description": "Get glowing shredded squid",
"advancements.squidcraft.magma_shredded_squid.title": "Magma Shredded Squid",
"advancements.squidcraft.magma_shredded_squid.description": "Get magma shredded squid",
"item.squidcraft.shredded_squid": "Shredded Squid",
"item.squidcraft.cooked_shredded_squid": "Cooked Shredded Squid",
"item.squidcraft.glowing_shredded_squid": "Glowing Shredded Squid",
"item.squidcraft.magma_shredded_squid": "Magma Shredded Squid",
"itemGroup.squidcraft.main": "SquidCraft"
}
10 changes: 8 additions & 2 deletions common/src/main/resources/assets/squidcraft/lang/zh_cn.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
{
"advancements.squidcraft.root.title": "鱿鱼工艺",
"advancements.squidcraft.root.description": "起源",
"advancements.squidcraft.root.description": "获得鱿鱼丝",
"advancements.squidcraft.cooked_shredded_squid.title": "熟鱿鱼丝",
"advancements.squidcraft.cooked_shredded_squid.description": "小吃",
"advancements.squidcraft.cooked_shredded_squid.description": "获得熟鱿鱼丝",
"advancements.squidcraft.glowing_shredded_squid.title": "荧光鱿鱼丝",
"advancements.squidcraft.glowing_shredded_squid.description": "获得荧光鱿鱼丝",
"advancements.squidcraft.magma_shredded_squid.title": "岩浆鱿鱼丝",
"advancements.squidcraft.magma_shredded_squid.description": "获得岩浆鱿鱼丝",
"item.squidcraft.shredded_squid": "鱿鱼丝",
"item.squidcraft.cooked_shredded_squid": "熟鱿鱼丝",
"item.squidcraft.glowing_shredded_squid": "荧光鱿鱼丝",
"item.squidcraft.magma_shredded_squid": "岩浆鱿鱼丝",
"itemGroup.squidcraft.main": "鱿鱼工艺"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "squidcraft:item/glowing_shredded_squid"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "squidcraft:item/magma_shredded_squid"
}
}
7 changes: 7 additions & 0 deletions common/src/main/resources/data/c/raw_fishes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"replace": false,
"values": [
"squidcraft:shredded_squid",
"squidcraft:glowing_shredded_squid.json"
]
}
7 changes: 7 additions & 0 deletions common/src/main/resources/data/forge/raw_fishes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"replace": false,
"values": [
"squidcraft:shredded_squid",
"squidcraft:glowing_shredded_squid.json"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"parent": "squidcraft:root",
"criteria": {
"glowing_shredded_squid": {
"conditions": {
"items": [
{
"items": [
"squidcraft:glowing_shredded_squid"
]
}
]
},
"trigger": "minecraft:inventory_changed"
}
},
"display": {
"announce_to_chat": false,
"description": {
"translate": "advancements.squidcraft.glowing_shredded_squid.description"
},
"title": {
"translate": "advancements.squidcraft.glowing_shredded_squid.title"
},
"icon": {
"item": "squidcraft:glowing_shredded_squid"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"parent": "squidcraft:root",
"criteria": {
"magma_shredded_squid": {
"conditions": {
"items": [
{
"items": [
"squidcraft:magma_shredded_squid"
]
}
]
},
"trigger": "minecraft:inventory_changed"
}
},
"display": {
"announce_to_chat": false,
"description": {
"translate": "advancements.squidcraft.magma_shredded_squid.description"
},
"title": {
"translate": "advancements.squidcraft.magma_shredded_squid.title"
},
"icon": {
"item": "squidcraft:magma_shredded_squid"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@
},
"trigger": "minecraft:inventory_changed"
},
"has_glowing_shredded_squid": {
"conditions": {
"items": [
{
"items": [
"squidcraft:glowing_shredded_squid"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "squidcraft:cooked_shredded_squid"
Expand All @@ -23,6 +35,7 @@
"requirements": [
[
"has_shredded_squid",
"has_glowing_shredded_squid",
"has_the_recipe"
]
],
Expand Down
Loading

0 comments on commit 2157f5e

Please sign in to comment.