55 lines
2.2 KiB
Java
55 lines
2.2 KiB
Java
package com.dairymoose.modernlife.blocks;
|
|
|
|
import com.dairymoose.entity.BicycleEntity;
|
|
import java.util.List;
|
|
import javax.annotation.Nullable;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.network.chat.Component;
|
|
import net.minecraft.network.chat.TextComponent;
|
|
import net.minecraft.world.entity.Entity;
|
|
import net.minecraft.world.item.ItemStack;
|
|
import net.minecraft.world.item.TooltipFlag;
|
|
import net.minecraft.world.level.BlockGetter;
|
|
import net.minecraft.world.level.Level;
|
|
import net.minecraft.world.level.block.Block;
|
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.world.phys.Vec3;
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
|
|
/* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/PavedRoadBlock.class */
|
|
public class PavedRoadBlock extends Block {
|
|
public PavedRoadBlock(Properties p_i48377_1_) {
|
|
super(p_i48377_1_);
|
|
}
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
public void appendHoverText(ItemStack itemStack, @Nullable BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag) {
|
|
list.add(new TextComponent("Slightly increases movement speed of vehicles"));
|
|
}
|
|
|
|
public static void steppedOn(Entity entity) {
|
|
if (entity.getVehicle() != null || entity.isVehicle()) {
|
|
float fallDist = entity.fallDistance;
|
|
if (entity.isVehicle()) {
|
|
Vec3 mov = entity.getDeltaMovement();
|
|
if (entity instanceof BicycleEntity) {
|
|
} else {
|
|
double velocity = Math.sqrt((mov.x * mov.x) + (mov.z * mov.z));
|
|
double newVelocity = velocity * 1.1d;
|
|
double angle = Math.atan2(mov.z, mov.x);
|
|
double newX = newVelocity * Math.cos(angle);
|
|
double newZ = newVelocity * Math.sin(angle);
|
|
entity.setDeltaMovement(newX, mov.y, newZ);
|
|
}
|
|
}
|
|
entity.fallDistance = fallDist;
|
|
}
|
|
}
|
|
|
|
public void stepOn(Level p_176199_1_, BlockPos p_176199_2_, BlockState state, Entity entity) {
|
|
steppedOn(entity);
|
|
}
|
|
}
|