mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
fancynpcs: Add harness attribute for happy ghasts
This commit is contained in:
@@ -2,6 +2,5 @@ fancylibVersion=37
|
|||||||
fancysitulaVersion=0.0.13
|
fancysitulaVersion=0.0.13
|
||||||
jdbVersion=1.0.0
|
jdbVersion=1.0.0
|
||||||
plugintestsVersion=1.0.0
|
plugintestsVersion=1.0.0
|
||||||
|
org.gradle.parallel=false
|
||||||
org.gradle.parallel=true
|
|
||||||
org.gradle.caching=true
|
org.gradle.caching=true
|
||||||
@@ -1 +1 @@
|
|||||||
2.6.0.283
|
2.6.0.284
|
||||||
@@ -267,13 +267,25 @@ public class Npc_1_21_6 extends Npc {
|
|||||||
|
|
||||||
npc.setGlowingTag(data.isGlowing());
|
npc.setGlowingTag(data.isGlowing());
|
||||||
|
|
||||||
if (data.getEquipment() != null && data.getEquipment().size() > 0) {
|
data.applyAllAttributes(this);
|
||||||
List<Pair<EquipmentSlot, ItemStack>> equipmentList = new ArrayList<>();
|
|
||||||
|
|
||||||
|
// Set equipment
|
||||||
|
List<Pair<EquipmentSlot, ItemStack>> equipmentList = new ArrayList<>();
|
||||||
|
if (data.getEquipment() != null) {
|
||||||
for (NpcEquipmentSlot slot : data.getEquipment().keySet()) {
|
for (NpcEquipmentSlot slot : data.getEquipment().keySet()) {
|
||||||
equipmentList.add(new Pair<>(EquipmentSlot.byName(slot.toNmsName()), CraftItemStack.asNMSCopy(data.getEquipment().get(slot))));
|
equipmentList.add(new Pair<>(EquipmentSlot.byName(slot.toNmsName()), CraftItemStack.asNMSCopy(data.getEquipment().get(slot))));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set body slot (from happy ghast harness attribute)
|
||||||
|
if (npc instanceof LivingEntity livingEntity) {
|
||||||
|
ItemStack bodySlot = livingEntity.getItemBySlot(EquipmentSlot.BODY);
|
||||||
|
if (!bodySlot.isEmpty()) {
|
||||||
|
equipmentList.add(new Pair<>(EquipmentSlot.BODY, bodySlot));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!equipmentList.isEmpty()) {
|
||||||
ClientboundSetEquipmentPacket setEquipmentPacket = new ClientboundSetEquipmentPacket(npc.getId(), equipmentList);
|
ClientboundSetEquipmentPacket setEquipmentPacket = new ClientboundSetEquipmentPacket(npc.getId(), equipmentList);
|
||||||
serverPlayer.connection.send(setEquipmentPacket);
|
serverPlayer.connection.send(setEquipmentPacket);
|
||||||
}
|
}
|
||||||
@@ -283,8 +295,6 @@ public class Npc_1_21_6 extends Npc {
|
|||||||
npc.getEntityData().set(net.minecraft.world.entity.player.Player.DATA_PLAYER_MODE_CUSTOMISATION, (byte) (0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40));
|
npc.getEntityData().set(net.minecraft.world.entity.player.Player.DATA_PLAYER_MODE_CUSTOMISATION, (byte) (0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40));
|
||||||
}
|
}
|
||||||
|
|
||||||
data.applyAllAttributes(this);
|
|
||||||
|
|
||||||
refreshEntityData(player);
|
refreshEntityData(player);
|
||||||
|
|
||||||
if (data.isSpawnEntity() && data.getLocation() != null) {
|
if (data.isSpawnEntity() && data.getLocation() != null) {
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public class Attributes_1_21_6 {
|
|||||||
attributes.addAll(BeeAttributes.getAllAttributes());
|
attributes.addAll(BeeAttributes.getAllAttributes());
|
||||||
attributes.addAll(VexAttributes.getAllAttributes());
|
attributes.addAll(VexAttributes.getAllAttributes());
|
||||||
attributes.addAll(ArmadilloAttributes.getAllAttributes());
|
attributes.addAll(ArmadilloAttributes.getAllAttributes());
|
||||||
|
attributes.addAll(HappyGhastAttributes.getAllAttributes());
|
||||||
|
|
||||||
attributes.addAll(DisplayAttributes.getAllAttributes());
|
attributes.addAll(DisplayAttributes.getAllAttributes());
|
||||||
attributes.addAll(TextDisplayAttributes.getAllAttributes());
|
attributes.addAll(TextDisplayAttributes.getAllAttributes());
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package de.oliver.fancynpcs.v1_21_6.attributes;
|
||||||
|
|
||||||
|
import de.oliver.fancynpcs.api.Npc;
|
||||||
|
import de.oliver.fancynpcs.api.NpcAttribute;
|
||||||
|
import de.oliver.fancynpcs.v1_21_6.ReflectionHelper;
|
||||||
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
|
import net.minecraft.world.entity.animal.HappyGhast;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.Items;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class HappyGhastAttributes {
|
||||||
|
|
||||||
|
public static List<NpcAttribute> getAllAttributes() {
|
||||||
|
List<NpcAttribute> attributes = new ArrayList<>();
|
||||||
|
|
||||||
|
attributes.add(new NpcAttribute(
|
||||||
|
"harness",
|
||||||
|
List.of("white", "orange", "magenta", "light_blue", "yellow", "lime", "pink", "gray", "light_gray", "cyan", "purple", "blue", "brown", "green", "red", "black"),
|
||||||
|
List.of(EntityType.HAPPY_GHAST),
|
||||||
|
HappyGhastAttributes::setHarness
|
||||||
|
));
|
||||||
|
|
||||||
|
return attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setHarness(Npc npc, String value) {
|
||||||
|
HappyGhast ghast = ReflectionHelper.getEntity(npc);
|
||||||
|
|
||||||
|
ItemStack harnessItem = switch (value.toLowerCase()) {
|
||||||
|
case "white" -> Items.WHITE_HARNESS.getDefaultInstance();
|
||||||
|
case "orange" -> Items.ORANGE_HARNESS.getDefaultInstance();
|
||||||
|
case "magenta" -> Items.MAGENTA_HARNESS.getDefaultInstance();
|
||||||
|
case "light_blue" -> Items.LIGHT_BLUE_HARNESS.getDefaultInstance();
|
||||||
|
case "yellow" -> Items.YELLOW_HARNESS.getDefaultInstance();
|
||||||
|
case "lime" -> Items.LIME_HARNESS.getDefaultInstance();
|
||||||
|
case "pink" -> Items.PINK_HARNESS.getDefaultInstance();
|
||||||
|
case "gray" -> Items.GRAY_HARNESS.getDefaultInstance();
|
||||||
|
case "light_gray" -> Items.LIGHT_GRAY_HARNESS.getDefaultInstance();
|
||||||
|
case "cyan" -> Items.CYAN_HARNESS.getDefaultInstance();
|
||||||
|
case "purple" -> Items.PURPLE_HARNESS.getDefaultInstance();
|
||||||
|
case "blue" -> Items.BLUE_HARNESS.getDefaultInstance();
|
||||||
|
case "brown" -> Items.BROWN_HARNESS.getDefaultInstance();
|
||||||
|
case "green" -> Items.GREEN_HARNESS.getDefaultInstance();
|
||||||
|
case "red" -> Items.RED_HARNESS.getDefaultInstance();
|
||||||
|
case "black" -> Items.BLACK_HARNESS.getDefaultInstance();
|
||||||
|
default -> Items.AIR.getDefaultInstance();
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!harnessItem.isEmpty()) {
|
||||||
|
ghast.setItemSlot(EquipmentSlot.BODY, harnessItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user