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.below()).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);
}
}
use of net.minecraft.core.BlockPos in project Denizen-For-Bukkit by DenizenScript.
the class PacketHelperImpl method showBlockCrack.
@Override
public void showBlockCrack(Player player, int id, Location location, int progress) {
BlockPos position = new BlockPos(location.getX(), location.getY(), location.getZ());
send(player, new ClientboundBlockDestructionPacket(id, position, progress));
}
use of net.minecraft.core.BlockPos in project Denizen-For-Bukkit by DenizenScript.
the class PacketHelperImpl method showDebugTestMarker.
@Override
public void showDebugTestMarker(Player player, Location location, ColorTag color, int alpha, String name, int time) {
ResourceLocation packetKey = new ResourceLocation("minecraft", "debug/game_test_add_marker");
FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer());
buf.writeBlockPos(new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
int colorInt = color.getColor().getBlue() | (color.getColor().getGreen() << 8) | (color.getColor().getRed() << 16) | (alpha << 24);
buf.writeInt(colorInt);
buf.writeByteArray(name.getBytes(StandardCharsets.UTF_8));
buf.writeInt(time);
ClientboundCustomPayloadPacket packet = new ClientboundCustomPayloadPacket(packetKey, buf);
send(player, packet);
}
use of net.minecraft.core.BlockPos in project Denizen-For-Bukkit by DenizenScript.
the class BlockHelperImpl method setNbtData.
@Override
public void setNbtData(Block block, CompoundTag ctag) {
CompoundTagBuilder builder = ctag.createBuilder();
builder.putInt("x", block.getX());
builder.putInt("y", block.getY());
builder.putInt("z", block.getZ());
ctag = builder.build();
BlockPos blockPos = new BlockPos(block.getX(), block.getY(), block.getZ());
BlockEntity te = ((CraftWorld) block.getWorld()).getHandle().getTileEntity(blockPos, true);
te.load(((CompoundTagImpl) ctag).toNMSTag());
}
Aggregations