New attribute field names, more fixes

This commit is contained in:
FlorianMichael 2024-10-25 01:51:57 +02:00
parent 6ef7bbb22a
commit 02136f09a9
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
5 changed files with 22 additions and 23 deletions

View File

@ -60,13 +60,13 @@ public class EnchantmentAttributesEmulation1_20_6 {
}
final int efficiencyLevel = getEquipmentLevel(Enchantments.EFFICIENCY, player);
if (efficiencyLevel > 0) {
player.getAttributeInstance(EntityAttributes.PLAYER_MINING_EFFICIENCY).setBaseValue(efficiencyLevel * efficiencyLevel + 1);
player.getAttributeInstance(EntityAttributes.MINING_EFFICIENCY).setBaseValue(efficiencyLevel * efficiencyLevel + 1);
} else {
player.getAttributeInstance(EntityAttributes.PLAYER_MINING_EFFICIENCY).setBaseValue(0);
player.getAttributeInstance(EntityAttributes.MINING_EFFICIENCY).setBaseValue(0);
}
player.getAttributeInstance(EntityAttributes.PLAYER_SNEAKING_SPEED).setBaseValue(0.3F + getEquipmentLevel(Enchantments.SWIFT_SNEAK, player) * 0.15F);
player.getAttributeInstance(EntityAttributes.PLAYER_SUBMERGED_MINING_SPEED).setBaseValue(getEquipmentLevel(Enchantments.AQUA_AFFINITY, player) <= 0 ? 0.2F : 1F);
player.getAttributeInstance(EntityAttributes.SNEAKING_SPEED).setBaseValue(0.3F + getEquipmentLevel(Enchantments.SWIFT_SNEAK, player) * 0.15F);
player.getAttributeInstance(EntityAttributes.SUBMERGED_MINING_SPEED).setBaseValue(getEquipmentLevel(Enchantments.AQUA_AFFINITY, player) <= 0 ? 0.2F : 1F);
}
});
}
@ -82,14 +82,14 @@ public class EnchantmentAttributesEmulation1_20_6 {
public static void setGenericMovementEfficiencyAttribute(final LivingEntity entity) {
final boolean isOnSoulSpeedBlock = entity.getWorld().getBlockState(entity.getVelocityAffectingPos()).isIn(BlockTags.SOUL_SPEED_BLOCKS);
if (isOnSoulSpeedBlock && getEquipmentLevel(Enchantments.SOUL_SPEED, entity) > 0) {
entity.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_EFFICIENCY).setBaseValue(1);
entity.getAttributeInstance(EntityAttributes.MOVEMENT_EFFICIENCY).setBaseValue(1);
} else {
entity.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_EFFICIENCY).setBaseValue(0);
entity.getAttributeInstance(EntityAttributes.MOVEMENT_EFFICIENCY).setBaseValue(0);
}
}
private static int getEquipmentLevel(final RegistryKey<Enchantment> enchantment, final LivingEntity entity) {
final Optional<RegistryEntry.Reference<Enchantment>> enchantmentRef = entity.getWorld().getRegistryManager().getWrapperOrThrow(RegistryKeys.ENCHANTMENT).getOptional(enchantment);
final Optional<RegistryEntry.Reference<Enchantment>> enchantmentRef = entity.getWorld().getRegistryManager().getOrThrow(RegistryKeys.ENCHANTMENT).getOptional(enchantment);
return enchantmentRef.map(e -> EnchantmentHelper.getEquipmentLevel(e, entity)).orElse(0);
}

View File

@ -30,9 +30,7 @@ import net.minecraft.entity.decoration.ArmorStandEntity;
import net.minecraft.entity.mob.*;
import net.minecraft.entity.passive.*;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.vehicle.AbstractMinecartEntity;
import net.minecraft.entity.vehicle.BoatEntity;
import net.minecraft.entity.vehicle.ChestBoatEntity;
import net.minecraft.entity.vehicle.*;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
@ -52,25 +50,25 @@ public class EntityRidingOffsetsPre1_20_2 {
public static Vec3d getMountedHeightOffset(final Entity entity, final Entity passenger) {
double yOffset = entity.getHeight() * 0.75F;
if (entity instanceof BoatEntity boatEntity) {
if (!boatEntity.hasPassenger(passenger)) return Vec3d.ZERO;
if (entity instanceof AbstractBoatEntity abstractBoatEntity) {
if (!abstractBoatEntity.hasPassenger(passenger)) return Vec3d.ZERO;
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
yOffset = -0.3F;
final double xOffset = MathHelper.cos(boatEntity.getYaw() * MathHelper.PI / 180F);
final double zOffset = MathHelper.sin(boatEntity.getYaw() * MathHelper.PI / 180F);
final double xOffset = MathHelper.cos(abstractBoatEntity.getYaw() * MathHelper.PI / 180F);
final double zOffset = MathHelper.sin(abstractBoatEntity.getYaw() * MathHelper.PI / 180F);
return new Vec3d(0.4F * xOffset, yOffset, 0.4F * zOffset);
} else {
if (boatEntity.isRemoved()) {
if (abstractBoatEntity.isRemoved()) {
yOffset = 0.01F;
} else {
yOffset = boatEntity.getVariant() == BoatEntity.Type.BAMBOO ? 0.25F : -0.1F;
yOffset = abstractBoatEntity.getType() == EntityType.BAMBOO_RAFT || abstractBoatEntity.getType() == EntityType.BAMBOO_CHEST_RAFT ? 0.25F : -0.1F;
}
double xOffset = boatEntity instanceof ChestBoatEntity ? 0.15F : 0F;
if (boatEntity.getPassengerList().size() > 1) {
final int idx = boatEntity.getPassengerList().indexOf(passenger);
double xOffset = abstractBoatEntity instanceof AbstractChestBoatEntity ? 0.15F : 0F;
if (abstractBoatEntity.getPassengerList().size() > 1) {
final int idx = abstractBoatEntity.getPassengerList().indexOf(passenger);
if (idx == 0) {
xOffset = 0.2F;
} else {

View File

@ -107,9 +107,9 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_19_3) && instance.hasVehicle();
}
@Redirect(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isFallFlying()Z"))
private boolean removeFallFlyingCheck(ClientPlayerEntity instance) {
return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_19_3) && instance.isFallFlying();
@Redirect(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isGliding()Z"))
private boolean removeGlidingCheck(ClientPlayerEntity instance) {
return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_19_3) && instance.isGliding();
}
@Redirect(method = "canSprint", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z"))

View File

@ -46,7 +46,7 @@ public class VisualSettings extends SettingGroup {
final MinecraftClient client = MinecraftClient.getInstance();
if (client != null) {
for (FontStorage storage : client.fontManager.fontStorages.values()) {
storage.glyphRendererCache.clear();
storage.bakedGlyphCache.clear();
storage.glyphCache.clear();
}
}

View File

@ -9,6 +9,7 @@ accessible field net/minecraft/client/font/FontStorage$GlyphPair MISSING Lnet/mi
accessible field net/minecraft/network/ClientConnection packetSizeLogger Lnet/minecraft/network/handler/PacketSizeLogger;
accessible field net/minecraft/entity/boss/dragon/EnderDragonEntity body Lnet/minecraft/entity/boss/dragon/EnderDragonPart;
accessible field net/minecraft/entity/passive/AbstractHorseEntity lastAngryAnimationProgress F
accessible field net/minecraft/client/font/FontStorage bakedGlyphCache Lnet/minecraft/client/font/GlyphContainer;
accessible field net/minecraft/entity/vehicle/AbstractBoatEntity yawVelocity F
accessible field net/minecraft/client/font/FontStorage glyphCache Lnet/minecraft/client/font/GlyphContainer;
accessible field net/minecraft/entity/EntityType dimensions Lnet/minecraft/entity/EntityDimensions;