Skip to content

Commit

Permalink
tweak advancements, add more
Browse files Browse the repository at this point in the history
  • Loading branch information
TropheusJ committed Apr 2, 2024
1 parent 0b2f4a4 commit 87df66d
Show file tree
Hide file tree
Showing 12 changed files with 177 additions and 32 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# It's as Shrimple as That
A shrimple mod about everyone's favorite crustaceans.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import io.github.tropheusj.its_as_shrimple_as_that.arrow.ShrimpArrowEntity;
import io.github.tropheusj.its_as_shrimple_as_that.arrow.ShrimpArrowItem;
import io.github.tropheusj.its_as_shrimple_as_that.command.KrillCommand;
import io.github.tropheusj.its_as_shrimple_as_that.criteria.LoadShrimpTrigger;
import io.github.tropheusj.its_as_shrimple_as_that.criteria.KrillSelfTrigger;
import io.github.tropheusj.its_as_shrimple_as_that.criteria.KrillTrigger;
import io.github.tropheusj.its_as_shrimple_as_that.criteria.ShrimpAccomplishDreamsTrigger;
import io.github.tropheusj.its_as_shrimple_as_that.entity.ShrimpEntity;
import io.github.tropheusj.its_as_shrimple_as_that.item.FriedRiceItem;
Expand All @@ -30,7 +32,6 @@
import net.minecraft.world.entity.SpawnPlacements;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.item.ArrowItem;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Item.Properties;
Expand Down Expand Up @@ -72,7 +73,9 @@ public class ItsAsShrimpleAsThat implements ModInitializer {
);

public static final ShrimpAccomplishDreamsTrigger ACCOMPLISH_DREAMS_TRIGGER = new ShrimpAccomplishDreamsTrigger();
public static final KrillSelfTrigger KRILL_SELF = new KrillSelfTrigger();
public static final KrillTrigger KRILL_TRIGGER = new KrillTrigger();
public static final KrillSelfTrigger KRILL_SELF_TRIGGER = new KrillSelfTrigger();
public static final LoadShrimpTrigger LOAD_SHRIMP_TRIGGER = new LoadShrimpTrigger();

