simple-tech

Minecraft: Better than Adventure! mod that adds simple blocks to automate tasks
git clone git://memoryshards.xyz/simple-tech.git
Log | Files | Refs | README | LICENSE

BlockJumpPad.java (1664B)


      1 package ambos.simpletech.block;
      2 
      3 import net.minecraft.core.block.Block;
      4 import net.minecraft.core.block.material.Material;
      5 import net.minecraft.core.entity.Entity;
      6 import net.minecraft.core.entity.EntityItem;
      7 import net.minecraft.core.entity.EntityLiving;
      8 import net.minecraft.core.world.World;
      9 
     10 public class BlockJumpPad extends Block {
     11     public BlockJumpPad(String key, int id, Material material) {
     12         super(key, id, material);
     13     }
     14 
     15     @Override
     16     public boolean isSolidRender() {
     17         return false;
     18     }
     19 
     20     @Override
     21     public boolean canPlaceBlockAt(World world, int x, int y, int z) {
     22         return world.isBlockOpaqueCube(x, y - 1, z);
     23     }
     24 
     25     public void jump(Entity entity) {
     26         if ((entity instanceof EntityLiving || entity instanceof EntityItem) && entity.yd < 1.0D) {
     27             entity.yd = 0.0D;
     28             entity.fallDistance = 0.0F;
     29             entity.push(0.0D, 1.0D, 0.0D);
     30         }
     31     }
     32 
     33     @Override
     34     public void onEntityWalking(World world, int x, int y, int z, Entity entity) {
     35         this.jump(entity);
     36     }
     37 
     38     @Override
     39     public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
     40         if (entity.y > (double) y) {
     41             this.jump(entity);
     42         }
     43     }
     44 
     45     @Override
     46     public void setBlockBoundsBasedOnState(World world, int x, int y, int z) {
     47         // Sets block shape when placed.
     48         this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 0.25f, 1.0f);
     49     }
     50 
     51     @Override
     52     public void setBlockBoundsForItemRender() {
     53         // Sets block shape when rendered inside containers.
     54         this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 0.25f, 1.0f);
     55     }
     56 }