Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-04 23:30:24 +01:00
Ursprung
77d702bc9b
Commit
5243c1800e
@ -225,18 +225,32 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
||||
wrapper.passthrough(Types.DOUBLE); // X
|
||||
wrapper.passthrough(Types.DOUBLE); // Y
|
||||
wrapper.passthrough(Types.DOUBLE); // Z
|
||||
wrapper.passthrough(Types.FLOAT); // Offset X
|
||||
wrapper.passthrough(Types.FLOAT); // Offset Y
|
||||
wrapper.passthrough(Types.FLOAT); // Offset Z
|
||||
final float offX = wrapper.passthrough(Types.FLOAT);
|
||||
final float offY = wrapper.passthrough(Types.FLOAT);
|
||||
final float offZ = wrapper.passthrough(Types.FLOAT);
|
||||
final float data = wrapper.passthrough(Types.FLOAT);
|
||||
wrapper.passthrough(Types.INT); // Particle Count
|
||||
final int count = wrapper.passthrough(Types.INT);
|
||||
|
||||
// Read data and add it to Particle
|
||||
final ParticleMappings mappings = protocol.getMappingData().getParticleMappings();
|
||||
final int mappedId = mappings.getNewId(particleId);
|
||||
final Particle particle = new Particle(mappedId);
|
||||
if (mappedId == mappings.mappedId("entity_effect")) {
|
||||
particle.add(Types.INT, data != 0 ? ThreadLocalRandom.current().nextInt() : 0); // rgb
|
||||
final int color;
|
||||
if (data == 0) {
|
||||
// Black
|
||||
color = 0;
|
||||
} else if (count != 0) {
|
||||
// Randomized color
|
||||
color = ThreadLocalRandom.current().nextInt();
|
||||
} else {
|
||||
// From offset
|
||||
final int red = Math.round(offX * 255);
|
||||
final int green = Math.round(offY * 255);
|
||||
final int blue = Math.round(offZ * 255);
|
||||
color = (red << 16) | (green << 8) | blue;
|
||||
}
|
||||
particle.add(Types.INT, EntityPacketRewriter1_20_5.withAlpha(color));
|
||||
} else if (particleId == mappings.id("dust_color_transition")) {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
particle.add(Types.FLOAT, wrapper.read(Types.FLOAT));
|
||||
|
@ -387,7 +387,7 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
||||
}
|
||||
}
|
||||
|
||||
private int withAlpha(final int rgb) {
|
||||
static int withAlpha(final int rgb) {
|
||||
return 255 << 24 | rgb & 0xffffff;
|
||||
}
|
||||
|
||||
|
@ -27,10 +27,10 @@ import java.util.List;
|
||||
|
||||
public final class EfficiencyAttributeStorage implements StorableObject {
|
||||
|
||||
public static final EnchantAttributeModifier EFFICIENCY = new EnchantAttributeModifier("minecraft:enchantment.efficiency/mainhand", 19, 0, level -> (level * level) + 1);
|
||||
public static final EnchantAttributeModifier SOUL_SPEED = new EnchantAttributeModifier("minecraft:enchantment.soul_speed", 21, 0.1, level -> 0.04D + ((level - 1) * 0.01D));
|
||||
public static final EnchantAttributeModifier SWIFT_SNEAK = new EnchantAttributeModifier("minecraft:enchantment.swift_sneak", 25, 0.3, level -> level * 0.15D);
|
||||
public static final EnchantAttributeModifier DEPTH_STRIDER = new EnchantAttributeModifier("minecraft:enchantment.depth_strider", 30, 0, level -> level / 3D);
|
||||
private static final EnchantAttributeModifier EFFICIENCY = new EnchantAttributeModifier("minecraft:enchantment.efficiency/mainhand", 19, 0, level -> (level * level) + 1);
|
||||
private static final EnchantAttributeModifier SOUL_SPEED = new EnchantAttributeModifier("minecraft:enchantment.soul_speed", 21, 0.1, level -> 0.04D + ((level - 1) * 0.01D));
|
||||
private static final EnchantAttributeModifier SWIFT_SNEAK = new EnchantAttributeModifier("minecraft:enchantment.swift_sneak", 25, 0.3, level -> level * 0.15D);
|
||||
private static final EnchantAttributeModifier DEPTH_STRIDER = new EnchantAttributeModifier("minecraft:enchantment.depth_strider", 30, 0, level -> level / 3D);
|
||||
private static final ActiveEnchants DEFAULT = new ActiveEnchants(-1,
|
||||
new ActiveEnchant(EFFICIENCY, 0),
|
||||
new ActiveEnchant(SOUL_SPEED, 0),
|
||||
@ -115,18 +115,7 @@ public final class EfficiencyAttributeStorage implements StorableObject {
|
||||
public record ActiveEnchant(EnchantAttributeModifier modifier, int level) {
|
||||
}
|
||||
|
||||
public static final class EnchantAttributeModifier { // Private constructor, equals by reference
|
||||
private final String key;
|
||||
private final int attributeId;
|
||||
private final double baseValue;
|
||||
private final LevelToModifier modifierFunction;
|
||||
|
||||
private EnchantAttributeModifier(final String key, final int attributeId, final double baseValue, final LevelToModifier modifierFunction) {
|
||||
this.key = key;
|
||||
this.attributeId = attributeId;
|
||||
this.baseValue = baseValue;
|
||||
this.modifierFunction = modifierFunction;
|
||||
}
|
||||
public record EnchantAttributeModifier(String key, int attributeId, double baseValue, LevelToModifier modifierFunction) {
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren