Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.mcreator.endrevival.block;
- import net.minecraftforge.fml.relauncher.SideOnly;
- import net.minecraftforge.fml.relauncher.Side;
- import net.minecraftforge.fml.common.registry.GameRegistry;
- import net.minecraftforge.client.model.ModelLoader;
- import net.minecraftforge.client.event.ModelRegistryEvent;
- import net.minecraft.world.World;
- import net.minecraft.world.IBlockAccess;
- import net.minecraft.util.math.RayTraceResult;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.util.NonNullList;
- import net.minecraft.util.BlockRenderLayer;
- import net.minecraft.item.ItemStack;
- import net.minecraft.item.ItemBlock;
- import net.minecraft.item.Item;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.client.renderer.block.model.ModelResourceLocation;
- import net.minecraft.block.state.IBlockState;
- import net.minecraft.block.material.Material;
- import net.minecraft.block.SoundType;
- import net.minecraft.block.Block;
- import net.minecraft.world.World;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.EntityLivingBase;
- import net.mcreator.endrevival.ElementsEndReborn;
- @ElementsEndReborn.ModElement.Tag
- public class BlockChorusblock extends ElementsEndReborn.ModElement {
- @GameRegistry.ObjectHolder("endrevival:chorusblock")
- public static final Block block = null;
- public BlockChorusblock(ElementsEndReborn instance) {
- super(instance, 16);
- }
- @Override
- public void initElements() {
- elements.blocks.add(() -> new BlockCustom().setRegistryName("chorusblock"));
- elements.items.add(() -> new ItemBlock(block).setRegistryName(block.getRegistryName()));
- }
- @SideOnly(Side.CLIENT)
- @Override
- public void registerModels(ModelRegistryEvent event) {
- ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation("endrevival:chorusblock", "inventory"));
- }
- public static class BlockCustom extends Block {
- public BlockCustom() {
- super(Material.SPONGE);
- setUnlocalizedName("chorusblock");
- setSoundType(SoundType.SLIME);
- setHardness(0F);
- setResistance(0F);
- setLightLevel(0F);
- setLightOpacity(0);
- setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
- }
- @SideOnly(Side.CLIENT)
- @Override
- public BlockRenderLayer getBlockLayer() {
- return BlockRenderLayer.TRANSLUCENT;
- }
- @Override
- public boolean isOpaqueCube(IBlockState state) {
- return false;
- }
- @Override
- public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
- return new ItemStack(BlockChorusblockitem.block, (int) (1));
- }
- @Override
- public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
- drops.add(new ItemStack(BlockChorusblockitem.block, (int) (1)));
- }
- public void onFallenUpon(World worldIn, BlockPos pos, Entity entityIn, float fallDistance)
- {
- if (entityIn.isSneaking())
- {
- super.onFallenUpon(worldIn, pos, entityIn, fallDistance);
- }
- else
- {
- entityIn.fall(fallDistance, 0.0F);
- }
- }
- /**
- * Called when an Entity lands on this Block. This method *must* update motionY because the entity will not do that
- * on its own
- */
- public void onLanded(World worldIn, Entity entityIn)
- {
- if (entityIn.isSneaking())
- {
- super.onLanded(worldIn, entityIn);
- }
- else if (entityIn.motionY < 0.0D)
- {
- entityIn.motionY = -entityIn.motionY;
- if (!(entityIn instanceof EntityLivingBase))
- {
- entityIn.motionY *= 0.8D;
- }
- }
- }
- /**
- * Triggered whenever an entity collides with this block (enters into the block)
- */
- public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn)
- {
- if (Math.abs(entityIn.motionY) < 0.1D && !entityIn.isSneaking())
- {
- double d0 = 0.4D + Math.abs(entityIn.motionY) * 0.2D;
- entityIn.motionX *= d0;
- entityIn.motionZ *= d0;
- }
- super.onEntityWalk(worldIn, pos, entityIn);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement