diff --git a/src/generated/resources/assets/naturesaura/blockstates/nether_wart_mushroom.json b/src/generated/resources/assets/naturesaura/blockstates/nether_wart_mushroom.json new file mode 100644 index 00000000..41a124d9 --- /dev/null +++ b/src/generated/resources/assets/naturesaura/blockstates/nether_wart_mushroom.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "naturesaura:block/nether_wart_mushroom" + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/block/nether_wart_mushroom.json b/src/generated/resources/assets/naturesaura/models/block/nether_wart_mushroom.json new file mode 100644 index 00000000..c660e007 --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/block/nether_wart_mushroom.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "naturesaura:block/nether_wart_mushroom" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/item/crimson_meal.json b/src/generated/resources/assets/naturesaura/models/item/crimson_meal.json new file mode 100644 index 00000000..ecb5349d --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/item/crimson_meal.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "naturesaura:item/crimson_meal" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/item/nether_wart_mushroom.json b/src/generated/resources/assets/naturesaura/models/item/nether_wart_mushroom.json new file mode 100644 index 00000000..6dd6797e --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/item/nether_wart_mushroom.json @@ -0,0 +1,3 @@ +{ + "parent": "naturesaura:block/nether_wart_mushroom" +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/loot_tables/blocks/nether_wart_mushroom.json b/src/generated/resources/data/naturesaura/loot_tables/blocks/nether_wart_mushroom.json new file mode 100644 index 00000000..58beb3b7 --- /dev/null +++ b/src/generated/resources/data/naturesaura/loot_tables/blocks/nether_wart_mushroom.json @@ -0,0 +1,48 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ], + "name": "naturesaura:nether_wart_mushroom" + }, + { + "type": "minecraft:item", + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "min": 1.0, + "max": 2.0, + "type": "minecraft:uniform" + } + } + ], + "name": "minecraft:nether_wart" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java index ce2d823a..7ad8de38 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java @@ -58,6 +58,7 @@ public final class ModBlocks { public static Block DIMENSION_RAIL_NETHER; public static Block DIMENSION_RAIL_END; public static Block BLAST_FURNACE_BOOSTER; + public static Block NETHER_WART_MUSHROOM; public static Block.Properties prop(Material material, MaterialColor color) { return Block.Properties.create(material, color); diff --git a/src/main/java/de/ellpeck/naturesaura/data/BlockLootProvider.java b/src/main/java/de/ellpeck/naturesaura/data/BlockLootProvider.java index 36478514..be0ac57a 100644 --- a/src/main/java/de/ellpeck/naturesaura/data/BlockLootProvider.java +++ b/src/main/java/de/ellpeck/naturesaura/data/BlockLootProvider.java @@ -14,10 +14,12 @@ import net.minecraft.data.DataGenerator; import net.minecraft.data.DirectoryCache; import net.minecraft.data.IDataProvider; import net.minecraft.data.loot.BlockLootTables; +import net.minecraft.item.Items; import net.minecraft.util.ResourceLocation; import net.minecraft.world.storage.loot.*; import net.minecraft.world.storage.loot.conditions.BlockStateProperty; import net.minecraft.world.storage.loot.conditions.RandomChance; +import net.minecraft.world.storage.loot.functions.SetCount; import javax.annotation.Nonnull; import java.io.IOException; @@ -48,7 +50,7 @@ public class BlockLootProvider implements IDataProvider { this.lootFunctions.put(ModBlocks.ANCIENT_LEAVES, b -> LootTableHooks.genLeaves(b, ModBlocks.ANCIENT_SAPLING)); this.lootFunctions.put(ModBlocks.DECAYED_LEAVES, LootTableHooks::genSilkOnly); this.lootFunctions.put(ModBlocks.GOLDEN_LEAVES, b -> LootTable.builder().addLootPool(LootPool.builder().rolls(ConstantRange.of(1)).addEntry(LootTableHooks.survivesExplosion(b, ItemLootEntry.builder(ModItems.GOLD_LEAF)).acceptCondition(BlockStateProperty.builder(b).fromProperties(StatePropertiesPredicate.Builder.newBuilder().withIntProp(BlockGoldenLeaves.STAGE, BlockGoldenLeaves.HIGHEST_STAGE)))).acceptCondition(RandomChance.builder(0.75F)))); - + this.lootFunctions.put(ModBlocks.NETHER_WART_MUSHROOM, b -> LootTableHooks.genSilkOr(b, ItemLootEntry.builder(Items.NETHER_WART).acceptFunction(SetCount.builder(RandomValueRange.of(1, 2))))); } @Override @@ -90,6 +92,10 @@ public class BlockLootProvider implements IDataProvider { return onlyWithSilkTouch(block); } + public static LootTable.Builder genSilkOr(Block block, LootEntry.Builder builder) { + return droppingWithSilkTouch(block, builder); + } + public static T survivesExplosion(Block block, ILootConditionConsumer then) { return withSurvivesExplosion(block, then); } diff --git a/src/main/java/de/ellpeck/naturesaura/gen/WorldGenNetherWartMushroom.java b/src/main/java/de/ellpeck/naturesaura/gen/WorldGenNetherWartMushroom.java new file mode 100644 index 00000000..dd82498a --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/gen/WorldGenNetherWartMushroom.java @@ -0,0 +1,61 @@ +package de.ellpeck.naturesaura.gen; + +import de.ellpeck.naturesaura.blocks.ModBlocks; +import net.minecraft.block.Block; +import net.minecraft.block.Blocks; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IWorld; +import net.minecraft.world.gen.ChunkGenerator; +import net.minecraft.world.gen.GenerationSettings; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.NoFeatureConfig; + +import java.util.Random; + +public class WorldGenNetherWartMushroom extends Feature { + + public WorldGenNetherWartMushroom() { + super(d -> NoFeatureConfig.NO_FEATURE_CONFIG); + } + + @Override + public boolean place(IWorld worldIn, ChunkGenerator generator, Random rand, BlockPos pos, NoFeatureConfig config) { + int height = rand.nextInt(5) + 4; + if (rand.nextInt(10) == 0) + height += 5; + + // Check if the stem has space + for (int i = 1; i < height; i++) { + BlockPos offset = pos.up(i); + if (worldIn.hasBlockState(offset, s -> !s.canBeReplacedByLogs(worldIn, offset))) + return false; + } + + // Place stem + this.setBlockState(worldIn, pos, Blocks.AIR.getDefaultState()); + for (int i = 0; i < height; i++) + this.placeIfPossible(worldIn, pos.up(i), Blocks.NETHER_WART_BLOCK); + + // Place hat + int rad = 3; + for (int x = -rad; x <= rad; x++) { + for (int z = -rad; z <= rad; z++) { + int absX = Math.abs(x); + int absZ = Math.abs(z); + if (absX <= 1 && absZ <= 1) { + this.placeIfPossible(worldIn, pos.add(x, height, z), ModBlocks.NETHER_WART_MUSHROOM); + } else if (absX <= 2 && absZ <= 2 && absX != absZ) { + this.placeIfPossible(worldIn, pos.add(x, height - 1, z), ModBlocks.NETHER_WART_MUSHROOM); + } else if (absX < rad - 1 || absZ < rad - 1 || absX == rad - 1 && absZ == rad - 1) { + this.placeIfPossible(worldIn, pos.add(x, height - 2, z), ModBlocks.NETHER_WART_MUSHROOM); + } + } + } + return true; + } + + private void placeIfPossible(IWorld world, BlockPos pos, Block block) { + if (world.hasBlockState(pos, s -> s.canBeReplacedByLogs(world, pos))) + world.setBlockState(pos, block.getDefaultState(), 19); + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemCrimsonMeal.java b/src/main/java/de/ellpeck/naturesaura/items/ItemCrimsonMeal.java new file mode 100644 index 00000000..3a9dc195 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemCrimsonMeal.java @@ -0,0 +1,41 @@ +package de.ellpeck.naturesaura.items; + +import de.ellpeck.naturesaura.gen.WorldGenNetherWartMushroom; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.NetherWartBlock; +import net.minecraft.item.ItemUseContext; +import net.minecraft.util.ActionResultType; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.IFeatureConfig; +import net.minecraft.world.server.ServerWorld; + +public class ItemCrimsonMeal extends ItemImpl { + public ItemCrimsonMeal() { + super("crimson_meal"); + } + + @Override + public ActionResultType onItemUse(ItemUseContext context) { + World world = context.getWorld(); + BlockPos pos = context.getPos(); + BlockState state = world.getBlockState(pos); + if (state.getBlock() == Blocks.NETHER_WART) { + if (!world.isRemote) { + if (world.rand.nextInt(5) == 0) { + int age = state.get(NetherWartBlock.AGE); + if (age >= 3) { + new WorldGenNetherWartMushroom().place(world, ((ServerWorld) world).getChunkProvider().getChunkGenerator(), world.rand, pos, IFeatureConfig.NO_FEATURE_CONFIG); + } else { + world.setBlockState(pos, state.with(NetherWartBlock.AGE, age + 1)); + } + } + world.playEvent(2005, pos, 0); + context.getItem().shrink(1); + } + return ActionResultType.SUCCESS; + } + return ActionResultType.FAIL; + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/items/ModItems.java b/src/main/java/de/ellpeck/naturesaura/items/ModItems.java index d3b76e4b..512be495 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ModItems.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ModItems.java @@ -44,4 +44,5 @@ public final class ModItems { public static Item TOKEN_GRIEF; public static Item ENDER_ACCESS; public static Item CAVE_FINDER; + public static Item CRIMSON_MEAL; } diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java index b778da4c..02bd099c 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java @@ -21,6 +21,7 @@ import de.ellpeck.naturesaura.items.tools.*; import de.ellpeck.naturesaura.potion.ModPotions; import de.ellpeck.naturesaura.potion.PotionBreathless; import net.minecraft.block.Block; +import net.minecraft.block.Blocks; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.enchantment.Enchantment; @@ -105,7 +106,8 @@ public final class ModRegistry { new BlockDimensionRail("overworld", DimensionType.OVERWORLD, DimensionType.THE_NETHER, DimensionType.THE_END), new BlockDimensionRail("nether", DimensionType.THE_NETHER, DimensionType.OVERWORLD), new BlockDimensionRail("end", DimensionType.THE_END, DimensionType.OVERWORLD), - new BlockBlastFurnaceBooster() + new BlockBlastFurnaceBooster(), + new BlockImpl("nether_wart_mushroom", ModBlocks.prop(Blocks.RED_MUSHROOM_BLOCK)) ); if (ModConfig.instance.rfConverter.get()) @@ -167,7 +169,8 @@ public final class ModRegistry { new ItemImpl("token_rage"), new ItemImpl("token_grief"), new ItemEnderAccess(), - new ItemCaveFinder() + new ItemCaveFinder(), + new ItemCrimsonMeal() ); Helper.populateObjectHolders(ModItems.class, event.getRegistry()); } diff --git a/src/main/resources/assets/naturesaura/lang/en_us.json b/src/main/resources/assets/naturesaura/lang/en_us.json index 5b838bff..39e38b9d 100644 --- a/src/main/resources/assets/naturesaura/lang/en_us.json +++ b/src/main/resources/assets/naturesaura/lang/en_us.json @@ -54,6 +54,7 @@ "block.naturesaura.dimension_rail_nether": "Rail of the Nether", "block.naturesaura.projectile_generator": "Shooting Mark", "block.naturesaura.blast_furnace_booster": "Armorer's Aid", + "block.naturesaura.nether_wart_mushroom": "Nether Wart Mushroom", "item.naturesaura.eye": "Environmental Eye", "item.naturesaura.eye_improved": "Environmental Ocular", "item.naturesaura.gold_fiber": "Brilliant Fiber", @@ -101,6 +102,7 @@ "item.naturesaura.ender_access": "Ender Ocular", "item.naturesaura.cave_finder": "Staff of Shadows", "item.naturesaura.aura_trove": "Aura Trove", + "item.naturesaura.crimson_meal": "Crimson Meal", "container.naturesaura:tree_ritual.name": "Ritual of the Forest", "container.naturesaura:altar.name": "Natural Altar Infusion", "container.naturesaura:offering.name": "Offering to the Gods", diff --git a/src/main/resources/assets/naturesaura/textures/block/nether_wart_mushroom.png b/src/main/resources/assets/naturesaura/textures/block/nether_wart_mushroom.png new file mode 100644 index 00000000..d912933c Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/block/nether_wart_mushroom.png differ diff --git a/src/main/resources/assets/naturesaura/textures/item/crimson_meal.png b/src/main/resources/assets/naturesaura/textures/item/crimson_meal.png new file mode 100644 index 00000000..1a3b08c8 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/item/crimson_meal.png differ