Shadow berry
This commit is contained in:
parent
29a594fd10
commit
5c9eda39f2
24 changed files with 321 additions and 10 deletions
|
@ -9,7 +9,7 @@ import ru.betterend.effects.EndEnchantments;
|
|||
import ru.betterend.effects.EndPotions;
|
||||
import ru.betterend.recipe.AlloyingRecipes;
|
||||
import ru.betterend.recipe.CraftingRecipes;
|
||||
import ru.betterend.recipe.SmeltigRecipes;
|
||||
import ru.betterend.recipe.FurnaceRecipes;
|
||||
import ru.betterend.recipe.SmithingRecipes;
|
||||
import ru.betterend.registry.EndBiomes;
|
||||
import ru.betterend.registry.EndBlockEntities;
|
||||
|
@ -42,7 +42,7 @@ public class BetterEnd implements ModInitializer {
|
|||
EndEnchantments.register();
|
||||
EndPotions.register();
|
||||
CraftingRecipes.register();
|
||||
SmeltigRecipes.register();
|
||||
FurnaceRecipes.register();
|
||||
AlloyingRecipes.register();
|
||||
SmithingRecipes.register();
|
||||
EndStructures.register();
|
||||
|
|
|
@ -15,7 +15,7 @@ import ru.betterend.util.MHelper;
|
|||
|
||||
public class BlockBlueVineSeed extends BlockPlantWithAge {
|
||||
@Override
|
||||
public void grow(StructureWorldAccess world, Random random, BlockPos pos) {
|
||||
public void growAdult(StructureWorldAccess world, Random random, BlockPos pos) {
|
||||
int height = MHelper.randRange(2, 5, random);
|
||||
int h = BlocksHelper.upRay(world, pos, height + 2);
|
||||
if (h < height + 1) {
|
||||
|
|
58
src/main/java/ru/betterend/blocks/BlockShadowBerry.java
Normal file
58
src/main/java/ru/betterend/blocks/BlockShadowBerry.java
Normal file
|
@ -0,0 +1,58 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.World;
|
||||
import ru.betterend.blocks.basis.BlockPlantWithAge;
|
||||
import ru.betterend.registry.EndItems;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class BlockShadowBerry extends BlockPlantWithAge {
|
||||
private static final VoxelShape SHAPE = Block.createCuboidShape(1, 0, 1, 15, 8, 15);
|
||||
|
||||
@Override
|
||||
public void growAdult(StructureWorldAccess world, Random random, BlockPos pos) {}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||
if (state.get(AGE) < 3) {
|
||||
return Lists.newArrayList(new ItemStack(this));
|
||||
}
|
||||
else {
|
||||
return Lists.newArrayList(new ItemStack(this), new ItemStack(EndItems.SHADOW_BERRY_RAW, MHelper.randRange(1, 3, MHelper.RANDOM)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
|
||||
return state.get(AGE) < 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
|
||||
return state.get(AGE) < 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractBlock.OffsetType getOffsetType() {
|
||||
return AbstractBlock.OffsetType.NONE;
|
||||
}
|
||||
}
|
|
@ -31,7 +31,7 @@ public abstract class BlockPlantWithAge extends BlockPlant {
|
|||
stateManager.add(AGE);
|
||||
}
|
||||
|
||||
public abstract void grow(StructureWorldAccess world, Random random, BlockPos pos);
|
||||
public abstract void growAdult(StructureWorldAccess world, Random random, BlockPos pos);
|
||||
|
||||
@Override
|
||||
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
|
||||
|
@ -41,7 +41,7 @@ public abstract class BlockPlantWithAge extends BlockPlant {
|
|||
world.setBlockState(pos, state.with(AGE, age + 1));
|
||||
}
|
||||
else {
|
||||
grow(world, random, pos);
|
||||
growAdult(world, random, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,6 +93,7 @@ public class CraftingRecipes {
|
|||
GridRecipe.make("aurora_block", EndBlocks.AURORA_CRYSTAL).setShape("##", "##").addMaterial('#', EndItems.CRYSTAL_SHARDS).build();
|
||||
GridRecipe.make("lotus_block", EndBlocks.END_LOTUS.log).setShape("##", "##").addMaterial('#', EndBlocks.END_LOTUS_STEM).build();
|
||||
GridRecipe.make("needlegrass_stick", Items.STICK).setList("#").setOutputCount(2).addMaterial('#', EndBlocks.NEEDLEGRASS).build();
|
||||
GridRecipe.make("shadow_berry_seeds", EndBlocks.SHADOW_BERRY).setList("#").setOutputCount(4).addMaterial('#', EndItems.SHADOW_BERRY_RAW).build();
|
||||
}
|
||||
|
||||
public static void registerPedestal(String name, Block pedestal, Block slab, Block pillar) {
|
||||
|
|
|
@ -5,9 +5,10 @@ import ru.betterend.recipe.builders.FurnaceRecipe;
|
|||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndItems;
|
||||
|
||||
public class SmeltigRecipes {
|
||||
public class FurnaceRecipes {
|
||||
public static void register() {
|
||||
FurnaceRecipe.make("end_lily_leaf_dried", EndItems.END_LILY_LEAF, EndItems.END_LILY_LEAF_DRIED).build();
|
||||
FurnaceRecipe.make("end_glass", EndBlocks.ENDSTONE_DUST, Blocks.GLASS).build();
|
||||
FurnaceRecipe.make("end_glass", EndItems.SHADOW_BERRY_RAW, EndItems.SHADOW_BERRY_COOKED).build();
|
||||
}
|
||||
}
|
|
@ -28,10 +28,11 @@ import ru.betterend.blocks.BlockLacugroveSapling;
|
|||
import ru.betterend.blocks.BlockMossyGlowshroomCap;
|
||||
import ru.betterend.blocks.BlockMossyGlowshroomHymenophore;
|
||||
import ru.betterend.blocks.BlockMossyGlowshroomSapling;
|
||||
import ru.betterend.blocks.BlockPath;
|
||||
import ru.betterend.blocks.BlockMurkweed;
|
||||
import ru.betterend.blocks.BlockNeedlegrass;
|
||||
import ru.betterend.blocks.BlockPath;
|
||||
import ru.betterend.blocks.BlockPythadendronSapling;
|
||||
import ru.betterend.blocks.BlockShadowBerry;
|
||||
import ru.betterend.blocks.BlockShadowGrass;
|
||||
import ru.betterend.blocks.BlockTerrain;
|
||||
import ru.betterend.blocks.BlockTerrainPlant;
|
||||
|
@ -131,6 +132,9 @@ public class EndBlocks {
|
|||
public static final Block MURKWEED = registerBlock("murkweed", new BlockMurkweed());
|
||||
public static final Block NEEDLEGRASS = registerBlock("needlegrass", new BlockNeedlegrass());
|
||||
|
||||
// Crops //
|
||||
public static final Block SHADOW_BERRY = registerBlock("shadow_berry", new BlockShadowBerry());
|
||||
|
||||
// Vines //
|
||||
public static final Block DENSE_VINE = registerBlock("dense_vine", new BlockVine(15, true));
|
||||
public static final Block TWISTED_VINE = registerBlock("twisted_vine", new BlockVine());
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraft.entity.EquipmentSlot;
|
|||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.item.ArmorItem;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.FoodComponent;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Item.Settings;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -77,6 +78,10 @@ public class EndItems {
|
|||
public static final ToolItem DIAMOND_HAMMER = registerTool("diamond_hammer", new EndHammer(ToolMaterials.DIAMOND, 5.5F, -3.1F, 0.2D, makeSettings()));
|
||||
public static final ToolItem NETHERITE_HAMMER = registerTool("netherite_hammer", new EndHammer(ToolMaterials.NETHERITE, 5.0F, -3.0F, 0.2D, makeSettings()));
|
||||
|
||||
// Food //
|
||||
public final static Item SHADOW_BERRY_RAW = registerFood("shadow_berry_raw", 4, 0.5F);
|
||||
public final static Item SHADOW_BERRY_COOKED = registerFood("shadow_berry_cooked", 6, 0.7F);
|
||||
|
||||
// Other //
|
||||
public static final Item ETERNAL_CRYSTAL = registerItem("eternal_crystal", new EternalCrystal());
|
||||
|
||||
|
@ -130,6 +135,14 @@ public class EndItems {
|
|||
DispenserBlock.registerBehavior(item, behavior);
|
||||
return registerItem(name, item);
|
||||
}
|
||||
|
||||
public static Item registerFood(String name, int hunger, float saturation) {
|
||||
return registerFood(name, new FoodComponent.Builder().hunger(hunger).saturationModifier(saturation).build());
|
||||
}
|
||||
|
||||
public static Item registerFood(String name, FoodComponent foodComponent) {
|
||||
return registerItem(name, new Item(makeSettings().food(foodComponent)));
|
||||
}
|
||||
|
||||
public static Settings makeSettings() {
|
||||
return new Item.Settings().group(CreativeTab.END_TAB);
|
||||
|
|
|
@ -30,7 +30,7 @@ public class BlueVineFeature extends ScatterFeature {
|
|||
}
|
||||
else {
|
||||
BlockPlantWithAge seed = ((BlockPlantWithAge) EndBlocks.BLUE_VINE_SEED);
|
||||
seed.grow(world, random, blockPos);
|
||||
seed.growAdult(world, random, blockPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue