Skip to content

Commit

Permalink
Better Implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
AViewFromTheTop committed Dec 22, 2024
1 parent 6dd650c commit 42a2f12
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 21 deletions.
59 changes: 38 additions & 21 deletions src/main/java/net/frozenblock/trailiertales/entity/Apparition.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.entity.SpawnGroupData;
import net.minecraft.world.entity.ai.Brain;
Expand Down Expand Up @@ -366,31 +367,16 @@ protected SoundEvent getAmbientSound() {
return TTSounds.APPARITION_DEATH;
}

@Override
protected @NotNull MovementEmission getMovementEmission() {
return MovementEmission.NONE;
}

@Override
public float getSoundVolume() {
return 0.75F;
}

@Override
public boolean onGround() {
return false;
}

@Override
public boolean isInWall() {
return false;
}

@Override
public void tick() {
this.stuckSpeedMultiplier = Vec3.ZERO;
this.fallDistance = 0F;
this.noPhysics = true;
super.tick();
this.noPhysics = false;
this.setNoGravity(true);
if (!this.level().isClientSide) {
this.tickTransparency();
Expand Down Expand Up @@ -419,6 +405,41 @@ public void tick() {
}
}

@Override
public void move(MoverType movementType, Vec3 movement) {
this.level().getProfiler().push("move");
Vec3 vec3 = this.collide(movement);
this.setPos(this.getX() + vec3.x, this.getY() + vec3.y, this.getZ() + vec3.z);

this.level().getProfiler().pop();
this.level().getProfiler().push("rest");
boolean horizontalCollisionX = !Mth.equal(movement.x, vec3.x);
boolean horizontalCollisionZ = !Mth.equal(movement.z, vec3.z);
this.horizontalCollision = horizontalCollisionX || horizontalCollisionZ;
this.verticalCollision = movement.y != vec3.y;
this.verticalCollisionBelow = this.verticalCollision && movement.y < 0D;
if (this.horizontalCollision) {
this.minorHorizontalCollision = this.isHorizontalCollisionMinor(vec3);
} else {
this.minorHorizontalCollision = false;
}

this.setOnGroundWithMovement(this.verticalCollisionBelow, vec3);
if (this.isRemoved()) {
this.level().getProfiler().pop();
} else {
if (this.horizontalCollision) {
Vec3 vec32 = this.getDeltaMovement();
this.setDeltaMovement(horizontalCollisionX ? 0D : vec32.x, vec32.y, horizontalCollisionZ ? 0D : vec32.z);
}
this.tryCheckInsideBlocks();
float h = this.getBlockSpeedFactor();
this.setDeltaMovement(this.getDeltaMovement().multiply(h, 1D, h));

this.level().getProfiler().pop();
}
}

@Contract(" -> new")
private @NotNull ParticleOptions createAmbientParticleOptions() {
float aidProgress = this.getAidAnimProgress();
Expand Down Expand Up @@ -655,10 +676,6 @@ protected void doPush(Entity entity) {
protected void pushEntities() {
}

@Override
public void push(Entity entity) {
}

public void spawnParticles(int count, ParticleOptions particleOptions) {
if (this.level() instanceof ServerLevel level) {
level.sendParticles(
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/trailiertales.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ accessible method net/minecraft/world/entity/projectile/ProjectileUtil getHitRes

# Entity
accessible field net/minecraft/world/level/ClipContext collisionContext Lnet/minecraft/world/phys/shapes/CollisionContext;
accessible method net/minecraft/world/entity/Entity collide (Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;
accessible method net/minecraft/world/entity/LivingEntity makePoofParticles ()V

# Mob Effect
Expand Down

0 comments on commit 42a2f12

Please sign in to comment.