Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - public class CustomBlockBounce extends Block {
 - //Constructor stuff
 - public CustomBlockBounce (Material materialIn, String name //You can delete this and replace it with your block name) {
 - super(materialIn);
 - setUnlocalizedName(name);
 - setRegistryName(name);
 - MinecraftForge.EventBus.register(this);
 - }
 - @SubscribeEvent
 - public void onPlayerStepOn(LivingEvent.LivingJumpEvent event) {
 - if(event.getEntity() == null) {
 - return;
 - }
 - // check if we jumped from a block that bounce
 - BlockPos pos = new BlockPos(event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ);
 - if(event.getEntity().getEntityWorld().isAirBlock(pos)) {
 - pos = pos.down();
 - }
 - IBlockState state = event.getEntity().getEntityWorld().getBlockState(pos);
 - Block block = state.getBlock();
 - if(block == ModBlocks.customBlockBounce) {
 - bounce(event.getEntity(), 1.0f);
 - }
 - }
 - private void bounce(Entity entity, float amount) {
 - entity.motionY += amount;
 - }
 - }
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment