use of net.minecraft.world.phys.Vec3 in project SolarCraftRepository by FINDERFEED.
the class InfusingTableTile method clientTick.
public void clientTick() {
if (isRecipeInProgress() && (level.getGameTime() % 2 == 0)) {
float time = -level.getGameTime() * 4;
Vec3 pos = Helpers.getBlockCenter(worldPosition);
for (int i = 0; i <= 1; i++) {
double a = Math.toRadians(i * 180 + time % 360);
double x = 0.5 * Math.sin(a);
double z = 0.5 * Math.cos(a);
ClientHelpers.ParticleConstructor c = new ClientHelpers.ParticleConstructor(ParticleTypesRegistry.SMALL_SOLAR_STRIKE_PARTICLE.get(), pos.x + x, pos.y + 0.9, pos.z + z, 0, 0, 0);
}
}
if (remainingRecipeTime != -1) {
Vec3 vec3 = Helpers.randomVector();
Vec3 pos = Helpers.getBlockCenter(worldPosition);
ClientHelpers.ParticleConstructor c = new ClientHelpers.ParticleConstructor(ParticleTypesRegistry.SPARK_PARTICLE.get(), pos.x, pos.y + 0.9, pos.z, vec3.x * 0.01, vec3.y * 0.01, vec3.z * 0.01).setColor(255, 255, Math.round(40 + level.random.nextFloat() * 120));
}
}
use of net.minecraft.world.phys.Vec3 in project SolarCraftRepository by FINDERFEED.
the class RunicElementalRenderer method handleHammerRender.
private void handleHammerRender(RunicElementalBoss boss, float something, float pticks, PoseStack matrices, MultiBufferSource buffer, int light, int attackTick) {
float scaleMod = 5;
if (attackTick <= 2)
return;
if (attackTick < 16) {
float value = (float) boss.getOrCreateAnimationValue("prepare_swing_hammer", new EaseInOut(0, 1, 15, 3)).getValue();
Vec3 dirVec = boss.getHammerAttackDirection();
matrices.pushPose();
matrices.translate(0, 1.75, 0);
RenderingTools.applyMovementMatrixRotations(matrices, dirVec.yRot((float) Math.toRadians(-80)));
matrices.mulPose(Vector3f.XP.rotationDegrees(180));
matrices.mulPose(Vector3f.YP.rotationDegrees(90));
matrices.translate(0, -3 * scaleMod + 0.5, 0);
matrices.scale(2, scaleMod, scaleMod);
HAMMER.renderToBuffer(matrices, buffer.getBuffer(RenderType.entityTranslucent(RunicHammerModel.TEXTURE_LOCATION)), light, OverlayTexture.NO_OVERLAY, 1, 1, 1, (float) FinderfeedMathHelper.clamp(0, value * 2, 1));
matrices.popPose();
} else if (attackTick < 26) {
float value = (float) boss.getOrCreateAnimationValue("swing_hammer", new EaseInOut(0, 2, 10, 3)).getValue() - 1;
Vec3 dirVec = boss.getHammerAttackDirection();
matrices.pushPose();
matrices.translate(0, 1.75, 0);
RenderingTools.applyMovementMatrixRotations(matrices, dirVec.yRot((float) Math.toRadians((value) * 80 + pticks)));
matrices.mulPose(Vector3f.XP.rotationDegrees(180));
matrices.mulPose(Vector3f.YP.rotationDegrees(90));
matrices.translate(0, -3 * scaleMod + 0.5, 0);
matrices.scale(2, scaleMod, scaleMod);
HAMMER.renderToBuffer(matrices, buffer.getBuffer(RenderType.entityTranslucent(RunicHammerModel.TEXTURE_LOCATION)), light, OverlayTexture.NO_OVERLAY, 1, 1, 1, 1);
matrices.popPose();
} else if (attackTick < 41) {
float value = 1 - (float) boss.getOrCreateAnimationValue("end_swing_hammer", new EaseInOut(0, 1, 15, 3)).getValue();
Vec3 dirVec = boss.getHammerAttackDirection();
matrices.pushPose();
matrices.translate(0, 1.75, 0);
RenderingTools.applyMovementMatrixRotations(matrices, dirVec.yRot((float) Math.toRadians(80)));
matrices.mulPose(Vector3f.XP.rotationDegrees(180));
matrices.mulPose(Vector3f.YP.rotationDegrees(90));
matrices.translate(0, -3 * scaleMod + 0.5, 0);
matrices.scale(2, scaleMod, scaleMod);
HAMMER.renderToBuffer(matrices, buffer.getBuffer(RenderType.entityTranslucent(RunicHammerModel.TEXTURE_LOCATION)), light, OverlayTexture.NO_OVERLAY, 1, 1, 1, (float) FinderfeedMathHelper.clamp(0, value * 2, 1));
matrices.popPose();
}
}
use of net.minecraft.world.phys.Vec3 in project SolarCraftRepository by FINDERFEED.
the class EarthquakeEntity method tick.
@Override
public void tick() {
if (!level.isClientSide) {
this.setDirection(this.getDir());
this.setLength(this.getLength());
if (tickCount == ACTIVATION_TIME) {
Vec3 dir = this.entityData.get(DIRECTION_VECTOR);
Vec3 initPos = position();
Vec3 endPos = initPos.add(dir.normalize().multiply(getLength() + 1, 0, getLength() + 1));
Vec3 beetween = initPos.subtract(endPos).normalize();
AABB box = new AABB(initPos.x + beetween.x, initPos.y, initPos.z + beetween.z, endPos.x + beetween.reverse().x, endPos.y + 6, endPos.z + beetween.reverse().z);
for (LivingEntity e : level.getEntitiesOfClass(LivingEntity.class, box, (l) -> !(l instanceof CrystalBossBuddy))) {
Vec3 vec = endPos.subtract(initPos).multiply(1, 0, 1);
Vec3 ePos = e.position().subtract(initPos).multiply(1, 0, 1);
double main = vec.length();
double a = ePos.length();
double b = vec.subtract(ePos).length();
double p = (main + a + b) / 2;
double S = Math.sqrt(p * (p - a) * (p - b) * (p - main));
double H = 2 * S / main;
if (H <= 2) {
e.hurt(DamageSource.MAGIC, damage);
}
}
}
if (tickCount >= DEATH_TIME - 20) {
this.kill();
}
} else {
if (tickCount == ACTIVATION_TIME - 2) {
Vec3 dir = this.entityData.get(DIRECTION_VECTOR);
Vec3 initPos = position();
Vec3 endPos = initPos.add(dir.normalize().multiply(getLength(), 0, getLength()));
Vec3 between = endPos.subtract(initPos);
for (int i = 0; i < 5; i++) {
for (double g = 0; g <= between.length(); g += 0.75) {
double percentile = (g + level.random.nextDouble() * 0.3) / between.length();
Vec3 pos = initPos.add(between.multiply(percentile, 0, percentile));
ClientHelpers.ParticleAnimationHelper.createParticle(ParticleTypesRegistry.SMALL_SOLAR_STRIKE_PARTICLE.get(), pos.x, pos.y, pos.z, 0, (0.1 + level.random.nextDouble() * 0.05) * (1 - i / 4f), 0, () -> 255, () -> 255, () -> 0, 0.5f * (i / 4f));
}
}
}
}
super.tick();
}
use of net.minecraft.world.phys.Vec3 in project SolarCraftRepository by FINDERFEED.
the class EarthquakeEntity method defineSynchedData.
@Override
protected void defineSynchedData() {
this.entityData.define(DIRECTION_VECTOR, new Vec3(1, 0, 1));
this.entityData.define(LENGTH, MAX_LENGTH);
}
use of net.minecraft.world.phys.Vec3 in project SolarCraftRepository by FINDERFEED.
the class MyFallingBlockEntity method tick.
public void tick() {
if (this.blockState.isAir()) {
this.discard();
} else {
Block block = this.blockState.getBlock();
++this.time;
if (!this.isNoGravity()) {
this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.04D, 0.0D));
}
this.move(MoverType.SELF, this.getDeltaMovement());
if (!this.level.isClientSide) {
BlockPos blockpos = this.blockPosition();
boolean flag = this.blockState.getBlock() instanceof ConcretePowderBlock;
boolean flag1 = flag && this.level.getFluidState(blockpos).is(FluidTags.WATER);
double d0 = this.getDeltaMovement().lengthSqr();
if (flag && d0 > 1.0D) {
BlockHitResult blockhitresult = this.level.clip(new ClipContext(new Vec3(this.xo, this.yo, this.zo), this.position(), ClipContext.Block.COLLIDER, ClipContext.Fluid.SOURCE_ONLY, this));
if (blockhitresult.getType() != HitResult.Type.MISS && this.level.getFluidState(blockhitresult.getBlockPos()).is(FluidTags.WATER)) {
blockpos = blockhitresult.getBlockPos();
flag1 = true;
}
}
if (!this.onGround && !flag1) {
if (!this.level.isClientSide && (this.time > 100 && (blockpos.getY() <= this.level.getMinBuildHeight() || blockpos.getY() > this.level.getMaxBuildHeight()) || this.time > 600)) {
if (this.dropItem && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
this.spawnAtLocation(block);
}
this.discard();
}
} else {
BlockState blockstate = this.level.getBlockState(blockpos);
this.setDeltaMovement(this.getDeltaMovement().multiply(0.7D, -0.5D, 0.7D));
if (!blockstate.is(Blocks.MOVING_PISTON)) {
if (!this.cancelDrop) {
boolean flag2 = blockstate.canBeReplaced(new DirectionalPlaceContext(this.level, blockpos, Direction.DOWN, ItemStack.EMPTY, Direction.UP));
boolean flag3 = FallingBlock.isFree(this.level.getBlockState(blockpos.below())) && (!flag || !flag1);
boolean flag4 = this.blockState.canSurvive(this.level, blockpos) && !flag3;
if (flag2 && flag4) {
if (this.blockState.hasProperty(BlockStateProperties.WATERLOGGED) && this.level.getFluidState(blockpos).getType() == Fluids.WATER) {
this.blockState = this.blockState.setValue(BlockStateProperties.WATERLOGGED, true);
}
if (this.level.setBlock(blockpos, this.blockState, 3)) {
((ServerLevel) this.level).getChunkSource().chunkMap.broadcast(this, new ClientboundBlockUpdatePacket(blockpos, this.level.getBlockState(blockpos)));
this.discard();
if (this.blockData != null && this.blockState.hasBlockEntity()) {
BlockEntity blockentity = this.level.getBlockEntity(blockpos);
if (blockentity != null) {
CompoundTag compoundtag = blockentity.saveWithoutMetadata();
for (String s : this.blockData.getAllKeys()) {
compoundtag.put(s, this.blockData.get(s).copy());
}
try {
blockentity.load(compoundtag);
} catch (Exception exception) {
SolarForge.LOGGER.error("Failed to load block entity from falling block", (Throwable) exception);
}
blockentity.setChanged();
}
}
} else if (this.dropItem && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
this.discard();
this.callOnBrokenAfterFall(block, blockpos);
this.spawnAtLocation(block);
}
} else {
this.discard();
if (this.dropItem && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
this.callOnBrokenAfterFall(block, blockpos);
this.spawnAtLocation(block);
}
}
} else {
this.discard();
this.callOnBrokenAfterFall(block, blockpos);
}
}
}
}
this.setDeltaMovement(this.getDeltaMovement().scale(0.98D));
}
}
Aggregations