fix effects meta not working on versions 1.8-1.10 because of duplicate data indexes due to incorrect implementation of the "using_item" property on those versions
This commit is contained in:
parent
06c5397bd8
commit
46d848b823
9 changed files with 45 additions and 12 deletions
|
@ -19,7 +19,7 @@ import net.kyori.adventure.text.Component;
|
||||||
*/
|
*/
|
||||||
public interface MetadataFactory {
|
public interface MetadataFactory {
|
||||||
EntityData skinLayers(boolean cape, boolean jacket, boolean leftSleeve, boolean rightSleeve, boolean leftLeg, boolean rightLeg, boolean hat);
|
EntityData skinLayers(boolean cape, boolean jacket, boolean leftSleeve, boolean rightSleeve, boolean leftLeg, boolean rightLeg, boolean hat);
|
||||||
EntityData effects(boolean onFire, boolean glowing, boolean invisible, boolean usingElytra);
|
EntityData effects(boolean onFire, boolean glowing, boolean invisible, boolean usingElytra, boolean usingItemLegacy);
|
||||||
EntityData silent(boolean enabled);
|
EntityData silent(boolean enabled);
|
||||||
EntityData name(Component name);
|
EntityData name(Component name);
|
||||||
EntityData nameShown();
|
EntityData nameShown();
|
||||||
|
|
|
@ -4,6 +4,11 @@ import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
|
||||||
public class V1_11MetadataFactory extends V1_10MetadataFactory {
|
public class V1_11MetadataFactory extends V1_10MetadataFactory {
|
||||||
|
@Override
|
||||||
|
public EntityData effects(boolean onFire, boolean glowing, boolean invisible, boolean usingElytra, boolean usingItemLegacy) {
|
||||||
|
return super.effects(onFire, glowing, invisible, usingElytra, false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityData usingItem(boolean usingItem, boolean offHand, boolean riptide) {
|
public EntityData usingItem(boolean usingItem, boolean offHand, boolean riptide) {
|
||||||
return newEntityData(6, EntityDataTypes.BYTE, (byte) ((usingItem ? 0x01 : 0) | (offHand ? 0x02 : 0)));
|
return newEntityData(6, EntityDataTypes.BYTE, (byte) ((usingItem ? 0x01 : 0) | (offHand ? 0x02 : 0)));
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class V1_17MetadataFactory extends V1_16MetadataFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityData effects(boolean onFire, boolean glowing, boolean invisible, boolean usingElytra) {
|
public EntityData effects(boolean onFire, boolean glowing, boolean invisible, boolean usingElytra, boolean usingItemLegacy) {
|
||||||
return newEntityData(0, EntityDataTypes.BYTE, (byte) ((onFire ? 0x01 : 0) | (invisible ? 0x20 : 0) | (glowing ? 0x40 : 0) | (usingElytra ? 0x80 : 0)));
|
return newEntityData(0, EntityDataTypes.BYTE, (byte) ((onFire ? 0x01 : 0) | (invisible ? 0x20 : 0) | (glowing ? 0x40 : 0) | (usingElytra ? 0x80 : 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@ public class V1_8MetadataFactory implements MetadataFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityData effects(boolean onFire, boolean glowing, boolean invisible, boolean usingElytra) {
|
public EntityData effects(boolean onFire, boolean glowing, boolean invisible, boolean usingElytra, boolean usingItemLegacy) {
|
||||||
return newEntityData(0, EntityDataTypes.BYTE, (byte) ((onFire ? 0x01 : 0) | (invisible ? 0x20 : 0)));
|
return newEntityData(0, EntityDataTypes.BYTE, (byte) ((onFire ? 0x01 : 0) | (usingItemLegacy ? 0x10 : 0) | (invisible ? 0x20 : 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,7 +45,7 @@ public class V1_8MetadataFactory implements MetadataFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityData usingItem(boolean enabled, boolean offHand, boolean riptide) {
|
public EntityData usingItem(boolean enabled, boolean offHand, boolean riptide) {
|
||||||
return newEntityData(0, EntityDataTypes.BYTE, (byte) (enabled ? 0x10 : 0));
|
throw new UnsupportedOperationException("The standalone using item data isn't supported on this version");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -12,8 +12,8 @@ public class V1_9MetadataFactory extends V1_8MetadataFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityData effects(boolean onFire, boolean glowing, boolean invisible, boolean usingElytra) {
|
public EntityData effects(boolean onFire, boolean glowing, boolean invisible, boolean usingElytra, boolean usingItemLegacy) {
|
||||||
return newEntityData(0, EntityDataTypes.BYTE, (byte) ((onFire ? 0x01 : 0) | (invisible ? 0x20 : 0) | (glowing ? 0x40 : 0) | (usingElytra ? 0x80 : 0)));
|
return newEntityData(0, EntityDataTypes.BYTE, (byte) ((onFire ? 0x01 : 0) | (usingItemLegacy ? 0x10 : 0) | (invisible ? 0x20 : 0) | (glowing ? 0x40 : 0) | (usingElytra ? 0x80 : 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package lol.pyr.znpcsplus.packets;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.PacketEventsAPI;
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||||
|
import lol.pyr.znpcsplus.api.entity.PropertyHolder;
|
||||||
|
import lol.pyr.znpcsplus.entity.EntityPropertyRegistryImpl;
|
||||||
|
import lol.pyr.znpcsplus.entity.PacketEntity;
|
||||||
|
import lol.pyr.znpcsplus.metadata.MetadataFactory;
|
||||||
|
import lol.pyr.znpcsplus.scheduling.TaskScheduler;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class V1_11PacketFactory extends V1_10PacketFactory {
|
||||||
|
public V1_11PacketFactory(TaskScheduler scheduler, MetadataFactory metadataFactory, PacketEventsAPI<Plugin> packetEvents, EntityPropertyRegistryImpl propertyRegistry) {
|
||||||
|
super(scheduler, metadataFactory, packetEvents, propertyRegistry);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Integer, EntityData> generateMetadata(Player player, PacketEntity entity, PropertyHolder properties) {
|
||||||
|
Map<Integer, EntityData> data = super.generateMetadata(player, entity, properties);
|
||||||
|
add(data, metadataFactory.usingItem(properties.getProperty(propertyRegistry.getByName("using_item", Boolean.class)), false, false));
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,7 +18,7 @@ import org.bukkit.plugin.Plugin;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class V1_14PacketFactory extends V1_10PacketFactory {
|
public class V1_14PacketFactory extends V1_11PacketFactory {
|
||||||
public V1_14PacketFactory(TaskScheduler scheduler, MetadataFactory metadataFactory, PacketEventsAPI<Plugin> packetEvents, EntityPropertyRegistryImpl propertyRegistry) {
|
public V1_14PacketFactory(TaskScheduler scheduler, MetadataFactory metadataFactory, PacketEventsAPI<Plugin> packetEvents, EntityPropertyRegistryImpl propertyRegistry) {
|
||||||
super(scheduler, metadataFactory, packetEvents, propertyRegistry);
|
super(scheduler, metadataFactory, packetEvents, propertyRegistry);
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,10 +139,10 @@ public class V1_8PacketFactory implements PacketFactory {
|
||||||
properties.getProperty(propertyRegistry.getByName("fire", Boolean.class)),
|
properties.getProperty(propertyRegistry.getByName("fire", Boolean.class)),
|
||||||
false,
|
false,
|
||||||
properties.getProperty(propertyRegistry.getByName("invisible", Boolean.class)),
|
properties.getProperty(propertyRegistry.getByName("invisible", Boolean.class)),
|
||||||
false)
|
false,
|
||||||
);
|
properties.getProperty(propertyRegistry.getByName("using_item", Boolean.class))
|
||||||
|
));
|
||||||
add(data, metadataFactory.silent(properties.getProperty(propertyRegistry.getByName("silent", Boolean.class))));
|
add(data, metadataFactory.silent(properties.getProperty(propertyRegistry.getByName("silent", Boolean.class))));
|
||||||
add(data, metadataFactory.usingItem(properties.getProperty(propertyRegistry.getByName("using_item", Boolean.class)), false, false));
|
|
||||||
add(data, metadataFactory.potionColor(properties.getProperty(propertyRegistry.getByName("potion_color", Color.class)).asRGB()));
|
add(data, metadataFactory.potionColor(properties.getProperty(propertyRegistry.getByName("potion_color", Color.class)).asRGB()));
|
||||||
add(data, metadataFactory.potionAmbient(properties.getProperty(propertyRegistry.getByName("potion_ambient", Boolean.class))));
|
add(data, metadataFactory.potionAmbient(properties.getProperty(propertyRegistry.getByName("potion_ambient", Boolean.class))));
|
||||||
if (properties.hasProperty(propertyRegistry.getByName("name"))) {
|
if (properties.hasProperty(propertyRegistry.getByName("name"))) {
|
||||||
|
|
|
@ -23,7 +23,9 @@ public class V1_9PacketFactory extends V1_8PacketFactory {
|
||||||
add(data, metadataFactory.effects(properties.getProperty(propertyRegistry.getByName("fire", Boolean.class)),
|
add(data, metadataFactory.effects(properties.getProperty(propertyRegistry.getByName("fire", Boolean.class)),
|
||||||
properties.hasProperty(propertyRegistry.getByName("glow", Boolean.class)),
|
properties.hasProperty(propertyRegistry.getByName("glow", Boolean.class)),
|
||||||
properties.getProperty(propertyRegistry.getByName("invisible", Boolean.class)),
|
properties.getProperty(propertyRegistry.getByName("invisible", Boolean.class)),
|
||||||
false));
|
false,
|
||||||
|
properties.getProperty(propertyRegistry.getByName("using_item", Boolean.class))
|
||||||
|
));
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue