Where are the issues?

- Seats are bouncy again
- Seats can be mounted again
- Fixed increased water fog while wearing Diving helmet
This commit is contained in:
simibubi 2021-11-07 18:37:12 +01:00
parent 55c95b347b
commit 1f0b428e58
4 changed files with 32 additions and 14 deletions

View file

@ -52,7 +52,7 @@ public class AllEntityTypes {
MobCategory.MISC, 4, 20, true, false, PotatoProjectileEntity::build).register(); MobCategory.MISC, 4, 20, true, false, PotatoProjectileEntity::build).register();
public static final EntityEntry<SeatEntity> SEAT = register("seat", SeatEntity::new, () -> SeatEntity.Render::new, public static final EntityEntry<SeatEntity> SEAT = register("seat", SeatEntity::new, () -> SeatEntity.Render::new,
MobCategory.MISC, 0, Integer.MAX_VALUE, false, true, SeatEntity::build).register(); MobCategory.MISC, 5, Integer.MAX_VALUE, false, true, SeatEntity::build).register();
// //

View file

@ -29,6 +29,7 @@ import net.minecraft.world.level.pathfinder.BlockPathTypes;
import net.minecraft.world.level.pathfinder.PathComputationType; import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
@ -60,8 +61,19 @@ public class SeatBlock extends Block {
@Override @Override
public void updateEntityAfterFallOn(BlockGetter reader, Entity entity) { public void updateEntityAfterFallOn(BlockGetter reader, Entity entity) {
BlockPos pos = entity.blockPosition(); BlockPos pos = entity.blockPosition();
if (entity instanceof Player || !(entity instanceof LivingEntity) || !canBePickedUp(entity) || isSeatOccupied(entity.level, pos)) { if (entity instanceof Player || !(entity instanceof LivingEntity) || !canBePickedUp(entity)
super.updateEntityAfterFallOn(reader, entity); || isSeatOccupied(entity.level, pos)) {
if (entity.isSuppressingBounce()) {
super.updateEntityAfterFallOn(reader, entity);
return;
}
Vec3 vec3 = entity.getDeltaMovement();
if (vec3.y < 0.0D) {
double d0 = entity instanceof LivingEntity ? 1.0D : 0.8D;
entity.setDeltaMovement(vec3.x, -vec3.y * (double) 0.66F * d0, vec3.z);
}
return; return;
} }
if (reader.getBlockState(pos) if (reader.getBlockState(pos)
@ -71,8 +83,7 @@ public class SeatBlock extends Block {
} }
@Override @Override
public BlockPathTypes getAiPathNodeType(BlockState state, BlockGetter world, BlockPos pos, public BlockPathTypes getAiPathNodeType(BlockState state, BlockGetter world, BlockPos pos, @Nullable Mob entity) {
@Nullable Mob entity) {
return BlockPathTypes.RAIL; return BlockPathTypes.RAIL;
} }
@ -99,7 +110,8 @@ public class SeatBlock extends Block {
if (color != null && color != this.color) { if (color != null && color != this.color) {
if (world.isClientSide) if (world.isClientSide)
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
BlockState newState = BlockHelper.copyProperties(state, AllBlocks.SEATS.get(color).getDefaultState()); BlockState newState = BlockHelper.copyProperties(state, AllBlocks.SEATS.get(color)
.getDefaultState());
world.setBlockAndUpdate(pos, newState); world.setBlockAndUpdate(pos, newState);
return InteractionResult.sidedSuccess(world.isClientSide); return InteractionResult.sidedSuccess(world.isClientSide);
} }
@ -136,7 +148,7 @@ public class SeatBlock extends Block {
if (world.isClientSide) if (world.isClientSide)
return; return;
SeatEntity seat = new SeatEntity(world, pos); SeatEntity seat = new SeatEntity(world, pos);
seat.setPosRaw(pos.getX() + .5f, pos.getY(), pos.getZ() + .5f); seat.setPos(pos.getX() + .5f, pos.getY(), pos.getZ() + .5f);
world.addFreshEntity(seat); world.addFreshEntity(seat);
entity.startRiding(seat, true); entity.startRiding(seat, true);
} }

View file

@ -12,6 +12,7 @@ import net.minecraft.network.protocol.Packet;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
@ -35,7 +36,7 @@ public class SeatEntity extends Entity implements IEntityAdditionalSpawnData {
EntityType.Builder<SeatEntity> entityBuilder = (EntityType.Builder<SeatEntity>) builder; EntityType.Builder<SeatEntity> entityBuilder = (EntityType.Builder<SeatEntity>) builder;
return entityBuilder.sized(0.25f, 0.35f); return entityBuilder.sized(0.25f, 0.35f);
} }
@Override @Override
public void setPos(double x, double y, double z) { public void setPos(double x, double y, double z) {
super.setPos(x, y, z); super.setPos(x, y, z);
@ -49,7 +50,7 @@ public class SeatEntity extends Entity implements IEntityAdditionalSpawnData {
@Override @Override
public void tick() { public void tick() {
if (level.isClientSide) if (level.isClientSide)
return; return;
boolean blockPresent = level.getBlockState(blockPosition()) boolean blockPresent = level.getBlockState(blockPosition())
.getBlock() instanceof SeatBlock; .getBlock() instanceof SeatBlock;
@ -60,15 +61,19 @@ public class SeatEntity extends Entity implements IEntityAdditionalSpawnData {
@Override @Override
protected boolean canRide(Entity entity) { protected boolean canRide(Entity entity) {
// Fake Players (tested with deployers) have a BUNCH of weird issues, don't let them ride seats // Fake Players (tested with deployers) have a BUNCH of weird issues, don't let
// them ride seats
return !(entity instanceof FakePlayer); return !(entity instanceof FakePlayer);
} }
@Override @Override
protected void removePassenger(Entity entity) { protected void removePassenger(Entity entity) {
super.removePassenger(entity); super.removePassenger(entity);
Vec3 pos = entity.position(); }
entity.setPos(pos.x, pos.y + 0.85f, pos.z);
@Override
public Vec3 getDismountLocationForPassenger(LivingEntity pLivingEntity) {
return super.getDismountLocationForPassenger(pLivingEntity).add(0, 0.5f, 0);
} }
@Override @Override
@ -92,7 +97,8 @@ public class SeatEntity extends Entity implements IEntityAdditionalSpawnData {
} }
@Override @Override
public boolean shouldRender(SeatEntity p_225626_1_, Frustum p_225626_2_, double p_225626_3_, double p_225626_5_, double p_225626_7_) { public boolean shouldRender(SeatEntity p_225626_1_, Frustum p_225626_2_, double p_225626_3_, double p_225626_5_,
double p_225626_7_) {
return false; return false;
} }

View file

@ -303,7 +303,7 @@ public class ClientEvents {
if (FluidHelper.isWater(fluid) && AllItems.DIVING_HELMET.get() if (FluidHelper.isWater(fluid) && AllItems.DIVING_HELMET.get()
.isWornBy(Minecraft.getInstance().cameraEntity)) { .isWornBy(Minecraft.getInstance().cameraEntity)) {
event.setDensity(0.010f); event.setDensity(300f);
event.setCanceled(true); event.setCanceled(true);
return; return;
} }