mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
28 lines
709 B
Java
28 lines
709 B
Java
package com.hbm.blocks.generic;
|
|
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.entity.Entity;
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
import net.minecraft.world.World;
|
|
|
|
public class BlockSpeedy extends Block {
|
|
|
|
double speed;
|
|
|
|
public BlockSpeedy(Material mat, double speed) {
|
|
super(mat);
|
|
this.speed = speed;
|
|
}
|
|
|
|
@Override
|
|
public void onEntityWalking(World world, int x, int y, int z, Entity entity) {
|
|
|
|
if(entity instanceof EntityLivingBase) { //prevents vehicles from going mach 5
|
|
double tan = Math.atan2(entity.motionX, entity.motionZ);
|
|
entity.motionX += Math.sin(tan) * speed;
|
|
entity.motionZ += Math.cos(tan) * speed;
|
|
}
|
|
}
|
|
}
|