use of net.minecraft.core.BlockPos in project MyPet by xXKeyleXx.
the class EntityMyStrider method ride.
// Special riding for Lava
@Override
protected void ride(double motionSideways, double motionForward, double motionUpwards, float speedModifier) {
float speed;
if (this.specialFloat()) {
// This already has the floating/walking on Lava logic -> Now we just ride it like it's solid
double minY;
minY = this.getBoundingBox().minY;
float friction = 0.91F;
if (this.onGround) {
friction = this.level.getBlockState(new BlockPos(Mth.floor(this.getX()), Mth.floor(minY) - 1, Mth.floor(this.getZ()))).getBlock().getFriction() * 0.91F;
}
speed = speedModifier * (0.16277136F / (friction * friction * friction));
this.moveRelative(speed, new Vec3(motionSideways, motionUpwards, motionForward));
double motX = this.getDeltaMovement().x();
double motY = this.getDeltaMovement().y();
double motZ = this.getDeltaMovement().z();
Vec3 mot = new Vec3(motX, motY, motZ);
this.move(MoverType.SELF, mot);
if (this.horizontalCollision && this.onClimbable()) {
motY = 0.2D;
}
motY -= 0.08D;
motY *= 0.9800000190734863D;
motX *= friction;
motZ *= friction;
this.setDeltaMovement(motX, motY, motZ);
this.startRiding(this, false);
} else {
// Call normal riding when not in lava aka when specialFloat returned false
super.ride(motionSideways, motionForward, motionUpwards, speedModifier);
}
}
use of net.minecraft.core.BlockPos in project MyPet by xXKeyleXx.
the class PlatformHelper method getBlockBBsInBB.
public List getBlockBBsInBB(net.minecraft.world.level.Level world, AABB axisalignedbb) {
UnsafeList unsafeList = new UnsafeList();
int minX = Mth.floor(axisalignedbb.minX);
int maxX = (int) Math.ceil(axisalignedbb.maxX);
int minY = Mth.floor(axisalignedbb.minY);
int maxY = (int) Math.ceil(axisalignedbb.maxY);
int minZ = Mth.floor(axisalignedbb.minZ);
int maxZ = (int) Math.ceil(axisalignedbb.maxZ);
VoxelShape vec3d;
boolean isEmpty;
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
if (((ServerChunkCache) world.getChunkSource()).hasChunk(x >> 4, z >> 4)) {
for (int y = minY - 1; y <= maxY; y++) {
BlockPos bp = new BlockPos(x, y, z);
BlockState blockData = world.getBlockState(bp);
if (blockData != null && blockData.getMaterial().isSolid()) {
vec3d = blockData.getCollisionShape(world, bp);
isEmpty = vec3d.isEmpty();
if (!isEmpty) {
for (AABB bb : vec3d.toAabbs()) {
if (bb.move(bp).intersects(axisalignedbb)) {
unsafeList.add(bb);
}
}
}
}
}
}
}
}
return unsafeList;
}
use of net.minecraft.core.BlockPos in project MyPet by xXKeyleXx.
the class EatGrass method shouldStart.
@Override
public boolean shouldStart() {
if (!Configuration.MyPet.Sheep.CAN_REGROW_WOOL) {
return false;
} else if (!this.entityMySheep.getMyPet().isSheared()) {
return false;
} else if (entityMySheep.getRandom().nextInt(1000) != 0) {
return false;
} else if (this.entityMySheep.getTarget() != null && !this.entityMySheep.getMyPetTarget().isDead()) {
return false;
}
int blockLocX = Mth.floor(this.entityMySheep.getX());
int blockLocY = Mth.floor(this.entityMySheep.getY());
int blockLocZ = Mth.floor(this.entityMySheep.getZ());
BlockPos blockposition = new BlockPos(blockLocX, blockLocY, blockLocZ);
return GRASS.test(this.world.getBlockState(blockposition)) || this.world.getBlockState(blockposition.down()).getBlock() == Blocks.GRASS;
}
use of net.minecraft.core.BlockPos in project MyPet by xXKeyleXx.
the class EntityMyAquaticPet method ride.
// Special riding for Underwater
@Override
protected void ride(double motionSideways, double motionForward, double motionUpwards, float speedModifier) {
float speed;
if (this.isEyeInFluid(FluidTags.WATER)) {
// No floating, just riding
double minY;
minY = this.getBoundingBox().minY;
float friction = 0.91F;
if (this.onGround) {
friction = this.level.getBlockState(new BlockPos(Mth.floor(this.getX()), Mth.floor(minY) - 1, Mth.floor(this.getZ()))).getBlock().getFriction() * 0.91F;
}
speed = speedModifier * (0.16277136F / (friction * friction * friction));
this.moveRelative(speed, new Vec3(motionSideways, motionUpwards, motionForward));
double motX = this.getDeltaMovement().x();
double motY = this.getDeltaMovement().y();
double motZ = this.getDeltaMovement().z();
Vec3 mot = new Vec3(motX, motY, motZ);
this.move(MoverType.SELF, mot);
motY -= 0.1D;
motY *= 0.6D;
motY *= 0.9800000190734863D;
motX *= friction;
motZ *= friction;
this.setDeltaMovement(motX, motY, motZ);
this.startRiding(this, false);
} else {
// Call normal riding when not in water
super.ride(motionSideways, motionForward, motionUpwards, speedModifier);
}
}
Aggregations