added nether wart trees

This commit is contained in:
Ellpeck 2020-01-30 16:04:40 +01:00
parent d5cb1ab0df
commit 22c38d363e
14 changed files with 188 additions and 3 deletions

View file

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "naturesaura:block/nether_wart_mushroom"
}
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "naturesaura:block/nether_wart_mushroom"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "naturesaura:item/crimson_meal"
}
}

View file

@ -0,0 +1,3 @@
{
"parent": "naturesaura:block/nether_wart_mushroom"
}

View file

@ -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"
}
]
}
]
}
]
}

View file

@ -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);

View file

@ -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> T survivesExplosion(Block block, ILootConditionConsumer<T> then) {
return withSurvivesExplosion(block, then);
}

View file

@ -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<NoFeatureConfig> {
public WorldGenNetherWartMushroom() {
super(d -> NoFeatureConfig.NO_FEATURE_CONFIG);
}
@Override
public boolean place(IWorld worldIn, ChunkGenerator<? extends GenerationSettings> 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);
}
}

View file

@ -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;
}
}

View file

@ -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;
}

View file

@ -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());
}

View file

@ -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",

Binary file not shown.

After

Width:  |  Height:  |  Size: 455 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 B