@Override
public void onInitialize() {
Expand All @@ -82,7 +85,9 @@ public void onInitialize() {
Registry.register(BuiltInRegistries.ITEM, id("fried_rice"), FRIED_RICE);
Registry.register(BuiltInRegistries.ITEM, id("shrimp_spawn_egg"), SHRIMP_EGG);
Registry.register(BuiltInRegistries.TRIGGER_TYPES, id("accomplish_dreams"), ACCOMPLISH_DREAMS_TRIGGER);
Registry.register(BuiltInRegistries.TRIGGER_TYPES, id("krill_self"), KRILL_SELF);
Registry.register(BuiltInRegistries.TRIGGER_TYPES, id("krill"), KRILL_TRIGGER);
Registry.register(BuiltInRegistries.TRIGGER_TYPES, id("krill_self"), KRILL_SELF_TRIGGER);
Registry.register(BuiltInRegistries.TRIGGER_TYPES, id("load_shrimp"), LOAD_SHRIMP_TRIGGER);

ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.SPAWN_EGGS).register(entries -> entries.accept(SHRIMP_EGG));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.github.tropheusj.its_as_shrimple_as_that.criteria;

import java.util.Optional;

import io.github.tropheusj.its_as_shrimple_as_that.criteria.KrillTrigger.TriggerInstance;

import org.jetbrains.annotations.NotNull;

import com.mojang.serialization.Codec;

import net.minecraft.advancements.critereon.ContextAwarePredicate;
import net.minecraft.advancements.critereon.SimpleCriterionTrigger;
import net.minecraft.server.level.ServerPlayer;

public class KrillTrigger extends SimpleCriterionTrigger<TriggerInstance> {
public void trigger(ServerPlayer player) {
this.trigger(player, instance -> true);
}

@Override
@NotNull
public Codec<TriggerInstance> codec() {
return TriggerInstance.CODEC;
}

public record TriggerInstance() implements SimpleInstance {
public static final Codec<TriggerInstance> CODEC = Codec.unit(new TriggerInstance());

@Override
@NotNull
public Optional<ContextAwarePredicate> player() {
return Optional.empty();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.github.tropheusj.its_as_shrimple_as_that.criteria;

import java.util.Optional;

import com.mojang.serialization.Codec;

import io.github.tropheusj.its_as_shrimple_as_that.criteria.LoadShrimpTrigger.TriggerInstance;

import org.jetbrains.annotations.NotNull;

import net.minecraft.advancements.critereon.ContextAwarePredicate;
import net.minecraft.advancements.critereon.SimpleCriterionTrigger;
import net.minecraft.server.level.ServerPlayer;

public class LoadShrimpTrigger extends SimpleCriterionTrigger<TriggerInstance> {
public void trigger(ServerPlayer player) {
this.trigger(player, instance -> true);
}

@Override
@NotNull
public Codec<TriggerInstance> codec() {
return TriggerInstance.CODEC;
}

public record TriggerInstance() implements SimpleInstance {
public static final Codec<TriggerInstance> CODEC = Codec.unit(new TriggerInstance());

@Override
@NotNull
public Optional<ContextAwarePredicate> player() {
return Optional.empty();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@
import org.jetbrains.annotations.Nullable;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
Expand All @@ -26,6 +23,9 @@ public static void transform(LivingEntity entity, @Nullable Entity kriller) {
if (entity instanceof ShrimpEntity)
return;

if (kriller instanceof ServerPlayer player)
ItsAsShrimpleAsThat.KRILL_TRIGGER.trigger(player);

// particles
AABB bounds = entity.getBoundingBox();
BlockPos.betweenClosedStream(bounds).forEach(pos -> {
Expand Down Expand Up @@ -66,7 +66,7 @@ private static void transformPlayer(ServerPlayer player, Entity kriller) {
player.addEffect(new MobEffectInstance(ItsAsShrimpleAsThat.KRILLED, 30 * 20));
if (player == kriller) {
// krilled self
ItsAsShrimpleAsThat.KRILL_SELF.trigger(player);
ItsAsShrimpleAsThat.KRILL_SELF_TRIGGER.trigger(player);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.tropheusj.its_as_shrimple_as_that.entity;

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

Expand Down Expand Up @@ -89,10 +88,11 @@ protected InteractionResult mobInteract(Player player, InteractionHand interacti
ChargedProjectiles ammo = held.get(DataComponents.CHARGED_PROJECTILES);
if (ammo != null && ammo.isEmpty()) {
// lock and load
if (!this.level().isClientSide) {
if (player instanceof ServerPlayer serverPlayer) {
ChargedProjectiles newAmmo = ChargedProjectiles.of(new ItemStack(ItsAsShrimpleAsThat.SHRIMP_ARROW));
held.set(DataComponents.CHARGED_PROJECTILES, newAmmo);
this.makeSound(SoundEvents.ITEM_FRAME_REMOVE_ITEM);
ItsAsShrimpleAsThat.LOAD_SHRIMP_TRIGGER.trigger(serverPlayer);
this.discard();
}
return InteractionResult.sidedSuccess(this.level().isClientSide);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
{
"parent": "its_as_shrimple_as_that:one_in_a_krillion",
"display": {
"icon": {
"id": "its_as_shrimple_as_that:fried_rice"
"id": "its_as_shrimple_as_that:shrimp_spawn_egg"
},
"title": "You're telling me a shrimp fried this rice?",
"description": "It couldn't be more true.",
"frame": "challenge",
"show_toast": true,
"announce_to_chat": true,
"title": "It's as Shrimple as That",
"description": "Or is it?",
"background": "minecraft:textures/block/terredepomme.png",
"frame": "task",
"show_toast": false,
"announce_to_chat": false,
"hidden": false
},
"criteria": {
"traded": {
"trigger": "minecraft:villager_trade",
"conditions": {
"item": {
"items": "its_as_shrimple_as_that:fried_rice",
"count": 1
}
}
"impossible": {
"trigger": "minecraft:impossible"
}
},
"requirements": [
[
"traded"
"impossible"
]
],
"rewards": {
"experience": 42069
}
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"parent": "its_as_shrimple_as_that:one_in_a_krillion",
"parent": "its_as_shrimple_as_that:krilled",
"display": {
"icon": {
"id": "its_as_shrimple_as_that:shrimp_spawn_egg"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"parent": "its_as_shrimple_as_that:unimaginable_power",
"display": {
"icon": {
"id": "its_as_shrimple_as_that:shrimp_spawn_egg"
},
"title": "Krilled",
"description": "An unconventional strategy.",
"frame": "task",
"show_toast": true,
"announce_to_chat": true,
"hidden": true
},
"criteria": {
"krill": {
"trigger": "its_as_shrimple_as_that:krill"
}
},
"requirements": [
[
"krill"
]
]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"parent": "its_as_shrimple_as_that:its_as_shrimple_as_that",
"display": {
"icon": {
"id": "its_as_shrimple_as_that:shrimp_spawn_egg",
Expand All @@ -9,8 +10,7 @@
}
},
"title": "One in a krillion",
"description": "Help a shrimp to accomplish its dreams.",
"background": "minecraft:textures/block/terredepomme.png",
"description": "Help a shrimp accomplish its dreams.",
"frame": "task",
"show_toast": true,
"announce_to_chat": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"parent": "its_as_shrimple_as_that:one_in_a_krillion",
"display": {
"icon": {
"id": "its_as_shrimple_as_that:fried_rice"
},
"title": "You're telling me a shrimp fried this rice?",
"description": "It couldn't be more true.",
"frame": "challenge",
"show_toast": true,
"announce_to_chat": true,
"hidden": false
},
"criteria": {
"traded": {
"trigger": "minecraft:villager_trade",
"conditions": {
"item": {
"items": "its_as_shrimple_as_that:fried_rice",
"count": 1
}
}
}
},
"requirements": [
[
"traded"
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"parent": "its_as_shrimple_as_that:its_as_shrimple_as_that",
"display": {
"icon": {
"id": "minecraft:crossbow"
},
"title": "Unimaginable Power",
"description": "What will you do with it?",
"frame": "task",
"show_toast": true,
"announce_to_chat": true,
"hidden": false
},
"criteria": {
"load_shrimp": {
"trigger": "its_as_shrimple_as_that:load_shrimp"
}
},
"requirements": [
[
"load_shrimp"
]
]
}

0 comments on commit 87df66d

Please sign in to comment.