fix antigravel and upward falling blocks
This commit is contained in:
1 parent
ea24b19068
commit
313c54e8d6
8 files changed
+55
-57
No files matched your search
+1
-3
@@ -26,9 +26,7 @@ public class AntigravelBlock extends Block {
|
||||
|
||||
@Override
|
||||
public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor level, BlockPos pos, BlockPos neighborPos) {
|
||||
if (direction == Direction.UP) {
|
||||
level.scheduleTick(pos, this, 2);
|
||||
}
|
||||
level.scheduleTick(pos, this, 2);
|
||||
return super.updateShape(state, direction, neighborState, level, pos, neighborPos);
|
||||
}
|
||||
|
||||
|
||||
+13
-12
@@ -2,7 +2,6 @@ package com.craisinlord.antarchy.content.entity;
|
||||
|
||||
import com.craisinlord.antarchy.content.block.AntimetalScaffoldingBlock;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
@@ -12,6 +11,7 @@ import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.MoverType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
@@ -28,14 +28,16 @@ public class UpwardFallingBlockEntity extends Entity {
|
||||
private static final EntityDataAccessor<BlockState> DATA_BLOCK_STATE =
|
||||
SynchedEntityData.defineId(UpwardFallingBlockEntity.class, EntityDataSerializers.BLOCK_STATE);
|
||||
|
||||
private static final double RISE_SPEED = 0.5;
|
||||
private static final double RISE_ACCEL = 0.04;
|
||||
private static final double DRAG = 0.98;
|
||||
private static final int MAX_TICKS = 200;
|
||||
|
||||
public int time = 0;
|
||||
private double distanceTraveled = 0.0;
|
||||
|
||||
public UpwardFallingBlockEntity(EntityType<UpwardFallingBlockEntity> type, Level level) {
|
||||
super(type, level);
|
||||
this.noPhysics = true;
|
||||
this.blocksBuilding = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,10 +74,11 @@ public class UpwardFallingBlockEntity extends Entity {
|
||||
return;
|
||||
}
|
||||
|
||||
// Move upward directly — noPhysics=true means move() just calls setPos().
|
||||
// Runs on both sides so the client simulates the same deterministic rise
|
||||
// instead of relying on interpolated network updates, matching vanilla FallingBlockEntity.
|
||||
setPos(getX(), getY() + RISE_SPEED, getZ());
|
||||
double beforeY = getY();
|
||||
setDeltaMovement(getDeltaMovement().add(0.0, RISE_ACCEL, 0.0));
|
||||
move(MoverType.SELF, getDeltaMovement());
|
||||
setDeltaMovement(getDeltaMovement().scale(DRAG));
|
||||
distanceTraveled += Math.max(0.0, getY() - beforeY);
|
||||
|
||||
if (level().isClientSide) return;
|
||||
|
||||
@@ -87,7 +90,7 @@ public class UpwardFallingBlockEntity extends Entity {
|
||||
|
||||
damageEntitiesAlongPath(blockState);
|
||||
|
||||
BlockPos headPos = BlockPos.containing(getX(), getY() + getBbHeight(), getZ());
|
||||
BlockPos headPos = BlockPos.containing(getX(), getBoundingBox().maxY, getZ());
|
||||
BlockState above = level().getBlockState(headPos);
|
||||
|
||||
// Leaves block the entity but can't hold scaffolding — drop as item
|
||||
@@ -96,10 +99,9 @@ public class UpwardFallingBlockEntity extends Entity {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean hitCeiling = above.isFaceSturdy(level(), headPos, Direction.DOWN);
|
||||
boolean hitScaffolding = above.getBlock() instanceof AntimetalScaffoldingBlock;
|
||||
|
||||
if (hitCeiling || hitScaffolding) {
|
||||
if (this.verticalCollision || hitScaffolding) {
|
||||
dropAndRemove(blockState);
|
||||
return;
|
||||
}
|
||||
@@ -118,8 +120,7 @@ public class UpwardFallingBlockEntity extends Entity {
|
||||
}
|
||||
|
||||
private float getImpactDamage(BlockState state) {
|
||||
float travelDistance = (float) this.time * (float) RISE_SPEED;
|
||||
float baseDamage = Math.max(0.0F, travelDistance - 1.5F);
|
||||
float baseDamage = Math.max(0.0F, (float) this.distanceTraveled - 1.5F);
|
||||
if (baseDamage <= 0.0F) {
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
+7
-7
@@ -18,7 +18,7 @@ public abstract class MountedVehicleCameraMixin {
|
||||
|
||||
@ModifyArgs(
|
||||
method = "setup",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;move(FFF)V")
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;move(DDD)V")
|
||||
)
|
||||
private void antarchy$adjustMountedCameraOffset(
|
||||
Args args,
|
||||
@@ -34,16 +34,16 @@ public abstract class MountedVehicleCameraMixin {
|
||||
|
||||
Entity vehicle = this.entity.getVehicle();
|
||||
if (vehicle instanceof HerculesBeetleEntity) {
|
||||
args.set(0, (Float) args.get(0) * 1.45F);
|
||||
args.set(1, (Float) args.get(1) + 0.2F);
|
||||
args.set(2, (Float) args.get(2) + 0.45F);
|
||||
args.set(0, (Double) args.get(0) * 1.45D);
|
||||
args.set(1, (Double) args.get(1) + 0.2D);
|
||||
args.set(2, (Double) args.get(2) + 0.45D);
|
||||
return;
|
||||
}
|
||||
|
||||
// if (vehicle instanceof DorrieEntity) {
|
||||
// args.set(0, (Float) args.get(0) * 0.25F);
|
||||
// args.set(1, (Float) args.get(1) + 0.1F);
|
||||
// args.set(2, (Float) args.get(2) + 0.55F);
|
||||
// args.set(0, (Double) args.get(0) * 0.25D);
|
||||
// args.set(1, (Double) args.get(1) + 0.1D);
|
||||
// args.set(2, (Double) args.get(2) + 0.55D);
|
||||
// }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user