Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.mcreator.endrevival;
- 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.item.ItemBlock;
- import net.minecraft.item.Item;
- 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;
- @Elementsendrevival.ModElement.Tag
- public class MCreatorChorusblock extends Elementsendrevival.ModElement {
- @GameRegistry.ObjectHolder("endrevival:chorusblock")
- public static final Block block = null;
- public MCreatorChorusblock(Elementsendrevival instance) {
- super(instance, 34);
- }
- @Override
- public void initElements() {
- elements.blocks.add(() -> new BlockCustom());
- 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.CIRCUITS);
- setRegistryName("chorusblock");
- setUnlocalizedName("chorusblock");
- setSoundType(SoundType.SLIME);
- setHardness(0.05F);
- setResistance(0F);
- setLightLevel(0F);
- setLightOpacity(255);
- setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
- }
- @Override
- public boolean isOpaqueCube(IBlockState state) {
- return false;
- }
- }
- 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