Skip to content

Commit

Permalink
Polish the Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
enjarai committed Mar 1, 2025
1 parent 8198e9f commit b39c801
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.RenderLayers;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.render.block.BlockRenderManager;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.texture.SpriteAtlasTexture;
Expand Down Expand Up @@ -47,7 +45,7 @@ public void render(LevitatingBlockEntity fallingBlockEntity, float f, float tick
matrixStack.push();
matrixStack.translate(0, 0.5, 0);

if (!fallingBlockEntity.isOnGround()) {
if (!fallingBlockEntity.isOnGround() || fallingBlockEntity.onGroundTicks < 2) {
matrixStack.multiply(new Quaternionf().rotateAxis((float) (totalAge / 10 % (Math.PI * 2)), rotationAxis));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.MovementType;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.damage.DamageSources;
import net.minecraft.entity.data.DataTracker;
import net.minecraft.entity.data.TrackedData;
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
Expand All @@ -23,7 +21,6 @@
import net.minecraft.network.packet.s2c.play.BlockUpdateS2CPacket;
import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.server.network.EntityTrackerEntry;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup;
Expand All @@ -46,6 +43,8 @@ public class LevitatingBlockEntity extends Entity {
public BlockEntity cachedBlockEntity;
public boolean shouldRevertNow = false;

public int onGroundTicks = 0;

public LevitatingBlockEntity(EntityType<?> type, World world) {
super(type, world);
}
Expand Down Expand Up @@ -125,6 +124,12 @@ public void tick() {
blockSoundGroup.getVolume(), blockSoundGroup.getPitch(), true // * 0.15F
);
}

if (this.isOnGround()) {
this.onGroundTicks++;
} else {
this.onGroundTicks = 0;
}
}

if (getWeight() != 1.0f && !ModEntityComponents.GRACE.get(this).isInGrace("weight")) {
Expand All @@ -140,7 +145,8 @@ public void tick() {
if (!this.getWorld().isClient()) {
BlockPos blockPos = BlockPos.ofFloored(this.getPos().add(0, 0.49, 0));

if (this.getWeight() >= 1 && (isOnGround() || shouldRevertNow) && getWorld().getBlockState(blockPos).isReplaceable()) {
if (this.getWeight() >= 1 && (isOnGround() || shouldRevertNow) &&
this.getVelocity().lengthSquared() < 0.2 * 0.2 && getWorld().getBlockState(blockPos).isReplaceable()) {
var isWater = getWorld().getFluidState(blockPos).isOf(Fluids.WATER);
var isWaterLoggable = this.blockState.contains(Properties.WATERLOGGED);

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/dev/enjarai/trickster/mixin/EntityMixin.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package dev.enjarai.trickster.mixin;

import dev.enjarai.trickster.cca.ModEntityComponents;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.math.BlockPos;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(Entity.class)
Expand All @@ -21,4 +24,12 @@ private void applyGravityGrace(CallbackInfoReturnable<Double> cir) {
cir.setReturnValue(0.0);
}
}

@Inject(
method = "playStepSounds(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)V",
at = @At("TAIL")
)
private void playCollarJingle(BlockPos pos, BlockState state, CallbackInfo ci) {

}
}

0 comments on commit b39c801

Please sign in to comment.