From 1ed0a122127ea80afb6486d1d56b21c944e71a63 Mon Sep 17 00:00:00 2001 From: north82 <64515742+north82@users.noreply.github.com> Date: Wed, 7 Aug 2024 17:49:49 +0800 Subject: [PATCH 1/2] - Fix #31 - Added fruiting_avocado_leaves, along with its corresponding tags and English/Chinese --- .../common/registry/CDObjects.java | 2 +- .../assets/culturaldelights/lang/en_us.json | 1 + .../assets/culturaldelights/lang/zh_cn.json | 1 + .../blocks/fruiting_avocado_leaves.json | 193 ++++++++++++++++++ .../data/minecraft/tags/blocks/leaves.json | 3 +- .../minecraft/tags/blocks/mineable/hoe.json | 3 +- .../data/minecraft/tags/items/leaves.json | 3 +- 7 files changed, 202 insertions(+), 4 deletions(-) create mode 100644 src/main/resources/data/culturaldelights/loot_tables/blocks/fruiting_avocado_leaves.json diff --git a/src/main/java/dev/sterner/culturaldelights/common/registry/CDObjects.java b/src/main/java/dev/sterner/culturaldelights/common/registry/CDObjects.java index c14767f..ce1b551 100644 --- a/src/main/java/dev/sterner/culturaldelights/common/registry/CDObjects.java +++ b/src/main/java/dev/sterner/culturaldelights/common/registry/CDObjects.java @@ -84,7 +84,7 @@ public class CDObjects { public static final Block FRUITING_AVOCADO_LEAVES = register("fruiting_avocado_leaves", - new FruitingLeaves(BlockBehaviour.Properties.copy(Blocks.JUNGLE_LEAVES)), settings(), false); + new FruitingLeaves(BlockBehaviour.Properties.copy(Blocks.JUNGLE_LEAVES)), settings(), true); public static final Block WILD_CUCUMBERS = register("wild_cucumbers", new WildCropBlock(MobEffects.DAMAGE_BOOST, 6, FabricBlockSettings.copyOf(Blocks.TALL_GRASS)), settings(), true); public static final Block WILD_CORN = register("wild_corn", new WildCropBlock(MobEffects.DAMAGE_BOOST, 6, FabricBlockSettings.copyOf(Blocks.TALL_GRASS)), settings(), true); diff --git a/src/main/resources/assets/culturaldelights/lang/en_us.json b/src/main/resources/assets/culturaldelights/lang/en_us.json index bfefac6..0045cc7 100644 --- a/src/main/resources/assets/culturaldelights/lang/en_us.json +++ b/src/main/resources/assets/culturaldelights/lang/en_us.json @@ -67,6 +67,7 @@ "block.culturaldelights.avocado_log": "Avocado Log", "block.culturaldelights.avocado_wood": "Avocado Wood", "block.culturaldelights.avocado_leaves": "Avocado Leaves", + "block.culturaldelights.fruiting_avocado_leaves": "Fruiting Avocado Leaves", "block.culturaldelights.avocado_leaf_carpet": "Avocado Leaf Carpet", "block.culturaldelights.avocado_sapling": "Avocado Sapling", "block.culturaldelights.avocado_pit": "Avocado Pit", diff --git a/src/main/resources/assets/culturaldelights/lang/zh_cn.json b/src/main/resources/assets/culturaldelights/lang/zh_cn.json index 73fda58..3deb327 100644 --- a/src/main/resources/assets/culturaldelights/lang/zh_cn.json +++ b/src/main/resources/assets/culturaldelights/lang/zh_cn.json @@ -55,6 +55,7 @@ "block.culturaldelights.avocado_log": "牛油果树原木", "block.culturaldelights.avocado_wood": "牛油果树木", "block.culturaldelights.avocado_leaves": "牛油果树叶", + "block.culturaldelights.fruiting_avocado_leaves": "结果的牛油果树叶", "block.culturaldelights.avocado_leaf_carpet": "牛油果树叶地毯", "block.culturaldelights.avocado_sapling": "牛油果树苗", "block.culturaldelights.avocado_pit": "牛油果核", diff --git a/src/main/resources/data/culturaldelights/loot_tables/blocks/fruiting_avocado_leaves.json b/src/main/resources/data/culturaldelights/loot_tables/blocks/fruiting_avocado_leaves.json new file mode 100644 index 0000000..d03fa84 --- /dev/null +++ b/src/main/resources/data/culturaldelights/loot_tables/blocks/fruiting_avocado_leaves.json @@ -0,0 +1,193 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:any_of", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "items": [ + "minecraft:shears" + ] + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + ], + "name": "culturaldelights:fruiting_avocado_leaves" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + }, + { + "chances": [ + 0.05, + 0.0625, + 0.083333336, + 0.1 + ], + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune" + } + ], + "name": "culturaldelights:avocado_sapling" + } + ] + } + ], + "rolls": 1.0 + }, + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:inverted", + "term": { + "condition": "minecraft:any_of", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "items": [ + "minecraft:shears" + ] + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + } + ], + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "chances": [ + 0.02, + 0.022222223, + 0.025, + 0.033333335, + 0.1 + ], + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune" + } + ], + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 2.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "minecraft:stick" + } + ], + "rolls": 1.0 + }, + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:inverted", + "term": { + "condition": "minecraft:any_of", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "items": [ + "minecraft:shears" + ] + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + } + ], + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + }, + { + "chances": [ + 0.005, + 0.0055555557, + 0.00625, + 0.008333334, + 0.025 + ], + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune" + } + ], + "name": "culturaldelights:avocado" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "culturaldelights:blocks/fruiting_avocado_leaves" +} \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/blocks/leaves.json b/src/main/resources/data/minecraft/tags/blocks/leaves.json index 7fc6880..e404800 100644 --- a/src/main/resources/data/minecraft/tags/blocks/leaves.json +++ b/src/main/resources/data/minecraft/tags/blocks/leaves.json @@ -1,6 +1,7 @@ { "replace": false, "values": [ - "culturaldelights:avocado_leaves" + "culturaldelights:avocado_leaves", + "culturaldelights:fruiting_avocado_leaves" ] } \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/blocks/mineable/hoe.json b/src/main/resources/data/minecraft/tags/blocks/mineable/hoe.json index 7fc6880..e404800 100644 --- a/src/main/resources/data/minecraft/tags/blocks/mineable/hoe.json +++ b/src/main/resources/data/minecraft/tags/blocks/mineable/hoe.json @@ -1,6 +1,7 @@ { "replace": false, "values": [ - "culturaldelights:avocado_leaves" + "culturaldelights:avocado_leaves", + "culturaldelights:fruiting_avocado_leaves" ] } \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/items/leaves.json b/src/main/resources/data/minecraft/tags/items/leaves.json index 7fc6880..e404800 100644 --- a/src/main/resources/data/minecraft/tags/items/leaves.json +++ b/src/main/resources/data/minecraft/tags/items/leaves.json @@ -1,6 +1,7 @@ { "replace": false, "values": [ - "culturaldelights:avocado_leaves" + "culturaldelights:avocado_leaves", + "culturaldelights:fruiting_avocado_leaves" ] } \ No newline at end of file From d2e24fc2a4961d0463a301d496a8e3bec7505f2a Mon Sep 17 00:00:00 2001 From: north82 <64515742+north82@users.noreply.github.com> Date: Wed, 7 Aug 2024 22:52:12 +0800 Subject: [PATCH 2/2] - Fix #33 --- .../mixin/ZombieEntityMixin.java | 28 +++++++++++++++++++ .../resources/culturaldelights.mixins.json | 3 +- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/main/java/dev/sterner/culturaldelights/mixin/ZombieEntityMixin.java diff --git a/src/main/java/dev/sterner/culturaldelights/mixin/ZombieEntityMixin.java b/src/main/java/dev/sterner/culturaldelights/mixin/ZombieEntityMixin.java new file mode 100644 index 0000000..fc7d91b --- /dev/null +++ b/src/main/java/dev/sterner/culturaldelights/mixin/ZombieEntityMixin.java @@ -0,0 +1,28 @@ +package dev.sterner.culturaldelights.mixin; + +import dev.sterner.culturaldelights.common.registry.CDObjects; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.monster.Monster; +import net.minecraft.world.entity.monster.Zombie; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + + +@Mixin(Zombie.class) +public abstract class ZombieEntityMixin extends Monster { + + protected ZombieEntityMixin(EntityType entityType, Level level) { + super(entityType, level); + } + + @Inject(method = "wantsToPickUp", at = @At("RETURN"),cancellable = true) + public void wantsToPickUpInjected(ItemStack itemStack, CallbackInfoReturnable cir) { + if (itemStack.is(CDObjects.GLOW_SQUID)) { + cir.setReturnValue(false); + } + } +} \ No newline at end of file diff --git a/src/main/resources/culturaldelights.mixins.json b/src/main/resources/culturaldelights.mixins.json index 339bc53..38986bb 100644 --- a/src/main/resources/culturaldelights.mixins.json +++ b/src/main/resources/culturaldelights.mixins.json @@ -5,7 +5,8 @@ "compatibilityLevel": "JAVA_17", "mixins": [ "SimpleBlockStateProviderAccessor", - "TreeDecoratorTypeInvoker" + "TreeDecoratorTypeInvoker", + "ZombieEntityMixin" ], "client": [ ],