use of net.minecraft.world.phys.Vec3 in project Denizen-For-Bukkit by DenizenScript.
the class EntityHelperImpl method forceInteraction.
@Override
public void forceInteraction(Player player, Location location) {
CraftPlayer craftPlayer = (CraftPlayer) player;
BlockPos pos = new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ());
((CraftBlock) location.getBlock()).getNMS().use(((CraftWorld) location.getWorld()).getHandle(), craftPlayer != null ? craftPlayer.getHandle() : null, InteractionHand.MAIN_HAND, new BlockHitResult(new Vec3(0, 0, 0), null, pos, false));
}
use of net.minecraft.world.phys.Vec3 in project Denizen-For-Bukkit by DenizenScript.
the class FishingHelperImpl method getRandomReward.
public ItemStack getRandomReward(FishingHook hook, ResourceLocation key) {
ServerLevel worldServer = (ServerLevel) hook.level;
LootContext.Builder playerFishEvent2 = new LootContext.Builder(worldServer);
LootTables registry = ((ServerLevel) hook.level).getServer().getLootTables();
// registry.getLootTable(key).getLootContextParameterSet()
LootContext info = playerFishEvent2.withOptionalParameter(LootContextParams.ORIGIN, new Vec3(hook.getX(), hook.getY(), hook.getZ())).withOptionalParameter(LootContextParams.TOOL, new ItemStack(Items.FISHING_ROD)).create(LootContextParamSets.FISHING);
List<ItemStack> itemStacks = registry.get(key).getRandomItems(info);
return itemStacks.get(worldServer.random.nextInt(itemStacks.size()));
}
use of net.minecraft.world.phys.Vec3 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.world.phys.Vec3 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.world.phys.Vec3 in project SpongeCommon by SpongePowered.
the class ServerLevelMixin method impl$constructPostEventForEntityAdd.
@Inject(method = "addEntity", at = @At("HEAD"))
private void impl$constructPostEventForEntityAdd(final Entity entity, final CallbackInfoReturnable<Boolean> cir) {
if (!(entity instanceof EntityBridge)) {
return;
}
if (!((EntityBridge) entity).bridge$isConstructing()) {
return;
}
((EntityBridge) entity).bridge$fireConstructors();
final Vec3 position = entity.position();
final ServerLocation location = ServerLocation.of((ServerWorld) this, position.x(), position.y(), position.z());
final Vec2 rotationVector = entity.getRotationVector();
final Vector3d rotation = new Vector3d(rotationVector.x, rotationVector.y, 0);
try (final CauseStackManager.StackFrame frame = PhaseTracker.SERVER.pushCauseFrame()) {
frame.pushCause(entity);
final Event construct = SpongeEventFactory.createConstructEntityEventPost(frame.currentCause(), (org.spongepowered.api.entity.Entity) entity, location, rotation, ((EntityType<?>) entity.getType()));
SpongeCommon.post(construct);
}
}
Aggregations