Some new plants

This commit is contained in:
paulevsGitch 2020-11-03 19:33:54 +03:00
parent cf2bdf541b
commit 0f36f048ea
28 changed files with 791 additions and 2 deletions

View file

@ -0,0 +1,41 @@
package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.BlockState;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import ru.betterend.blocks.basis.BlockPlant;
import ru.betterend.util.MHelper;
public class BlockNeedlegrass extends BlockPlant {
@Override
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
if (entity instanceof LivingEntity) {
entity.damage(DamageSource.CACTUS, 0.1F);
}
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.get(LootContextParameters.TOOL);
if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
return Lists.newArrayList(new ItemStack(this));
}
else {
return Lists.newArrayList(new ItemStack(Items.STICK, MHelper.randRange(0, 2, MHelper.RANDOM)));
}
}
}