add fire & glow property and links for wikis
This commit is contained in:
parent
e7687959df
commit
ffc4bd9d8f
5 changed files with 34 additions and 2 deletions
|
@ -30,6 +30,7 @@ import lol.pyr.znpcsplus.tasks.NPCVisibilityTask;
|
|||
import lol.pyr.znpcsplus.updater.UpdateChecker;
|
||||
import lol.pyr.znpcsplus.updater.UpdateNotificationListener;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -139,7 +140,11 @@ public class ZNPCsPlus extends JavaPlugin {
|
|||
if (world == null) world = Bukkit.getWorlds().get(0);
|
||||
for (NPCType type : NPCType.values()) {
|
||||
NPC npc = new NPC(world, type, new PacketLocation(x * 3, 200, z * 3, 0, 0));
|
||||
if (type.getType() == EntityTypes.PLAYER) NPCSkin.forName("Pyrbu", (skin, ex) -> npc.setProperty(NPCProperty.SKIN, skin));
|
||||
if (type.getType() == EntityTypes.PLAYER) {
|
||||
npc.setProperty(NPCProperty.GLOW, NamedTextColor.RED);
|
||||
npc.setProperty(NPCProperty.FIRE, true);
|
||||
NPCSkin.forName("Notch", (skin, ex) -> npc.setProperty(NPCProperty.SKIN, skin));
|
||||
}
|
||||
NPCRegistry.register("debug_npc" + (z * wrap + x), npc);
|
||||
if (x++ > wrap) {
|
||||
x = 0;
|
||||
|
|
|
@ -8,8 +8,23 @@ import lol.pyr.znpcsplus.util.LazyLoader;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 1.8 https://wiki.vg/index.php?title=Entity_metadata&oldid=7415
|
||||
* 1.9 https://wiki.vg/index.php?title=Entity_metadata&oldid=7968
|
||||
* 1.10 https://wiki.vg/index.php?title=Entity_metadata&oldid=8241
|
||||
* 1.11 https://wiki.vg/index.php?title=Entity_metadata&oldid=8534
|
||||
* 1.12 https://wiki.vg/index.php?title=Entity_metadata&oldid=14048
|
||||
* 1.13 https://wiki.vg/index.php?title=Entity_metadata&oldid=14800
|
||||
* 1.14 https://wiki.vg/index.php?title=Entity_metadata&oldid=15240
|
||||
* 1.15 https://wiki.vg/index.php?title=Entity_metadata&oldid=15991
|
||||
* 1.16 https://wiki.vg/index.php?title=Entity_metadata&oldid=16539
|
||||
* 1.17 https://wiki.vg/index.php?title=Entity_metadata&oldid=17521
|
||||
* 1.18 NOTHING CHANGED
|
||||
* 1.19 https://wiki.vg/index.php?title=Entity_metadata
|
||||
*/
|
||||
public interface MetadataFactory {
|
||||
EntityData skinLayers();
|
||||
EntityData effects(boolean onFire, boolean glowing);
|
||||
|
||||
MetadataFactory factory = get();
|
||||
|
||||
|
|
|
@ -9,6 +9,11 @@ public class V1_8Factory implements MetadataFactory {
|
|||
return createSkinLayers(12);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData effects(boolean onFire, boolean glowing) {
|
||||
return new EntityData(0, EntityDataTypes.BYTE, (byte) ((onFire ? 0x01 : 0) | (glowing ? 0x40 : 0)));
|
||||
}
|
||||
|
||||
protected EntityData createSkinLayers(int index) {
|
||||
return new EntityData(index, EntityDataTypes.BYTE, Byte.MAX_VALUE);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package lol.pyr.znpcsplus.npc;
|
||||
|
||||
import io.github.znetworkw.znpcservers.npc.NPCSkin;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -35,4 +36,6 @@ public class NPCProperty<T> {
|
|||
|
||||
public static NPCProperty<Boolean> SKIN_LAYERS = new NPCProperty<>("skin_layers", true);
|
||||
public static NPCProperty<NPCSkin> SKIN = new NPCProperty<>("skin");
|
||||
public static NPCProperty<NamedTextColor> GLOW = new NPCProperty<>("glow");
|
||||
public static NPCProperty<Boolean> FIRE = new NPCProperty<>("fire", false);
|
||||
}
|
|
@ -35,6 +35,9 @@ public class V1_8Factory implements PacketFactory {
|
|||
sendPacket(player, new WrapperPlayServerSpawnPlayer(entity.getEntityId(),
|
||||
entity.getUuid(), location.toVector3d(), location.getYaw(), location.getPitch(), List.of()));
|
||||
if (owner.getProperty(NPCProperty.SKIN_LAYERS)) sendMetadata(player, entity, MetadataFactory.get().skinLayers());
|
||||
boolean glow = owner.hasProperty(NPCProperty.GLOW);
|
||||
boolean fire = owner.getProperty(NPCProperty.FIRE);
|
||||
if (glow || fire) sendMetadata(player, entity, MetadataFactory.get().effects(fire, glow));
|
||||
ZNPCsPlus.SCHEDULER.scheduleSyncDelayedTask(() -> removeTabPlayer(player, entity), 60);
|
||||
}
|
||||
|
||||
|
@ -81,11 +84,12 @@ public class V1_8Factory implements PacketFactory {
|
|||
|
||||
@Override
|
||||
public void createTeam(Player player, PacketEntity entity) {
|
||||
NPC owner = entity.getOwner();
|
||||
sendPacket(player, new WrapperPlayServerTeams("npc_team_" + entity.getEntityId(), WrapperPlayServerTeams.TeamMode.CREATE, new WrapperPlayServerTeams.ScoreBoardTeamInfo(
|
||||
Component.empty(), Component.empty(), Component.empty(),
|
||||
WrapperPlayServerTeams.NameTagVisibility.NEVER,
|
||||
WrapperPlayServerTeams.CollisionRule.NEVER,
|
||||
NamedTextColor.WHITE,
|
||||
owner.hasProperty(NPCProperty.GLOW) ? owner.getProperty(NPCProperty.GLOW) : NamedTextColor.WHITE,
|
||||
WrapperPlayServerTeams.OptionData.NONE
|
||||
)));
|
||||
sendPacket(player, new WrapperPlayServerTeams("npc_team_" + entity.getEntityId(), WrapperPlayServerTeams.TeamMode.ADD_ENTITIES, (WrapperPlayServerTeams.ScoreBoardTeamInfo) null, Integer.toString(entity.getEntityId())));
|
||||
|
|
Loading…
Reference in a new issue