Added resources for rest of nigiri, added Tuna fish item and loot table with fishing
|
|
@ -1,6 +1,8 @@
|
|||
package dev.confuzzedcat.sushi;
|
||||
|
||||
import dev.confuzzedcat.sushi.registry.SushiItems;
|
||||
import dev.confuzzedcat.sushi.registry.SushiLootConditions;
|
||||
import dev.confuzzedcat.sushi.registry.SushiLootHandler;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
|
|
@ -28,6 +30,8 @@ public class Sushi implements ModInitializer {
|
|||
|
||||
|
||||
SushiItems.init();
|
||||
SushiLootConditions.init();
|
||||
SushiLootHandler.init();
|
||||
}
|
||||
public static Identifier id(String name) {
|
||||
return new Identifier(MOD_ID, name);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
package dev.confuzzedcat.sushi.items.food.ingredients.fish;
|
||||
|
||||
import dev.confuzzedcat.sushi.items.food.SushiFoodItemBase;
|
||||
|
||||
public abstract class FishBase extends SushiFoodItemBase {
|
||||
public FishBase(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package dev.confuzzedcat.sushi.items.food.ingredients.fish;
|
||||
|
||||
import net.minecraft.item.FoodComponent;
|
||||
|
||||
public class TunaFish extends FishBase{
|
||||
public TunaFish(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
public TunaFish(){
|
||||
super(new Settings()
|
||||
.food(new FoodComponent.Builder()
|
||||
.hunger(1)
|
||||
.saturationModifier(1)
|
||||
.build()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -10,11 +10,11 @@ public abstract class NigiriBase extends SushiFoodItemBase {
|
|||
|
||||
public NigiriBase(){
|
||||
this(new Settings()
|
||||
.food(new FoodComponent.Builder()
|
||||
.hunger(1)
|
||||
.saturationModifier(1)
|
||||
.build()
|
||||
)
|
||||
.food(new FoodComponent.Builder()
|
||||
.hunger(1)
|
||||
.saturationModifier(1)
|
||||
.build()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
package dev.confuzzedcat.sushi.items.food.nigiri;
|
||||
|
||||
public class NigiriOctopus extends NigiriBase {
|
||||
}
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
package dev.confuzzedcat.sushi.loot.biome;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import dev.confuzzedcat.sushi.registry.SushiLootConditions;
|
||||
import net.minecraft.loot.condition.LootCondition;
|
||||
import net.minecraft.loot.condition.LootConditionType;
|
||||
import net.minecraft.loot.context.LootContext;
|
||||
import net.minecraft.loot.context.LootContextParameter;
|
||||
import net.minecraft.loot.context.LootContextParameters;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.registry.tag.TagKey;
|
||||
import net.minecraft.util.JsonSerializer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class BiomeLootCondition implements LootCondition {
|
||||
|
||||
protected final BiomeTagPredicate category;
|
||||
protected final BiomePredicate biome;
|
||||
|
||||
public BiomeLootCondition(BiomeTagPredicate category, BiomePredicate biome) {
|
||||
this.category = category;
|
||||
this.biome = biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootConditionType getType() {
|
||||
return SushiLootConditions.MATCH_BIOME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<LootContextParameter<?>> getRequiredParameters() {
|
||||
return ImmutableSet.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(LootContext lootContext) {
|
||||
Vec3d origin = lootContext.get(LootContextParameters.ORIGIN);
|
||||
|
||||
if(origin != null) {
|
||||
RegistryEntry<Biome> fisherBiome = lootContext.getWorld().getBiome(new BlockPos((int) Math.floor(origin.x), (int) Math.floor(origin.y), (int) Math.floor(origin.z)));
|
||||
|
||||
// Category predicate is null, check exact biome
|
||||
if (category == null || category.getValid().isEmpty()) {
|
||||
if (biome != null && !biome.getValid().isEmpty()) {
|
||||
return biome.test(lootContext.getWorld(), fisherBiome);
|
||||
}
|
||||
}
|
||||
|
||||
// Category predicate is not null, check it
|
||||
else if (!category.getValid().isEmpty()) {
|
||||
return category.test(fisherBiome);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static LootCondition.Builder builder(RegistryKey<Biome>... biomes) {
|
||||
return builder(Collections.emptyList(), List.of(biomes));
|
||||
}
|
||||
|
||||
public static LootCondition.Builder builder(TagKey<Biome>... categories) {
|
||||
return builder(Arrays.asList(categories), Collections.emptyList());
|
||||
}
|
||||
|
||||
public static LootCondition.Builder builder(List<TagKey<Biome>> categories, List<RegistryKey<Biome>> biomes) {
|
||||
List<String> stringCats = new ArrayList<>();
|
||||
List<String> stringBiomes = new ArrayList<>();
|
||||
|
||||
categories.forEach(category -> stringCats.add(category.id().toString()));
|
||||
biomes.forEach(biome -> stringBiomes.add(biome.getValue().toString()));
|
||||
|
||||
return builder(BiomeTagPredicate.builder().setValidByString(stringCats), BiomePredicate.builder().setValidFromString(stringBiomes));
|
||||
}
|
||||
|
||||
public static LootCondition.Builder builder(String category, String biome) {
|
||||
return builder(BiomeTagPredicate.builder().add(category), BiomePredicate.builder().add(biome));
|
||||
}
|
||||
|
||||
public static LootCondition.Builder builder(BiomeTagPredicate.Builder categoryBuilder) {
|
||||
return builder(categoryBuilder, BiomePredicate.builder());
|
||||
}
|
||||
|
||||
public static LootCondition.Builder builder(BiomePredicate.Builder biomeBuilder) {
|
||||
return builder(BiomeTagPredicate.builder(), biomeBuilder);
|
||||
}
|
||||
|
||||
public static LootCondition.Builder builder(BiomeTagPredicate.Builder categoryBuilder, BiomePredicate.Builder biomeBuilder) {
|
||||
return () -> new BiomeLootCondition(categoryBuilder.build(), biomeBuilder.build());
|
||||
}
|
||||
|
||||
public static class Serializer implements JsonSerializer<BiomeLootCondition> {
|
||||
|
||||
@Override
|
||||
public void toJson(JsonObject jsonObject, BiomeLootCondition condition, JsonSerializationContext jsonSerializationContext) {
|
||||
jsonObject.add("category", condition.category.toJson());
|
||||
jsonObject.add("biome", condition.biome.toJson());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeLootCondition fromJson(JsonObject obj, JsonDeserializationContext context) {
|
||||
BiomeTagPredicate categoryPredicate;
|
||||
BiomePredicate biomePredicate;
|
||||
|
||||
if (obj.has("category")) {
|
||||
categoryPredicate = BiomeTagPredicate.fromJson(obj.get("category"));
|
||||
} else {
|
||||
categoryPredicate = BiomeTagPredicate.EMPTY;
|
||||
}
|
||||
|
||||
if (obj.has("biome")) {
|
||||
biomePredicate = BiomePredicate.fromJson(obj.get("biome"));
|
||||
} else {
|
||||
biomePredicate = BiomePredicate.EMPTY;
|
||||
}
|
||||
|
||||
return new BiomeLootCondition(categoryPredicate, biomePredicate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
package dev.confuzzedcat.sushi.loot.biome;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.JsonHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class BiomePredicate {
|
||||
|
||||
public static final BiomePredicate EMPTY = new BiomePredicate(Collections.emptyList());
|
||||
private static final String VALID_KEY = "valid";
|
||||
private final List<RegistryKey<Biome>> valid;
|
||||
|
||||
public BiomePredicate(List<String> valid) {
|
||||
this.valid = builder().setValidFromString(valid).valid;
|
||||
}
|
||||
|
||||
private BiomePredicate(Builder builder) {
|
||||
this.valid = builder.valid;
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public List<RegistryKey<Biome>> getValid() {
|
||||
return valid;
|
||||
}
|
||||
|
||||
public boolean test(World world, RegistryEntry<Biome> biome) {
|
||||
for (RegistryKey<Biome> key : valid) {
|
||||
if (biome.matchesKey(key)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public JsonElement toJson() {
|
||||
JsonObject obj = new JsonObject();
|
||||
JsonArray arr = new JsonArray();
|
||||
|
||||
for(RegistryKey<Biome> rKey : valid) {
|
||||
arr.add(rKey.getValue().toString());
|
||||
}
|
||||
|
||||
obj.add(VALID_KEY, arr);
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static BiomePredicate fromJson(JsonElement element) {
|
||||
JsonObject obj = JsonHelper.asObject(element, VALID_KEY);
|
||||
JsonArray arr = obj.getAsJsonArray(VALID_KEY);
|
||||
|
||||
List<String> sArr = new ArrayList<>();
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
sArr.add(arr.get(i).getAsString());
|
||||
}
|
||||
|
||||
return new BiomePredicate(sArr);
|
||||
}
|
||||
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private List<RegistryKey<Biome>> valid;
|
||||
|
||||
private Builder() {
|
||||
|
||||
}
|
||||
|
||||
public Builder setValid(List<RegistryKey<Biome>> valid) {
|
||||
this.valid = valid;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setValidFromString(List<String> valid) {
|
||||
List<RegistryKey<Biome>> rKeys = new ArrayList<>();
|
||||
for (String str : valid) {
|
||||
if (!valid.isEmpty()) {
|
||||
rKeys.add(RegistryKey.of(RegistryKeys.BIOME, new Identifier(str)));
|
||||
}
|
||||
}
|
||||
|
||||
return setValid(rKeys);
|
||||
}
|
||||
|
||||
public Builder add(RegistryKey<Biome> biome) {
|
||||
valid.add(biome);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder add(String biome) {
|
||||
if(!biome.isEmpty()) {
|
||||
valid.add(RegistryKey.of(RegistryKeys.BIOME, new Identifier(biome)));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder of(BiomePredicate biomePredicate) {
|
||||
this.valid = biomePredicate.valid;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BiomePredicate build() {
|
||||
return new BiomePredicate(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
package dev.confuzzedcat.sushi.loot.biome;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.registry.tag.TagKey;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.JsonHelper;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class BiomeTagPredicate {
|
||||
|
||||
public static final BiomeTagPredicate EMPTY = new BiomeTagPredicate(Collections.emptyList());
|
||||
private static final String VALID_KEY = "valid";
|
||||
private final List<TagKey<Biome>> valid;
|
||||
|
||||
public BiomeTagPredicate(List<TagKey<Biome>> valid) { this.valid = valid; }
|
||||
|
||||
public BiomeTagPredicate(Builder builder) {
|
||||
this.valid = builder.valid;
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public List<TagKey<Biome>> getValid() {
|
||||
return valid;
|
||||
}
|
||||
|
||||
public boolean test(RegistryEntry<Biome> biome) {
|
||||
|
||||
for(TagKey<Biome> tag : valid) {
|
||||
if(biome.isIn(tag)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public JsonElement toJson() {
|
||||
JsonObject obj = new JsonObject();
|
||||
JsonArray arr = new JsonArray();
|
||||
|
||||
for(TagKey<Biome> tag : valid) {
|
||||
arr.add(tag.id().toString());
|
||||
}
|
||||
|
||||
obj.add(VALID_KEY, arr);
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static BiomeTagPredicate fromJson(JsonElement element) {
|
||||
JsonObject obj = JsonHelper.asObject(element, VALID_KEY);
|
||||
JsonArray arr = obj.getAsJsonArray(VALID_KEY);
|
||||
|
||||
List<String> sArr = new ArrayList<>();
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
sArr.add(arr.get(i).getAsString());
|
||||
}
|
||||
|
||||
return BiomeTagPredicate.builder().setValidByString(sArr).build();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private List<TagKey<Biome>> valid = new ArrayList<>();
|
||||
|
||||
private Builder() {
|
||||
|
||||
}
|
||||
|
||||
public Builder setValid(List<TagKey<Biome>> valid) {
|
||||
this.valid = valid;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setValidByString(List<String> valid) {
|
||||
List<TagKey<Biome>> tagKeys = new ArrayList<>();
|
||||
for (String str : valid) {
|
||||
tagKeys.add(TagKey.of(RegistryKeys.BIOME, new Identifier(str)));
|
||||
}
|
||||
return setValid(tagKeys);
|
||||
}
|
||||
|
||||
public Builder add(String tag) {
|
||||
if(!tag.isEmpty()) {
|
||||
this.valid.add(TagKey.of(RegistryKeys.BIOME, new Identifier(tag)));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder of(BiomeTagPredicate biomePredicate) {
|
||||
this.valid = biomePredicate.valid;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BiomeTagPredicate build() {
|
||||
return new BiomeTagPredicate(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
package dev.confuzzedcat.sushi.loot.weather;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import dev.confuzzedcat.sushi.registry.SushiLootConditions;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.loot.condition.LootCondition;
|
||||
import net.minecraft.loot.condition.LootConditionType;
|
||||
import net.minecraft.loot.context.LootContext;
|
||||
import net.minecraft.loot.context.LootContextParameter;
|
||||
import net.minecraft.loot.context.LootContextParameters;
|
||||
import net.minecraft.util.JsonSerializer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class WeatherLootCondition implements LootCondition {
|
||||
|
||||
protected boolean raining = false;
|
||||
protected boolean thundering = false;
|
||||
protected boolean snowing = false;
|
||||
|
||||
public WeatherLootCondition() {
|
||||
|
||||
}
|
||||
|
||||
public WeatherLootCondition(boolean raining, boolean thundering, boolean snowing) {
|
||||
this.raining = raining;
|
||||
this.thundering = thundering;
|
||||
this.snowing = snowing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootConditionType getType() {
|
||||
return SushiLootConditions.WEATHER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<LootContextParameter<?>> getRequiredParameters() {
|
||||
return ImmutableSet.of(LootContextParameters.THIS_ENTITY, LootContextParameters.ORIGIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(LootContext lootContext) {
|
||||
@Nullable Entity entity = lootContext.get(LootContextParameters.THIS_ENTITY);
|
||||
@Nullable Vec3d pos = lootContext.get(LootContextParameters.ORIGIN);
|
||||
|
||||
if(entity != null && pos != null) {
|
||||
World world = entity.getWorld();
|
||||
|
||||
// If raining is required and the world is not raining, return false.
|
||||
if (raining && !world.isRaining()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If thundering is required and the world is not raining, return false.
|
||||
if (thundering && !world.isThundering()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// same check for snowing
|
||||
if (snowing) {
|
||||
// >= .15 = no snow
|
||||
if(world.getBiome(entity.getBlockPos()).value().doesNotSnow(new BlockPos((int) Math.floor(pos.x), (int) Math.floor(pos.y), (int) Math.floor(pos.z)))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return world.isRaining();
|
||||
}
|
||||
|
||||
// Both conditions match, return true.
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static LootCondition.Builder builder(boolean raining, boolean thundering, boolean snowing) {
|
||||
return () -> new WeatherLootCondition(raining, thundering, snowing);
|
||||
}
|
||||
|
||||
public static class Serializer implements JsonSerializer<WeatherLootCondition> {
|
||||
|
||||
@Override
|
||||
public void toJson(JsonObject jsonObject, WeatherLootCondition condition, JsonSerializationContext jsonSerializationContext) {
|
||||
jsonObject.addProperty("raining", condition.raining);
|
||||
jsonObject.addProperty("thundering", condition.thundering);
|
||||
jsonObject.addProperty("snowing", condition.snowing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WeatherLootCondition fromJson(JsonObject obj, JsonDeserializationContext context) {
|
||||
return new WeatherLootCondition(
|
||||
obj.has("raining") && obj.get("raining").getAsBoolean(),
|
||||
obj.has("thundering") && obj.get("thundering").getAsBoolean(),
|
||||
obj.has("snowing") && obj.get("snowing").getAsBoolean());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package dev.confuzzedcat.sushi.mixin;
|
||||
|
||||
import net.minecraft.loot.LootPool;
|
||||
import net.minecraft.loot.LootTable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(LootTable.Builder.class)
|
||||
public interface ILootTableBuilderAccessor {
|
||||
@Accessor
|
||||
List<LootPool> getPools();
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
package dev.confuzzedcat.sushi.registry;
|
||||
|
||||
import dev.confuzzedcat.sushi.items.food.nigiri.NigiriBase;
|
||||
|
||||
public class NigiriOctopus extends NigiriBase {
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package dev.confuzzedcat.sushi.registry;
|
|||
|
||||
import dev.confuzzedcat.sushi.Sushi;
|
||||
import dev.confuzzedcat.sushi.items.food.ingredients.avocadoFruit;
|
||||
import dev.confuzzedcat.sushi.items.food.ingredients.fish.TunaFish;
|
||||
import dev.confuzzedcat.sushi.items.food.nigiri.*;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
|
||||
import net.minecraft.item.Item;
|
||||
|
|
@ -12,8 +13,12 @@ import org.slf4j.Logger;
|
|||
public class SushiItems {
|
||||
private static final Logger LOGGER = Sushi.LOGGER;
|
||||
|
||||
// Ingredients
|
||||
/// Ingredients
|
||||
// Plants
|
||||
public static final Item AVOCADO_FRUIT = register("avocado_fruit", new avocadoFruit());
|
||||
// Fish
|
||||
public static final Item TUNA_FISH = register("fish_tuna", new TunaFish());
|
||||
|
||||
|
||||
// Nigiri
|
||||
|
||||
|
|
@ -24,7 +29,7 @@ public class SushiItems {
|
|||
public static final Item NIGIRI_MACKEREL = register("nigiri_mackerel", new NigiriMackerel());
|
||||
public static final Item NIGIRI_SURF_CLAM = register("nigiri_surf_clam", new NigiriSurfClam());
|
||||
public static final Item NIGIRI_KING_PRAWN = register("nigiri_king_prawn", new NigiriKingPrawn());
|
||||
public static final Item NIGIRI_SWEET_PRAWN = register("nigiri_sweet_prawm", new NigiriSweetPrawn());
|
||||
public static final Item NIGIRI_SWEET_PRAWN = register("nigiri_sweet_prawn", new NigiriSweetPrawn());
|
||||
public static final Item NIGIRI_OCTOPUS = register("nigiri_octopus", new NigiriOctopus());
|
||||
public static final Item NIGIRI_TOBIKO = register("nigiri_tobiko", new NigiriTobiko());
|
||||
public static final Item NIGIRI_SCALLOP = register("nigiri_scallop", new NigiriScallop());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
package dev.confuzzedcat.sushi.registry;
|
||||
|
||||
import dev.confuzzedcat.sushi.Sushi;
|
||||
import dev.confuzzedcat.sushi.loot.biome.BiomeLootCondition;
|
||||
import dev.confuzzedcat.sushi.loot.weather.WeatherLootCondition;
|
||||
import net.minecraft.loot.condition.LootCondition;
|
||||
import net.minecraft.loot.condition.LootConditionType;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.util.JsonSerializer;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
public class SushiLootConditions {
|
||||
private static final Logger LOGGER = Sushi.LOGGER;
|
||||
|
||||
public static final LootConditionType MATCH_BIOME = register("match_biome", new BiomeLootCondition.Serializer());
|
||||
public static final LootConditionType WEATHER = register("weather", new WeatherLootCondition.Serializer());
|
||||
|
||||
|
||||
private static LootConditionType register(String name, JsonSerializer<? extends LootCondition> serializer){
|
||||
var id = Sushi.id(name);
|
||||
return Registry.register(Registries.LOOT_CONDITION_TYPE, id, new LootConditionType(serializer));
|
||||
}
|
||||
public static void init() {
|
||||
LOGGER.info("Initializing loot conditions for {}", Sushi.MOD_ID);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package dev.confuzzedcat.sushi.registry;
|
||||
|
||||
import dev.confuzzedcat.sushi.Sushi;
|
||||
import dev.confuzzedcat.sushi.loot.biome.BiomeLootCondition;
|
||||
import dev.confuzzedcat.sushi.loot.weather.WeatherLootCondition;
|
||||
import dev.confuzzedcat.sushi.mixin.ILootTableBuilderAccessor;
|
||||
import net.fabricmc.fabric.api.loot.v2.FabricLootPoolBuilder;
|
||||
import net.fabricmc.fabric.api.loot.v2.LootTableEvents;
|
||||
import net.fabricmc.fabric.api.tag.convention.v1.ConventionalBiomeTags;
|
||||
import net.minecraft.loot.LootPool;
|
||||
import net.minecraft.loot.entry.ItemEntry;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
public class SushiLootHandler {
|
||||
private static final Logger LOGGER = Sushi.LOGGER;
|
||||
public static final Identifier FISH_LOOT_TABLE = new Identifier("gameplay/fishing/fish");
|
||||
|
||||
public static void init() {
|
||||
LOGGER.info("Initializing loot tables for {}", Sushi.MOD_ID);
|
||||
registerFishLootHandler();
|
||||
}
|
||||
private static void registerFishLootHandler() {
|
||||
LootTableEvents.MODIFY.register((resourceManager, lootManager, identifier, fabricLootSupplierBuilder, lootTableSource) -> {
|
||||
if(identifier.equals(FISH_LOOT_TABLE)) {
|
||||
// Get first pool, which SHOULD be the fish pool
|
||||
LootPool lootPool = ((ILootTableBuilderAccessor) fabricLootSupplierBuilder).getPools().get(0);
|
||||
|
||||
|
||||
LootPool.Builder lpb = FabricLootPoolBuilder.copyOf(lootPool);
|
||||
|
||||
// The default fish loot table has a total weight of 100.
|
||||
// An entry with a weight of 10 represents a 10% chance to get that fish compared to the standard 4, but the percentage goes down as more custom fish are added.
|
||||
// In most situations, only 1-2 fish are added per biome or area, so the chance for that fish is still ~5-10%.
|
||||
|
||||
// Ocean
|
||||
lpb.with(
|
||||
ItemEntry
|
||||
.builder(SushiItems.TUNA_FISH)
|
||||
.weight(10)
|
||||
.conditionally(
|
||||
BiomeLootCondition.builder(ConventionalBiomeTags.OCEAN)
|
||||
.and(WeatherLootCondition.builder(true, false, false))
|
||||
)
|
||||
.build()
|
||||
);
|
||||
|
||||
// weather
|
||||
//lpb.with(ItemEntry.builder(GoFishItems.RAINY_BASS).weight(100).conditionally(WeatherCondition.builder(true, false, false)).build());
|
||||
|
||||
|
||||
((ILootTableBuilderAccessor) fabricLootSupplierBuilder)
|
||||
.getPools()
|
||||
.set(0, lpb.build());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,6 +2,19 @@
|
|||
"itemGroup.sushi.sushi_items": "Sushi Items",
|
||||
|
||||
"item.sushi.avocado_fruit": "Avocado Fruit",
|
||||
"item.sushi.nigiri_tuna": "Tuna Nigiri"
|
||||
"item.sushi.nigiri_tuna": "Tuna Nigiri",
|
||||
"item.sushi.nigiri_salmon" : "Salmon Nigiri",
|
||||
"item.sushi.nigiri_hamachi" : "Hamachi Nigiri",
|
||||
"item.sushi.nigiri_seabass" :"Seabass Nigiri",
|
||||
"item.sushi.nigiri_mackerel" : "Mackerel Nigiri",
|
||||
"item.sushi.nigiri_surf_clam" :"Surf Clam Nigiri",
|
||||
"item.sushi.nigiri_king_prawn" : "King Prawn Nigiri",
|
||||
"item.sushi.nigiri_sweet_prawn" :"Sweet Prawn Nigiri",
|
||||
"item.sushi.nigiri_octopus" : "Octopus Nigiri",
|
||||
"item.sushi.nigiri_tobiko" :"Tobiko Nigiri",
|
||||
"item.sushi.nigiri_scallop" : "Scallop Nigiri",
|
||||
"item.sushi.nigiri_unagi" :"Unagi Nigiri",
|
||||
"item.sushi.nigiri_aburi_salmon" : "Aburi Salmon Nigiri",
|
||||
|
||||
"item.sushi.fish_tuna" : "Tuna Fish"
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "sushi:item/fish_tuna"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "sushi:item/nigiri_aburi_salmon"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "sushi:item/nigiri_hamachi"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "sushi:item/nigiri_king_prawn"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "sushi:item/nigiri_mackerel"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "sushi:item/nigiri_octopus"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "sushi:item/nigiri_salmon"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "sushi:item/nigiri_scallop"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "sushi:item/nigiri_seabass"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "sushi:item/nigiri_surf_clam"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "sushi:item/nigiri_sweet_prawn"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "sushi:item/nigiri_tobiko"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "sushi:item/nigiri_unagi"
|
||||
}
|
||||
}
|
||||
BIN
src/main/resources/assets/sushi/textures/item/fish_tuna.png
Normal file
|
After Width: | Height: | Size: 136 B |
|
After Width: | Height: | Size: 136 B |
BIN
src/main/resources/assets/sushi/textures/item/nigiri_hamachi.png
Normal file
|
After Width: | Height: | Size: 136 B |
|
After Width: | Height: | Size: 136 B |
|
After Width: | Height: | Size: 136 B |
BIN
src/main/resources/assets/sushi/textures/item/nigiri_octopus.png
Normal file
|
After Width: | Height: | Size: 136 B |
BIN
src/main/resources/assets/sushi/textures/item/nigiri_salmon.png
Normal file
|
After Width: | Height: | Size: 136 B |
BIN
src/main/resources/assets/sushi/textures/item/nigiri_scallop.png
Normal file
|
After Width: | Height: | Size: 136 B |
BIN
src/main/resources/assets/sushi/textures/item/nigiri_seabass.png
Normal file
|
After Width: | Height: | Size: 136 B |
|
After Width: | Height: | Size: 136 B |
|
After Width: | Height: | Size: 136 B |
BIN
src/main/resources/assets/sushi/textures/item/nigiri_tobiko.png
Normal file
|
After Width: | Height: | Size: 136 B |
BIN
src/main/resources/assets/sushi/textures/item/nigiri_unagi.png
Normal file
|
After Width: | Height: | Size: 136 B |
|
|
@ -4,6 +4,7 @@
|
|||
"package": "dev.confuzzedcat.sushi.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"ILootTableBuilderAccessor"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
|
|||