Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Hurt allow empty source & drops are missing when recipe can't match in exploding #75

Merged
merged 3 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main/java/snownee/lychee/core/post/Hurt.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.GsonHelper;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import snownee.lychee.Lychee;
Expand Down Expand Up @@ -58,7 +59,8 @@ public static class Type extends PostActionType<Hurt> {

@Override
public Hurt fromJson(JsonObject o) {
return new Hurt(MinMaxBounds.Doubles.fromJson(o.get("damage")), new ResourceLocation(o.get("source").getAsString()));
var source = new ResourceLocation(GsonHelper.getAsString(o, "source", "generic"));
return new Hurt(MinMaxBounds.Doubles.fromJson(o.get("damage")), source);
}

@Override
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/snownee/lychee/mixin/ExplosionMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ private void lychee_removeBlockPost(boolean bl, CallbackInfo ci, boolean bl2, Ob
return ctx;
});
if (result == null) {
for (ItemStack stack : pair.getSecond()) {
addBlockDrops(objectArrayList, stack, blockPos);
}
return;
}
BlockExplodingContext ctx = result.getFirst();
Expand Down
30 changes: 17 additions & 13 deletions src/main/resources/data/lychee/recipes/block_exploding3.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
{
"type": "lychee:block_exploding",
"block_in": "gold_block",
"post": [
{
"type": "place",
"block": "diamond_block"
},
{
"type": "drop_item",
"item": "diamond_block"
}
]
}
"type": "lychee:block_exploding",
"block_in": "gold_block",
"contextual": {
"type": "weather",
"weather": "rain"
},
"post": [
{
"type": "place",
"block": "diamond_block"
},
{
"type": "drop_item",
"item": "diamond_block"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"max": 1.5
}
}
}
}