i think that's all the metadata
This commit is contained in:
parent
0d709013e2
commit
0ace331ef3
102 changed files with 2970 additions and 51 deletions
|
@ -9,6 +9,7 @@
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/test-plugin" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
|
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -36,6 +36,6 @@ allprojects {
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("com.github.retrooper.packetevents:spigot:2.0.2")
|
compileOnlyApi("com.github.retrooper.packetevents:spigot:2.0.2")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
rootProject.name = 'EntityLib'
|
rootProject.name = 'EntityLib'
|
||||||
include 'test-plugin'
|
include 'test-plugin'
|
||||||
|
include 'wrapper-entity'
|
||||||
|
|
||||||
|
|
42
src/.gitignore
vendored
Normal file
42
src/.gitignore
vendored
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
.gradle
|
||||||
|
build/
|
||||||
|
!gradle/wrapper/gradle-wrapper.jar
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
out/
|
||||||
|
!**/src/main/**/out/
|
||||||
|
!**/src/test/**/out/
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
bin/
|
||||||
|
!**/src/main/**/bin/
|
||||||
|
!**/src/test/**/bin/
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
21
src/main/java/me/tofaa/entitylib/EntityIdProvider.java
Normal file
21
src/main/java/me/tofaa/entitylib/EntityIdProvider.java
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
package me.tofaa.entitylib;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface EntityIdProvider {
|
||||||
|
|
||||||
|
static EntityIdProvider simple() {
|
||||||
|
return new EntityIdProvider() {
|
||||||
|
private final AtomicInteger atomicInteger = new AtomicInteger(0);
|
||||||
|
@Override
|
||||||
|
public int provide() {
|
||||||
|
return atomicInteger.incrementAndGet();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int provide();
|
||||||
|
}
|
|
@ -1,19 +1,33 @@
|
||||||
package me.tofaa.entitylib;
|
package me.tofaa.entitylib;
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.PacketEventsAPI;
|
import com.github.retrooper.packetevents.PacketEventsAPI;
|
||||||
|
import com.github.retrooper.packetevents.event.PacketListenerAbstract;
|
||||||
|
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
||||||
|
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||||
|
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||||
|
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||||
|
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity;
|
||||||
|
import me.tofaa.entitylib.entity.EntityInteractionProcessor;
|
||||||
|
import me.tofaa.entitylib.entity.WrapperEntity;
|
||||||
import me.tofaa.entitylib.meta.EntityMeta;
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
import me.tofaa.entitylib.meta.Metadata;
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
public final class EntityLib {
|
public final class EntityLib {
|
||||||
|
|
||||||
private EntityLib() {}
|
private EntityLib() {}
|
||||||
private static final HashMap<Integer, EntityMeta> metadata = new HashMap<>();
|
private static final HashMap<Integer, EntityMeta> metadata = new HashMap<>();
|
||||||
|
private static final Map<UUID, WrapperEntity> entities = new ConcurrentHashMap<>();
|
||||||
|
private static final Map<Integer, WrapperEntity> entitiesById = new ConcurrentHashMap<>();
|
||||||
|
private static EntityInteractionProcessor interactionProcessor;
|
||||||
private static boolean initialized = false;
|
private static boolean initialized = false;
|
||||||
private static PacketEventsAPI<?> packetEvents;
|
private static PacketEventsAPI<?> packetEvents;
|
||||||
private static MetaConverterRegistry metaRegistry;
|
private static MetaConverterRegistry metaRegistry;
|
||||||
|
@ -31,6 +45,43 @@ public final class EntityLib {
|
||||||
metaRegistry = new MetaConverterRegistry();
|
metaRegistry = new MetaConverterRegistry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void enableEntityInteractions() {
|
||||||
|
checkInit();
|
||||||
|
packetEvents.getEventManager().registerListener(new PacketListenerAbstract() {
|
||||||
|
@Override
|
||||||
|
public void onPacketReceive(PacketReceiveEvent event) {
|
||||||
|
if (interactionProcessor == null) return;
|
||||||
|
if (event.getPacketType() != PacketType.Play.Client.INTERACT_ENTITY) return;
|
||||||
|
WrapperPlayClientInteractEntity packet = new WrapperPlayClientInteractEntity(event);
|
||||||
|
WrapperEntity entity = getEntity(packet.getEntityId());
|
||||||
|
if (entity == null) return;
|
||||||
|
interactionProcessor.process(
|
||||||
|
entity, packet.getAction(), packet.getHand(), event.getUser()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @Nullable WrapperEntity getEntity(int entityId) {
|
||||||
|
checkInit();
|
||||||
|
return entitiesById.get(entityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @Nullable WrapperEntity getEntity(UUID uuid) {
|
||||||
|
checkInit();
|
||||||
|
return entities.get(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @Nullable WrapperEntity createEntity(UUID uuid, EntityType entityType) {
|
||||||
|
checkInit();
|
||||||
|
int id = WrapperEntity.ID_PROVIDER.provide();
|
||||||
|
EntityMeta meta = createMeta(id, entityType);
|
||||||
|
if (meta == null) return null;
|
||||||
|
WrapperEntity entity = new WrapperEntity(uuid, entityType, meta);
|
||||||
|
entities.put(uuid, entity);
|
||||||
|
entitiesById.put(id, entity);
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
public static @Nullable EntityMeta getMeta(int entityId) {
|
public static @Nullable EntityMeta getMeta(int entityId) {
|
||||||
checkInit();
|
checkInit();
|
||||||
|
@ -61,11 +112,32 @@ public final class EntityLib {
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static EntityMeta createMeta(WrapperEntity entity) {
|
||||||
|
return createMeta(entity.getEntityId(), entity.getEntityType());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T extends EntityMeta> Class<T> getMetaClassOf(EntityType entityType) {
|
||||||
|
return metaRegistry.getMetaClass(entityType);
|
||||||
|
}
|
||||||
|
|
||||||
public static PacketEventsAPI<?> getPacketEvents() {
|
public static PacketEventsAPI<?> getPacketEvents() {
|
||||||
checkInit();
|
checkInit();
|
||||||
return packetEvents;
|
return packetEvents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void sendPacket(UUID user, PacketWrapper<?> wrapper) {
|
||||||
|
checkInit();
|
||||||
|
packetEvents.getProtocolManager().sendPacket(packetEvents.getProtocolManager().getChannel(user), wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @Nullable EntityInteractionProcessor getInteractionProcessor() {
|
||||||
|
return interactionProcessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setInteractionProcessor(EntityInteractionProcessor interactionProcessor) {
|
||||||
|
EntityLib.interactionProcessor = interactionProcessor;
|
||||||
|
}
|
||||||
|
|
||||||
private static void checkInit() {
|
private static void checkInit() {
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
throw new IllegalStateException("EntityLib is not initialized");
|
throw new IllegalStateException("EntityLib is not initialized");
|
||||||
|
|
|
@ -7,14 +7,28 @@ import me.tofaa.entitylib.meta.mobs.*;
|
||||||
import me.tofaa.entitylib.meta.mobs.DonkeyMeta;
|
import me.tofaa.entitylib.meta.mobs.DonkeyMeta;
|
||||||
import me.tofaa.entitylib.meta.mobs.cuboid.MagmaCubeMeta;
|
import me.tofaa.entitylib.meta.mobs.cuboid.MagmaCubeMeta;
|
||||||
import me.tofaa.entitylib.meta.mobs.cuboid.SlimeMeta;
|
import me.tofaa.entitylib.meta.mobs.cuboid.SlimeMeta;
|
||||||
|
import me.tofaa.entitylib.meta.mobs.golem.IronGolemMeta;
|
||||||
|
import me.tofaa.entitylib.meta.mobs.golem.ShulkerMeta;
|
||||||
|
import me.tofaa.entitylib.meta.mobs.golem.SnowGolemMeta;
|
||||||
import me.tofaa.entitylib.meta.mobs.horse.*;
|
import me.tofaa.entitylib.meta.mobs.horse.*;
|
||||||
|
import me.tofaa.entitylib.meta.mobs.monster.*;
|
||||||
|
import me.tofaa.entitylib.meta.mobs.monster.piglin.PiglinBruteMeta;
|
||||||
|
import me.tofaa.entitylib.meta.mobs.monster.piglin.PiglinMeta;
|
||||||
|
import me.tofaa.entitylib.meta.mobs.monster.raider.*;
|
||||||
|
import me.tofaa.entitylib.meta.mobs.monster.skeleton.SkeletonMeta;
|
||||||
|
import me.tofaa.entitylib.meta.mobs.monster.skeleton.StrayMeta;
|
||||||
|
import me.tofaa.entitylib.meta.mobs.monster.skeleton.WitherSkeletonMeta;
|
||||||
|
import me.tofaa.entitylib.meta.mobs.monster.zombie.*;
|
||||||
|
import me.tofaa.entitylib.meta.mobs.passive.*;
|
||||||
|
import me.tofaa.entitylib.meta.mobs.water.*;
|
||||||
|
import me.tofaa.entitylib.meta.mobs.minecart.*;
|
||||||
|
import me.tofaa.entitylib.meta.mobs.other.*;
|
||||||
import me.tofaa.entitylib.meta.mobs.tameable.CatMeta;
|
import me.tofaa.entitylib.meta.mobs.tameable.CatMeta;
|
||||||
import me.tofaa.entitylib.meta.mobs.tameable.ParrotMeta;
|
import me.tofaa.entitylib.meta.mobs.tameable.ParrotMeta;
|
||||||
import me.tofaa.entitylib.meta.mobs.tameable.WolfMeta;
|
import me.tofaa.entitylib.meta.mobs.tameable.WolfMeta;
|
||||||
import me.tofaa.entitylib.meta.projectile.SmallFireballMeta;
|
import me.tofaa.entitylib.meta.mobs.villager.VillagerMeta;
|
||||||
import me.tofaa.entitylib.meta.projectile.ThrownEggMeta;
|
import me.tofaa.entitylib.meta.mobs.villager.WanderingTraderMeta;
|
||||||
import me.tofaa.entitylib.meta.projectile.ThrownExpBottleMeta;
|
import me.tofaa.entitylib.meta.projectile.*;
|
||||||
import me.tofaa.entitylib.meta.projectile.ThrownTridentMeta;
|
|
||||||
import me.tofaa.entitylib.meta.types.PlayerMeta;
|
import me.tofaa.entitylib.meta.types.PlayerMeta;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
@ -27,45 +41,122 @@ import static com.github.retrooper.packetevents.protocol.entity.type.EntityTypes
|
||||||
final class MetaConverterRegistry {
|
final class MetaConverterRegistry {
|
||||||
|
|
||||||
private final Map<EntityType, BiFunction<Integer, Metadata, EntityMeta>> converters = new HashMap<>();
|
private final Map<EntityType, BiFunction<Integer, Metadata, EntityMeta>> converters = new HashMap<>();
|
||||||
|
private final Map<EntityType, Class<? extends EntityMeta>> metaClasses = new HashMap<>();
|
||||||
|
|
||||||
MetaConverterRegistry() {
|
MetaConverterRegistry() {
|
||||||
put(PLAYER, PlayerMeta::new);
|
put(AREA_EFFECT_CLOUD, AreaEffectCloudMeta.class, AreaEffectCloudMeta::new);
|
||||||
put(THROWN_EXP_BOTTLE, ThrownExpBottleMeta::new);
|
put(ARMOR_STAND, ArmorStandMeta.class, ArmorStandMeta::new);
|
||||||
put(EGG, ThrownEggMeta::new);
|
put(BOAT, BoatMeta.class, BoatMeta::new);
|
||||||
put(TRIDENT, ThrownTridentMeta::new);
|
put(DRAGON_FIREBALL, DragonFireballMeta.class, DragonFireballMeta::new);
|
||||||
put(POTION, ThrownTridentMeta::new);
|
put(END_CRYSTAL, EndCrystalMeta.class, EndCrystalMeta::new);
|
||||||
put(SMALL_FIREBALL, SmallFireballMeta::new);
|
put(ENDER_DRAGON, EnderDragonMeta.class, EnderDragonMeta::new);
|
||||||
put(PIG, PigMeta::new);
|
put(EVOKER_FANGS, EvokerFangsMeta.class, EvokerFangsMeta::new);
|
||||||
put(COW, CowMeta::new);
|
put(FALLING_BLOCK, FallingBlockMeta.class, FallingBlockMeta::new);
|
||||||
put(CHICKEN, ChickenMeta::new);
|
put(FIREWORK_ROCKET, FireworkRocketMeta.class, FireworkRocketMeta::new);
|
||||||
put(BEE, BeeMeta::new);
|
put(FISHING_BOBBER, FishingHookMeta.class, FishingHookMeta::new);
|
||||||
put(TURTLE, TurtleMeta::new);
|
put(GLOW_ITEM_FRAME, GlowItemFrameMeta.class, GlowItemFrameMeta::new);
|
||||||
put(DONKEY, DonkeyMeta::new);
|
put(ITEM_FRAME, ItemFrameMeta.class, ItemFrameMeta::new);
|
||||||
put(SHEEP, SheepMeta::new);
|
put(LEASH_KNOT, LeashKnotMeta.class, LeashKnotMeta::new);
|
||||||
put(RABBIT, RabbitMeta::new);
|
put(LIGHTNING_BOLT, LightningBoltMeta.class, LightningBoltMeta::new);
|
||||||
put(POLAR_BEAR, PolarBearMeta::new);
|
put(LLAMA_SPIT, LlamaSpitMeta.class, LlamaSpitMeta::new);
|
||||||
put(OCELOT, OcelotMeta::new );
|
put(MARKER, MarkerMeta.class, MarkerMeta::new);
|
||||||
put(PANDA, PandaMeta::new);
|
put(PAINTING, PaintingMeta.class, PaintingMeta::new);
|
||||||
put(STRIDER, StriderMeta::new);
|
put(PRIMED_TNT, PrimedTntMeta.class, PrimedTntMeta::new);
|
||||||
put(FOX, FoxMeta::new);
|
put(WITHER_SKULL, WitherSkullMeta.class, WitherSkullMeta::new);
|
||||||
put(FROG, FrogMeta::new);
|
put(ZOGLIN, ZoglinMeta.class, ZoglinMeta::new);
|
||||||
put(GOAT, GoatMeta::new);
|
put(WITHER, WitherMeta.class, WitherMeta::new);
|
||||||
put(HOGLIN, HoglinMeta::new);
|
put(VEX, VexMeta.class, VexMeta::new);
|
||||||
put(CAT, CatMeta::new);
|
put(SPIDER, SpiderMeta.class, SpiderMeta::new);
|
||||||
put(PARROT, ParrotMeta::new);
|
put(SILVERFISH, SilverfishMeta.class, SilverfishMeta::new);
|
||||||
put(WOLF, WolfMeta::new);
|
put(GUARDIAN, GuardianMeta.class, GuardianMeta::new);
|
||||||
put(DONKEY, DonkeyMeta::new);
|
put(GIANT, GiantMeta.class, GiantMeta::new);
|
||||||
put(HORSE, HorseMeta::new);
|
put(ENDERMITE, EndermiteMeta.class, EndermiteMeta::new);
|
||||||
put(LLAMA, LlamaMeta::new);
|
put(ENDERMITE, EndermiteMeta.class, EndermiteMeta::new);
|
||||||
put(MULE, MuleMeta::new);
|
put(ELDER_GUARDIAN, ElderGuardianMeta.class, ElderGuardianMeta::new);
|
||||||
put(SKELETON_HORSE, SkeletonHorseMeta::new);
|
put(CREEPER, CreeperMeta.class, CreeperMeta::new);
|
||||||
put(ZOMBIE_HORSE, ZombieHorseMeta::new);
|
put(CAVE_SPIDER, CaveSpiderMeta.class, CaveSpiderMeta::new);
|
||||||
put(SLIME, SlimeMeta::new);
|
put(BLAZE, BlazeMeta.class, BlazeMeta::new);
|
||||||
put(MAGMA_CUBE, MagmaCubeMeta::new);
|
put(PIGLIN, PiglinMeta.class, PiglinMeta::new);
|
||||||
|
put(PIGLIN_BRUTE, PiglinBruteMeta.class, PiglinBruteMeta::new);
|
||||||
|
put(EVOKER, EvokerMeta.class, EvokerMeta::new);
|
||||||
|
put(ILLUSIONER, IllusionerMeta.class, IllusionerMeta::new);
|
||||||
|
put(PILLAGER, PillagerMeta.class, PillagerMeta::new);
|
||||||
|
put(RAVAGER, RavagerMeta.class, RavagerMeta::new);
|
||||||
|
put(VINDICATOR, VindicatorMeta.class, VindicatorMeta::new);
|
||||||
|
put(WITCH, WitchMeta.class, WitchMeta::new);
|
||||||
|
put(SKELETON, SkeletonMeta.class, SkeletonMeta::new);
|
||||||
|
put(STRAY, StrayMeta.class, StrayMeta::new);
|
||||||
|
put(WITHER_SKELETON, WitherSkeletonMeta.class, WitherSkeletonMeta::new);
|
||||||
|
put(DROWNED, DrownedMeta.class, DrownedMeta::new);
|
||||||
|
put(HUSK, HuskMeta.class, HuskMeta::new);
|
||||||
|
put(ZOMBIE, ZombieMeta.class, ZombieMeta::new);
|
||||||
|
put(ZOMBIE_VILLAGER, ZombieVillagerMeta.class, ZombieVillagerMeta::new);
|
||||||
|
put(ZOMBIFIED_PIGLIN, ZombifiedPiglinMeta.class, ZombifiedPiglinMeta::new);
|
||||||
|
put(AXOLOTL, AxolotlMeta.class, AxolotlMeta::new);
|
||||||
|
put(COD, CodMeta.class, CodMeta::new);
|
||||||
|
put(DOLPHIN, DolphinMeta.class, DolphinMeta::new);
|
||||||
|
put(GLOW_SQUID, GlowSquidMeta.class, GlowSquidMeta::new);
|
||||||
|
put(PUFFERFISH, PufferFishMeta.class, PufferFishMeta::new);
|
||||||
|
put(SALMON, SalmonMeta.class, SalmonMeta::new);
|
||||||
|
put(TROPICAL_FISH, TropicalFishMeta.class, TropicalFishMeta::new);
|
||||||
|
put(ARROW, ArrowMeta.class, ArrowMeta::new);
|
||||||
|
put(VILLAGER, VillagerMeta.class, VillagerMeta::new);
|
||||||
|
put(WANDERING_TRADER, WanderingTraderMeta.class, WanderingTraderMeta::new);
|
||||||
|
put(CHEST_MINECART, ChestMinecartMeta.class, ChestMinecartMeta::new);
|
||||||
|
put(COMMAND_BLOCK_MINECART, CommandBlockMinecartMeta.class, CommandBlockMinecartMeta::new);
|
||||||
|
put(COMMAND_BLOCK_MINECART, CommandBlockMinecartMeta.class, CommandBlockMinecartMeta::new);
|
||||||
|
put(FURNACE_MINECART, FurnaceMinecartMeta.class, FurnaceMinecartMeta::new);
|
||||||
|
put(HOPPER_MINECART, FurnaceMinecartMeta.class, FurnaceMinecartMeta::new);
|
||||||
|
put(SPAWNER_MINECART, SpawnerMinecartMeta.class, SpawnerMinecartMeta::new);
|
||||||
|
put(TNT_MINECART, TntMinecartMeta.class, TntMinecartMeta::new);
|
||||||
|
put(PLAYER, PlayerMeta.class, PlayerMeta::new);
|
||||||
|
put(THROWN_EXP_BOTTLE, ThrownExpBottleMeta.class, ThrownExpBottleMeta::new);
|
||||||
|
put(EGG, ThrownEggMeta.class, ThrownEggMeta::new);
|
||||||
|
put(TRIDENT, ThrownTridentMeta.class, ThrownTridentMeta::new);
|
||||||
|
put(POTION, ThrownTridentMeta.class, ThrownTridentMeta::new);
|
||||||
|
put(SMALL_FIREBALL, SmallFireballMeta.class, SmallFireballMeta::new);
|
||||||
|
put(PIG, PigMeta.class, PigMeta::new);
|
||||||
|
put(COW, CowMeta.class, CowMeta::new);
|
||||||
|
put(CHICKEN, ChickenMeta.class, ChickenMeta::new);
|
||||||
|
put(BEE, BeeMeta.class, BeeMeta::new);
|
||||||
|
put(TURTLE, TurtleMeta.class, TurtleMeta::new);
|
||||||
|
put(DONKEY, DonkeyMeta.class, DonkeyMeta::new);
|
||||||
|
put(SHEEP, SheepMeta.class, SheepMeta::new);
|
||||||
|
put(RABBIT, RabbitMeta.class, RabbitMeta::new);
|
||||||
|
put(POLAR_BEAR, PolarBearMeta.class, PolarBearMeta::new);
|
||||||
|
put(OCELOT, OcelotMeta.class, OcelotMeta::new );
|
||||||
|
put(PANDA, PandaMeta.class, PandaMeta::new);
|
||||||
|
put(STRIDER, StriderMeta.class, StriderMeta::new);
|
||||||
|
put(FOX, FoxMeta.class, FoxMeta::new);
|
||||||
|
put(FROG, FrogMeta.class, FrogMeta::new);
|
||||||
|
put(GOAT, GoatMeta.class, GoatMeta::new);
|
||||||
|
put(HOGLIN, HoglinMeta.class, HoglinMeta::new);
|
||||||
|
put(CAT, CatMeta.class, CatMeta::new);
|
||||||
|
put(PARROT, ParrotMeta.class, ParrotMeta::new);
|
||||||
|
put(WOLF, WolfMeta.class, WolfMeta::new);
|
||||||
|
put(DONKEY, DonkeyMeta.class, DonkeyMeta::new);
|
||||||
|
put(HORSE, HorseMeta.class, HorseMeta::new);
|
||||||
|
put(LLAMA, LlamaMeta.class, LlamaMeta::new);
|
||||||
|
put(MULE, MuleMeta.class, MuleMeta::new);
|
||||||
|
put(SKELETON_HORSE, SkeletonHorseMeta.class, SkeletonHorseMeta::new);
|
||||||
|
put(ZOMBIE_HORSE, ZombieHorseMeta.class, ZombieHorseMeta::new);
|
||||||
|
put(SLIME, SlimeMeta.class, SlimeMeta::new);
|
||||||
|
put(MAGMA_CUBE, MagmaCubeMeta.class, MagmaCubeMeta::new);
|
||||||
|
put(SHULKER_BULLET, ShulkerBulletMeta.class, ShulkerBulletMeta::new);
|
||||||
|
put(TRADER_LLAMA, TraderLlamaMeta.class, TraderLlamaMeta::new);
|
||||||
|
put(BAT, BatMeta.class, BatMeta::new);
|
||||||
|
put(IRON_GOLEM, IronGolemMeta.class, IronGolemMeta::new);
|
||||||
|
put(SHULKER, ShulkerMeta.class, ShulkerMeta::new);
|
||||||
|
put(SNOW_GOLEM, SnowGolemMeta.class, SnowGolemMeta::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void put(EntityType entityType, BiFunction<Integer, Metadata, EntityMeta> function) {
|
private void put(EntityType entityType, Class<? extends EntityMeta> metaClass, BiFunction<Integer, Metadata, EntityMeta> function) {
|
||||||
converters.put(entityType, function);
|
converters.put(entityType, function);
|
||||||
|
metaClasses.put(entityType, metaClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends EntityMeta> Class<T> getMetaClass(EntityType entityType) {
|
||||||
|
return (Class<T>) metaClasses.get(entityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable BiFunction<Integer, Metadata, EntityMeta> get(EntityType entityType) {
|
public @Nullable BiFunction<Integer, Metadata, EntityMeta> get(EntityType entityType) {
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package me.tofaa.entitylib.entity;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.player.InteractionHand;
|
||||||
|
import com.github.retrooper.packetevents.protocol.player.User;
|
||||||
|
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface EntityInteractionProcessor {
|
||||||
|
|
||||||
|
void process(
|
||||||
|
@NotNull WrapperEntity entity,
|
||||||
|
@NotNull WrapperPlayClientInteractEntity.InteractAction action,
|
||||||
|
@NotNull InteractionHand hand,
|
||||||
|
@NotNull User user
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
139
src/main/java/me/tofaa/entitylib/entity/WrapperEntity.java
Normal file
139
src/main/java/me/tofaa/entitylib/entity/WrapperEntity.java
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
package me.tofaa.entitylib.entity;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
||||||
|
import com.github.retrooper.packetevents.protocol.player.User;
|
||||||
|
import com.github.retrooper.packetevents.protocol.world.Location;
|
||||||
|
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||||
|
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerDestroyEntities;
|
||||||
|
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityTeleport;
|
||||||
|
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSpawnEntity;
|
||||||
|
import me.tofaa.entitylib.EntityIdProvider;
|
||||||
|
import me.tofaa.entitylib.EntityLib;
|
||||||
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class WrapperEntity {
|
||||||
|
|
||||||
|
public static EntityIdProvider ID_PROVIDER = EntityIdProvider.simple();
|
||||||
|
|
||||||
|
private final EntityType entityType;
|
||||||
|
private final int entityId;
|
||||||
|
private final Optional<UUID> uuid;
|
||||||
|
private final EntityMeta meta;
|
||||||
|
private final Set<UUID> viewers = new HashSet<>();
|
||||||
|
|
||||||
|
private Location location;
|
||||||
|
private boolean spawned;
|
||||||
|
|
||||||
|
public WrapperEntity(@NotNull UUID uuid, EntityType entityType, EntityMeta meta) {
|
||||||
|
this.uuid = Optional.of(uuid);
|
||||||
|
this.entityType = entityType;
|
||||||
|
this.entityId = ID_PROVIDER.provide();
|
||||||
|
this.meta = meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean spawn(Location location) {
|
||||||
|
if (spawned) return false;
|
||||||
|
this.location = location;
|
||||||
|
this.spawned = true;
|
||||||
|
sendPacketToViewers(
|
||||||
|
new WrapperPlayServerSpawnEntity(
|
||||||
|
entityId,
|
||||||
|
this.uuid,
|
||||||
|
entityType,
|
||||||
|
location.getPosition(),
|
||||||
|
location.getPitch(),
|
||||||
|
location.getYaw(),
|
||||||
|
location.getYaw(),
|
||||||
|
0,
|
||||||
|
Optional.empty()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove() {
|
||||||
|
if (!spawned) return;
|
||||||
|
spawned = false;
|
||||||
|
sendPacketToViewers(new WrapperPlayServerDestroyEntities(entityId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void teleport(Location location, boolean onGround) {
|
||||||
|
this.location = location;
|
||||||
|
sendPacketToViewers(
|
||||||
|
new WrapperPlayServerEntityTeleport(entityId, location, onGround)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void teleport(Location location) {
|
||||||
|
teleport(location, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendPacketToViewers(PacketWrapper<?> packet) {
|
||||||
|
viewers.forEach(uuid -> {
|
||||||
|
Object user = EntityLib.getPacketEvents().getProtocolManager().getChannel(uuid);
|
||||||
|
EntityLib.getPacketEvents().getProtocolManager().sendPacket(user, packet);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean addViewer(UUID uuid) {
|
||||||
|
if (!viewers.add(uuid)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!spawned) return false;
|
||||||
|
WrapperPlayServerSpawnEntity packet = new WrapperPlayServerSpawnEntity(
|
||||||
|
entityId,
|
||||||
|
this.uuid,
|
||||||
|
entityType,
|
||||||
|
location.getPosition(),
|
||||||
|
location.getPitch(),
|
||||||
|
location.getYaw(),
|
||||||
|
location.getYaw(),
|
||||||
|
0,
|
||||||
|
Optional.empty()
|
||||||
|
);
|
||||||
|
EntityLib.sendPacket(uuid, packet);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addViewer(User user) {
|
||||||
|
addViewer(user.getUUID());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeViewer(UUID uuid) {
|
||||||
|
if (!viewers.remove(uuid)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
EntityLib.sendPacket(uuid, new WrapperPlayServerDestroyEntities(entityId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityMeta getMeta() {
|
||||||
|
return meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUuid() {
|
||||||
|
return uuid.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityType getEntityType() {
|
||||||
|
return entityType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEntityId() {
|
||||||
|
return entityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends EntityMeta> Class<T> getMetaClass() {
|
||||||
|
return EntityLib.getMetaClassOf(entityType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasSpawned() {
|
||||||
|
return spawned;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
38
src/main/java/me/tofaa/entitylib/extras/Rotation.java
Normal file
38
src/main/java/me/tofaa/entitylib/extras/Rotation.java
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
package me.tofaa.entitylib.extras;
|
||||||
|
|
||||||
|
public enum Rotation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No rotation
|
||||||
|
*/
|
||||||
|
NONE,
|
||||||
|
/**
|
||||||
|
* Rotated clockwise by 45 degrees
|
||||||
|
*/
|
||||||
|
CLOCKWISE_45,
|
||||||
|
/**
|
||||||
|
* Rotated clockwise by 90 degrees
|
||||||
|
*/
|
||||||
|
CLOCKWISE,
|
||||||
|
/**
|
||||||
|
* Rotated clockwise by 135 degrees
|
||||||
|
*/
|
||||||
|
CLOCKWISE_135,
|
||||||
|
/**
|
||||||
|
* Flipped upside-down, a 180 degree rotation
|
||||||
|
*/
|
||||||
|
FLIPPED,
|
||||||
|
/**
|
||||||
|
* Flipped upside-down + 45 degree rotation
|
||||||
|
*/
|
||||||
|
FLIPPED_45,
|
||||||
|
/**
|
||||||
|
* Rotated counter-clockwise by 90 degrees
|
||||||
|
*/
|
||||||
|
COUNTER_CLOCKWISE,
|
||||||
|
/**
|
||||||
|
* Rotated counter-clockwise by 45 degrees
|
||||||
|
*/
|
||||||
|
COUNTER_CLOCKWISE_45;
|
||||||
|
|
||||||
|
}
|
26
src/main/java/me/tofaa/entitylib/meta/mobs/BatMeta.java
Normal file
26
src/main/java/me/tofaa/entitylib/meta/mobs/BatMeta.java
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||||
|
|
||||||
|
public class BatMeta extends MobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
private final static byte IS_HANGING_BIT = 0x01;
|
||||||
|
|
||||||
|
public BatMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHanging() {
|
||||||
|
return getMaskBit(OFFSET, IS_HANGING_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHanging(boolean value) {
|
||||||
|
setMaskBit(OFFSET, IS_HANGING_BIT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.golem;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||||
|
|
||||||
|
public class IronGolemMeta extends MobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||||
|
|
||||||
|
private final static byte PLAYER_CREATED_BIT = 0x01;
|
||||||
|
|
||||||
|
public IronGolemMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPlayerCreated() {
|
||||||
|
return getMaskBit(OFFSET, PLAYER_CREATED_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayerCreated(boolean value) {
|
||||||
|
setMaskBit(OFFSET, PLAYER_CREATED_BIT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.golem;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import com.github.retrooper.packetevents.protocol.world.Direction;
|
||||||
|
import com.github.retrooper.packetevents.util.Vector3i;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class ShulkerMeta extends MobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||||
|
|
||||||
|
|
||||||
|
public ShulkerMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Direction getAttachFace() {
|
||||||
|
return super.metadata.getIndex(OFFSET, Direction.DOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAttachFace(Direction value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value.ordinal());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<Vector3i> getAttachmentPosition() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 1), Optional.empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAttachmentPosition(Vector3i value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.OPTIONAL_BLOCK_POSITION, Optional.of(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getShieldHeight() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 2), (byte) 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShieldHeight(byte value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BYTE, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getColor() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 3), (byte) 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColor(byte value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 3), EntityDataTypes.BYTE, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.golem;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||||
|
|
||||||
|
public class SnowGolemMeta extends MobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||||
|
|
||||||
|
public SnowGolemMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHasPumpkinHat() {
|
||||||
|
return super.metadata.getIndex(OFFSET, (byte) 0x10) == (byte) 0x10;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHasPumpkinHat(boolean value) {
|
||||||
|
byte var = value ? (byte) 0x10 : (byte) 0x00;
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.BYTE, var);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.horse;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class TraderLlamaMeta extends EntityMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public TraderLlamaMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.minecart;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.ObjectData;
|
||||||
|
|
||||||
|
public abstract class BaseMinecartMeta extends EntityMeta implements ObjectData {
|
||||||
|
|
||||||
|
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 6;
|
||||||
|
|
||||||
|
protected BaseMinecartMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getShakingPower() {
|
||||||
|
return super.metadata.getIndex(OFFSET, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShakingPower(int value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getShakingDirection() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 1), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShakingDirection(int value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.INT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getShakingMultiplier() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 2), 0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShakingMultiplier(float value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.FLOAT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCustomBlockIdAndDamage() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 3), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustomBlockIdAndDamage(int value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 3), EntityDataTypes.INT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// in 16th of a block
|
||||||
|
public int getCustomBlockYPosition() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 4), 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustomBlockYPosition(int value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 4), EntityDataTypes.INT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresVelocityPacketAtSpawn() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.minecart;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class ChestMinecartMeta extends BaseMinecartMeta{
|
||||||
|
|
||||||
|
public static final byte OFFSET = BaseMinecartMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
|
||||||
|
public ChestMinecartMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getObjectData() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.minecart;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class CommandBlockMinecartMeta extends BaseMinecartMeta{
|
||||||
|
|
||||||
|
public static final byte OFFSET = BaseMinecartMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||||
|
|
||||||
|
public CommandBlockMinecartMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull String getCommand() {
|
||||||
|
return super.metadata.getIndex(OFFSET, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommand(@NotNull String value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.STRING, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull Component getLastOutput() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 1), Component.empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastOutput(@NotNull Component value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.COMPONENT, GsonComponentSerializer.gson().serialize(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getObjectData() {
|
||||||
|
return 6;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.minecart;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class FurnaceMinecartMeta extends BaseMinecartMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = BaseMinecartMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||||
|
|
||||||
|
public FurnaceMinecartMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHasFuel() {
|
||||||
|
return super.metadata.getIndex(OFFSET, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHasFuel(boolean value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getObjectData() {
|
||||||
|
return 2; }
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.minecart;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class HopperMinecartMeta extends BaseMinecartMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = BaseMinecartMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public HopperMinecartMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getObjectData() {
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.minecart;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class MinecartMeta extends BaseMinecartMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = BaseMinecartMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public MinecartMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getObjectData() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.minecart;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class SpawnerMinecartMeta extends BaseMinecartMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = BaseMinecartMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public SpawnerMinecartMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getObjectData() {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.minecart;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class TntMinecartMeta extends BaseMinecartMeta{
|
||||||
|
|
||||||
|
public static final byte OFFSET = BaseMinecartMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public TntMinecartMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getObjectData() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||||
|
|
||||||
|
public class BlazeMeta extends MobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||||
|
|
||||||
|
private final static byte ON_FIRE_BIT = 0x01;
|
||||||
|
|
||||||
|
public BlazeMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOnFire() {
|
||||||
|
return getMaskBit(OFFSET, ON_FIRE_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnFire(boolean value) {
|
||||||
|
setMaskBit(OFFSET, ON_FIRE_BIT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class CaveSpiderMeta extends SpiderMeta{
|
||||||
|
|
||||||
|
public static final byte OFFSET = SpiderMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public CaveSpiderMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class CreeperMeta extends MobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||||
|
|
||||||
|
public CreeperMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public State getState() {
|
||||||
|
int id = super.metadata.getIndex(OFFSET, -1);
|
||||||
|
return id == -1 ? State.IDLE : State.FUSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(@NotNull State value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value == State.IDLE ? -1 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCharged() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 1), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCharged(boolean value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIgnited() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 2), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIgnited(boolean value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum State {
|
||||||
|
IDLE,
|
||||||
|
FUSE
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class ElderGuardianMeta extends GuardianMeta{
|
||||||
|
|
||||||
|
public static final byte OFFSET = GuardianMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public ElderGuardianMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class EndermanMeta extends MobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||||
|
|
||||||
|
public EndermanMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCarriedBlockID() {
|
||||||
|
return super.metadata.getIndex(OFFSET, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCarriedBlockID(@Nullable Integer value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.OPTIONAL_INT, Optional.ofNullable(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isScreaming() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 1), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScreaming(boolean value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStaring() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 2), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStaring(boolean value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||||
|
|
||||||
|
public class EndermiteMeta extends MobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public EndermiteMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package me.tofaa.entitylib.meta.mobs;
|
package me.tofaa.entitylib.meta.mobs.monster;
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
import me.tofaa.entitylib.meta.Metadata;
|
import me.tofaa.entitylib.meta.Metadata;
|
|
@ -0,0 +1,13 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||||
|
|
||||||
|
public class GiantMeta extends MobMeta {
|
||||||
|
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public GiantMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||||
|
|
||||||
|
public class GuardianMeta extends MobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||||
|
|
||||||
|
private int target = -1;
|
||||||
|
|
||||||
|
public GuardianMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRetractingSpikes() {
|
||||||
|
return super.metadata.getIndex(OFFSET, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRetractingSpikes(boolean retractingSpikes) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, retractingSpikes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTarget() {
|
||||||
|
return this.target;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTarget(int target) {
|
||||||
|
this.target = target;
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.INT, target == -1 ? 0 : target);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package me.tofaa.entitylib.meta.mobs;
|
package me.tofaa.entitylib.meta.mobs.monster;
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
import me.tofaa.entitylib.meta.Metadata;
|
import me.tofaa.entitylib.meta.Metadata;
|
|
@ -0,0 +1,14 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||||
|
|
||||||
|
public class SilverfishMeta extends MobMeta {
|
||||||
|
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
|
||||||
|
public SilverfishMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||||
|
|
||||||
|
public class SpiderMeta extends MobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||||
|
|
||||||
|
private final static byte CLIMBING_BIT = 0x01;
|
||||||
|
|
||||||
|
|
||||||
|
public SpiderMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isClimbing() {
|
||||||
|
return getMaskBit(OFFSET, CLIMBING_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClimbing(boolean value) {
|
||||||
|
setMaskBit(OFFSET, CLIMBING_BIT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||||
|
|
||||||
|
public class VexMeta extends MobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||||
|
|
||||||
|
private final static byte ATTACKING_BIT = 0x01;
|
||||||
|
|
||||||
|
public VexMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAttacking() {
|
||||||
|
return getMaskBit(OFFSET, ATTACKING_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAttacking(boolean value) {
|
||||||
|
setMaskBit(OFFSET, ATTACKING_BIT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||||
|
|
||||||
|
public class WitherMeta extends MobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 4;
|
||||||
|
|
||||||
|
private int centerHead = -1;
|
||||||
|
private int leftHead = -1;
|
||||||
|
private int rightHead = -1;
|
||||||
|
|
||||||
|
public WitherMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCenterHead(int centerHead) {
|
||||||
|
this.centerHead = centerHead;
|
||||||
|
super.metadata.setIndex(offset(OFFSET,0), EntityDataTypes.INT, centerHead == -1 ? 0 : centerHead);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLeftHead(int leftHead) {
|
||||||
|
this.leftHead = leftHead;
|
||||||
|
super.metadata.setIndex(offset(OFFSET,1), EntityDataTypes.INT, leftHead == -1 ? 0 : leftHead);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRightHead(int rightHead) {
|
||||||
|
this.rightHead = rightHead;
|
||||||
|
super.metadata.setIndex(offset(OFFSET,2), EntityDataTypes.INT, rightHead == -1 ? 0 : rightHead);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCenterHead() {
|
||||||
|
return centerHead;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLeftHead() {
|
||||||
|
return leftHead;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRightHead() {
|
||||||
|
return rightHead;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getInvulnerableTime() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 3), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInvulnerableTime(int value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 3), EntityDataTypes.INT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||||
|
|
||||||
|
public class ZoglinMeta extends MobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||||
|
|
||||||
|
public ZoglinMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isBaby() {
|
||||||
|
return super.metadata.getIndex(OFFSET, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBaby(boolean value) {
|
||||||
|
if (isBaby() == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster.piglin;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||||
|
|
||||||
|
public abstract class BasePiglinMeta extends MobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||||
|
|
||||||
|
protected BasePiglinMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isImmuneToZombification() {
|
||||||
|
return super.metadata.getIndex(OFFSET, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImmuneToZombification(boolean value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster.piglin;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class PiglinBruteMeta extends BasePiglinMeta{
|
||||||
|
|
||||||
|
public static final byte OFFSET = BasePiglinMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public PiglinBruteMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster.piglin;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class PiglinMeta extends BasePiglinMeta{
|
||||||
|
|
||||||
|
public static final byte OFFSET = BasePiglinMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||||
|
|
||||||
|
public PiglinMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBaby() {
|
||||||
|
return super.metadata.getIndex(OFFSET, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBaby(boolean value) {
|
||||||
|
if (isBaby() == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isChargingCrossbow() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 1), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChargingCrossbow(boolean value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDancing() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 2), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDancing(boolean value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster.raider;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class EvokerMeta extends SpellcasterIllagerMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = SpellcasterIllagerMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public EvokerMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster.raider;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class IllusionerMeta extends SpellcasterIllagerMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = SpellcasterIllagerMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public IllusionerMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster.raider;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class PillagerMeta extends RaiderMeta{
|
||||||
|
|
||||||
|
public static final byte OFFSET = RaiderMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
|
||||||
|
public PillagerMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster.raider;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||||
|
|
||||||
|
public class RaiderMeta extends MobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||||
|
|
||||||
|
public RaiderMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCelebrating() {
|
||||||
|
return super.metadata.getIndex(OFFSET, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCelebrating(boolean value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster.raider;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class RavagerMeta extends RaiderMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = RaiderMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
|
||||||
|
public RavagerMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster.raider;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class SpellcasterIllagerMeta extends RaiderMeta{
|
||||||
|
|
||||||
|
public static final byte OFFSET = RaiderMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||||
|
|
||||||
|
public SpellcasterIllagerMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster.raider;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class VindicatorMeta extends RaiderMeta{
|
||||||
|
|
||||||
|
public static final byte OFFSET = RaiderMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public VindicatorMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster.raider;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class WitchMeta extends RaiderMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = RaiderMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||||
|
|
||||||
|
public WitchMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDrinkingPotion() {
|
||||||
|
return super.metadata.getIndex(OFFSET, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDrinkingPotion(boolean value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster.skeleton;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||||
|
|
||||||
|
public class SkeletonMeta extends MobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public SkeletonMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster.skeleton;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class StrayMeta extends SkeletonMeta{
|
||||||
|
|
||||||
|
|
||||||
|
public StrayMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster.skeleton;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class WitherSkeletonMeta extends SkeletonMeta {
|
||||||
|
public static final byte OFFSET = SkeletonMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public WitherSkeletonMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster.zombie;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class DrownedMeta extends ZombieMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = ZombieMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
public DrownedMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster.zombie;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class HuskMeta extends ZombieMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = ZombieMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public HuskMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster.zombie;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||||
|
|
||||||
|
public class ZombieMeta extends MobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||||
|
|
||||||
|
public ZombieMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBaby() {
|
||||||
|
return super.metadata.getIndex(OFFSET, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBaby(boolean value) {
|
||||||
|
if (isBaby() == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBecomingDrowned() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 2), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBecomingDrowned(boolean value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster.zombie;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.villager.VillagerData;
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.villager.profession.VillagerProfessions;
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.villager.type.VillagerTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.mobs.villager.VillagerMeta;
|
||||||
|
|
||||||
|
public class ZombieVillagerMeta extends ZombieMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = ZombieMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||||
|
|
||||||
|
public ZombieVillagerMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isConverting() {
|
||||||
|
return super.metadata.getIndex(OFFSET, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConverting(boolean value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public VillagerData getVillagerData() {
|
||||||
|
int[] data = super.metadata.getIndex(offset(OFFSET, 1), null);
|
||||||
|
if (data == null) {
|
||||||
|
return new VillagerData(VillagerTypes.PLAINS, VillagerProfessions.NONE, VillagerMeta.Level.NOVICE.ordinal());
|
||||||
|
}
|
||||||
|
return new VillagerData(VillagerMeta.TYPES[data[0]], VillagerMeta.PROFESSIONS[data[1]], VillagerMeta.Level.VALUES[data[2] - 1].ordinal());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVillagerData(VillagerData data) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.VILLAGER_DATA, new VillagerData(
|
||||||
|
data.getType().getId(),
|
||||||
|
data.getProfession().getId(),
|
||||||
|
data.getLevel() + 1
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.monster.zombie;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class ZombifiedPiglinMeta extends ZombieMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = ZombieMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public ZombifiedPiglinMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.other;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class AreaEffectCloudMeta extends EntityMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 4;
|
||||||
|
|
||||||
|
public AreaEffectCloudMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getRadius() {
|
||||||
|
return super.metadata.getIndex(OFFSET, .5F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRadius(float value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.FLOAT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getColor() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 1), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColor(int value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.INT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSinglePoint() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 2), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSinglePoint(boolean value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,110 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.other;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import com.github.retrooper.packetevents.util.Vector3f;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.LivingEntityMeta;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class ArmorStandMeta extends LivingEntityMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = LivingEntityMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 7;
|
||||||
|
|
||||||
|
private final static byte IS_SMALL_BIT = 0x01;
|
||||||
|
private final static byte HAS_ARMS_BIT = 0x04;
|
||||||
|
private final static byte HAS_NO_BASE_PLATE_BIT = 0x08;
|
||||||
|
private final static byte IS_MARKER_BIT = 0x10;
|
||||||
|
|
||||||
|
public ArmorStandMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSmall() {
|
||||||
|
return getMaskBit(OFFSET, IS_SMALL_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSmall(boolean value) {
|
||||||
|
setMaskBit(OFFSET, IS_SMALL_BIT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHasArms() {
|
||||||
|
return getMaskBit(OFFSET, HAS_ARMS_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHasArms(boolean value) {
|
||||||
|
setMaskBit(OFFSET, HAS_ARMS_BIT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHasNoBasePlate() {
|
||||||
|
return getMaskBit(OFFSET, HAS_NO_BASE_PLATE_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHasNoBasePlate(boolean value) {
|
||||||
|
setMaskBit(OFFSET, HAS_NO_BASE_PLATE_BIT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMarker() {
|
||||||
|
return getMaskBit(OFFSET, IS_MARKER_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMarker(boolean value) {
|
||||||
|
setMaskBit(OFFSET, IS_MARKER_BIT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Vector3f getHeadRotation() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 1), Vector3f.zero());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeadRotation(@NotNull Vector3f value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.ROTATION, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Vector3f getBodyRotation() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 2), Vector3f.zero());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBodyRotation(@NotNull Vector3f value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.ROTATION, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Vector3f getLeftArmRotation() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 3), new Vector3f(-10f, 0f, -10f));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLeftArmRotation(@NotNull Vector3f value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 3), EntityDataTypes.ROTATION, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Vector3f getRightArmRotation() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 4), new Vector3f(-15f, 0f, 10f));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRightArmRotation(@NotNull Vector3f value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 4), EntityDataTypes.ROTATION, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Vector3f getLeftLegRotation() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 5), new Vector3f(-1f, 0f, -1f));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLeftLegRotation(@NotNull Vector3f value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 5), EntityDataTypes.ROTATION, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Vector3f getRightLegRotation() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 6), new Vector3f(1f, 0f, 1f));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRightLegRotation(@NotNull Vector3f value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 6), EntityDataTypes.ROTATION, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.other;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class BoatMeta extends EntityMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 7;
|
||||||
|
|
||||||
|
public BoatMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTimeSinceLastHit() {
|
||||||
|
return super.metadata.getIndex(OFFSET, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeSinceLastHit(int value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getForwardDirection() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 1), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setForwardDirection(int value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.INT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getDamageTaken() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 2), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDamageTaken(float value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.FLOAT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Type getType() {
|
||||||
|
return Type.VALUES[super.metadata.getIndex(offset(OFFSET, 3), 0)];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(@NotNull Type value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 3), EntityDataTypes.INT, value.ordinal());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLeftPaddleTurning() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 4), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLeftPaddleTurning(boolean value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 4), EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRightPaddleTurning() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 5), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRightPaddleTurning(boolean value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 5), EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSplashTimer() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 6), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSplashTimer(int value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 6), EntityDataTypes.INT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Type {
|
||||||
|
OAK,
|
||||||
|
SPRUCE,
|
||||||
|
BIRCH,
|
||||||
|
JUNGLE,
|
||||||
|
ACACIA,
|
||||||
|
DARK_OAK;
|
||||||
|
|
||||||
|
private final static Type[] VALUES = values();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.other;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.ObjectData;
|
||||||
|
import me.tofaa.entitylib.meta.types.ProjectileMeta;
|
||||||
|
|
||||||
|
public class DragonFireballMeta extends EntityMeta implements ProjectileMeta, ObjectData {
|
||||||
|
|
||||||
|
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
private int shooter = -1;
|
||||||
|
|
||||||
|
public DragonFireballMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getObjectData() {
|
||||||
|
return this.shooter == -1 ? 0 : this.shooter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresVelocityPacketAtSpawn() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getShooter() {
|
||||||
|
return shooter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setShooter(int entityId) {
|
||||||
|
this.shooter = entityId;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.other;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import com.github.retrooper.packetevents.util.Vector3i;
|
||||||
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class EndCrystalMeta extends EntityMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||||
|
|
||||||
|
public EndCrystalMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable Optional<Vector3i> getBeamTarget() {
|
||||||
|
return super.metadata.getIndex(OFFSET, Optional.empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBeamTarget(@Nullable Vector3i value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.OPTIONAL_BLOCK_POSITION, Optional.ofNullable(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isShowingBottom() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 1), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowingBottom(boolean value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.other;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class EnderDragonMeta extends MobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
|
||||||
|
public EnderDragonMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Phase getPhase() {
|
||||||
|
return Phase.VALUES[super.metadata.getIndex(OFFSET, 0)];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhase(@NotNull Phase value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value.ordinal());
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Phase {
|
||||||
|
CIRCLING,
|
||||||
|
STRAFING,
|
||||||
|
FLYING_TO_THE_PORTAL,
|
||||||
|
LANDING_ON_THE_PORTAL,
|
||||||
|
TAKING_OFF_FROM_THE_PORTAL,
|
||||||
|
BREATH_ATTACK,
|
||||||
|
LOOKING_FOR_BREATH_ATTACK_PLAYER,
|
||||||
|
ROAR,
|
||||||
|
CHARGING_PLAYER,
|
||||||
|
FLYING_TO_THE_PORTAL_TO_DIE,
|
||||||
|
HOVERING_WITHOUT_AI;
|
||||||
|
|
||||||
|
private final static Phase[] VALUES = values();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.other;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class EvokerFangsMeta extends EntityMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public EvokerFangsMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.other;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import com.github.retrooper.packetevents.util.Vector3i;
|
||||||
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.ObjectData;
|
||||||
|
|
||||||
|
public class FallingBlockMeta extends EntityMeta implements ObjectData {
|
||||||
|
|
||||||
|
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||||
|
|
||||||
|
private int blockStateId;
|
||||||
|
|
||||||
|
public FallingBlockMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3i getSpawnPosition() {
|
||||||
|
return super.metadata.getIndex(OFFSET, Vector3i.zero());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpawnPosition(Vector3i value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.BLOCK_POSITION, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getBlockStateId() {
|
||||||
|
return blockStateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockStateId(int blockStateId) {
|
||||||
|
this.blockStateId = blockStateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getObjectData() {
|
||||||
|
return blockStateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresVelocityPacketAtSpawn() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.other;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||||
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.ProjectileMeta;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class FireworkRocketMeta extends EntityMeta implements ProjectileMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||||
|
|
||||||
|
private int shooter = -1;
|
||||||
|
|
||||||
|
public FireworkRocketMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getFireworkItem() {
|
||||||
|
return super.metadata.getIndex(OFFSET, ItemStack.EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFireworkItem(ItemStack value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.ITEMSTACK, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isShotAtAngle() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 2), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShotAtAngle(boolean value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getShooter() {
|
||||||
|
return shooter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setShooter(int entityId) {
|
||||||
|
this.shooter = entityId;
|
||||||
|
Optional<Integer> optional = Optional.ofNullable(entityId == -1 ? null : entityId);
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.OPTIONAL_INT, optional);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.other;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.ObjectData;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class FishingHookMeta extends EntityMeta implements ObjectData {
|
||||||
|
|
||||||
|
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||||
|
|
||||||
|
private int shooterId;
|
||||||
|
private int hookedId;
|
||||||
|
|
||||||
|
public FishingHookMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCatchable() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 1), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCatchable(boolean value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHookedEntity() {
|
||||||
|
return hookedId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShooter(int entityId) {
|
||||||
|
this.shooterId = entityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHookedEntity(int entityId) {
|
||||||
|
this.hookedId = entityId;
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, entityId == -1 ? 0 : entityId + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getObjectData() {
|
||||||
|
return shooterId != -1 ? shooterId : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresVelocityPacketAtSpawn() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.other;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class GlowItemFrameMeta extends ItemFrameMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = ItemFrameMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public GlowItemFrameMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.other;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||||
|
import me.tofaa.entitylib.extras.Rotation;
|
||||||
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.ObjectData;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class ItemFrameMeta extends EntityMeta implements ObjectData {
|
||||||
|
|
||||||
|
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||||
|
|
||||||
|
private Orientation orientation = Orientation.DOWN;
|
||||||
|
|
||||||
|
public ItemFrameMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public ItemStack getItem() {
|
||||||
|
return super.metadata.getIndex(OFFSET, ItemStack.EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItem(@NotNull ItemStack value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.ITEMSTACK, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Rotation getRotation() {
|
||||||
|
return Rotation.values()[super.metadata.getIndex(offset(OFFSET, 1), 0)];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRotation(@NotNull Rotation value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.INT, value.ordinal());
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Orientation getOrientation() {
|
||||||
|
return this.orientation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets orientation of the item frame.
|
||||||
|
* This is possible only before spawn packet is sent.
|
||||||
|
*
|
||||||
|
* @param orientation the orientation of the item frame.
|
||||||
|
*/
|
||||||
|
public void setOrientation(@NotNull Orientation orientation) {
|
||||||
|
this.orientation = orientation;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getObjectData() {
|
||||||
|
return this.orientation.ordinal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresVelocityPacketAtSpawn() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Orientation {
|
||||||
|
DOWN,
|
||||||
|
UP,
|
||||||
|
NORTH,
|
||||||
|
SOUTH,
|
||||||
|
WEST,
|
||||||
|
EAST
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.other;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class LeashKnotMeta extends EntityMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public LeashKnotMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.other;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class LightningBoltMeta extends EntityMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public LightningBoltMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.other;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.ObjectData;
|
||||||
|
|
||||||
|
public class LlamaSpitMeta extends EntityMeta implements ObjectData {
|
||||||
|
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public LlamaSpitMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getObjectData() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresVelocityPacketAtSpawn() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.other;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class MarkerMeta extends EntityMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public MarkerMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,120 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.other;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.world.Direction;
|
||||||
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO
|
||||||
|
*/
|
||||||
|
public class PaintingMeta extends EntityMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
private Direction direction = Direction.SOUTH;
|
||||||
|
private Type type = Type.KEBAB;
|
||||||
|
|
||||||
|
public PaintingMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Type getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(@NotNull Type type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Direction getDirection() {
|
||||||
|
return direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDirection(@NotNull Direction direction) {
|
||||||
|
if (direction == Direction.UP || direction == Direction.DOWN) {
|
||||||
|
throw new IllegalArgumentException("Direction cannot be up or down");
|
||||||
|
}
|
||||||
|
this.direction = direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public enum Type {
|
||||||
|
KEBAB(0, 0, 16, 16),
|
||||||
|
AZTEC(16, 0, 16, 16),
|
||||||
|
ALBAN(32, 0, 16, 16),
|
||||||
|
AZTEC2(48, 0, 16, 16),
|
||||||
|
BOMB(64, 0, 16, 16),
|
||||||
|
PLANT(80, 0, 16, 16),
|
||||||
|
WASTELAND(96, 0, 16, 16),
|
||||||
|
POOL(0, 32, 32, 16),
|
||||||
|
COURBET(32, 32, 32, 16),
|
||||||
|
SEA(64, 32, 32, 16),
|
||||||
|
SUNSET(96, 32, 32, 16),
|
||||||
|
CREEBET(128, 32, 32, 16),
|
||||||
|
WANDERER(0, 64, 16, 32),
|
||||||
|
GRAHAM(16, 64, 16, 32),
|
||||||
|
MATCH(0, 128, 32, 32),
|
||||||
|
BUST(32, 128, 32, 32),
|
||||||
|
STAGE(64, 128, 32, 32),
|
||||||
|
VOID(96, 128, 32, 32),
|
||||||
|
SKULL_AND_ROSES("skull_and_roses", 128, 128, 32, 32),
|
||||||
|
WITHER(160, 128, 32, 32),
|
||||||
|
FIGHTERS(0, 96, 64, 32),
|
||||||
|
POINTER(0, 192, 64, 64),
|
||||||
|
PIGSCENE(64, 192, 64, 64),
|
||||||
|
BURNING_SKULL(128, 192, 64, 64),
|
||||||
|
SKELETON(192, 64, 64, 48),
|
||||||
|
DONKEY_KONG(192, 112, 64, 48);
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private final int x;
|
||||||
|
private final int y;
|
||||||
|
private final int width;
|
||||||
|
private final int height;
|
||||||
|
|
||||||
|
Type(String name, int x, int y, int width, int height) {
|
||||||
|
this.name = name;
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
Type(int x, int y, int width, int height) {
|
||||||
|
this.name = "minecraft:" + name().toLowerCase(Locale.ROOT);
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getX() {
|
||||||
|
return this.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getY() {
|
||||||
|
return this.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWidth() {
|
||||||
|
return this.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHeight() {
|
||||||
|
return this.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.other;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class PrimedTntMeta extends EntityMeta {
|
||||||
|
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||||
|
|
||||||
|
|
||||||
|
public PrimedTntMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFuseTime() {
|
||||||
|
return super.metadata.getIndex(OFFSET, 80);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFuseTime(int value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.other;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.ObjectData;
|
||||||
|
import me.tofaa.entitylib.meta.types.ProjectileMeta;
|
||||||
|
|
||||||
|
public class WitherSkullMeta extends EntityMeta implements ObjectData, ProjectileMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||||
|
|
||||||
|
private int shooter = -1;
|
||||||
|
|
||||||
|
public WitherSkullMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isInvulnerable() {
|
||||||
|
return super.metadata.getIndex(OFFSET, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInvulnerable(boolean value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getObjectData() {
|
||||||
|
return this.shooter == -1 ? 0 : this.shooter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresVelocityPacketAtSpawn() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getShooter() {
|
||||||
|
return shooter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setShooter(int entityId) {
|
||||||
|
this.shooter = entityId;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package me.tofaa.entitylib.meta.mobs;
|
package me.tofaa.entitylib.meta.mobs.passive;
|
||||||
|
|
||||||
import me.tofaa.entitylib.meta.Metadata;
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
|
@ -1,4 +1,4 @@
|
||||||
package me.tofaa.entitylib.meta.mobs;
|
package me.tofaa.entitylib.meta.mobs.passive;
|
||||||
|
|
||||||
import me.tofaa.entitylib.meta.Metadata;
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
|
@ -1,4 +1,4 @@
|
||||||
package me.tofaa.entitylib.meta.mobs;
|
package me.tofaa.entitylib.meta.mobs.passive;
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
import me.tofaa.entitylib.meta.Metadata;
|
import me.tofaa.entitylib.meta.Metadata;
|
|
@ -1,4 +1,4 @@
|
||||||
package me.tofaa.entitylib.meta.mobs;
|
package me.tofaa.entitylib.meta.mobs.passive;
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
|
@ -1,4 +1,4 @@
|
||||||
package me.tofaa.entitylib.meta.mobs;
|
package me.tofaa.entitylib.meta.mobs.passive;
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
import me.tofaa.entitylib.meta.Metadata;
|
import me.tofaa.entitylib.meta.Metadata;
|
|
@ -1,4 +1,4 @@
|
||||||
package me.tofaa.entitylib.meta.mobs;
|
package me.tofaa.entitylib.meta.mobs.passive;
|
||||||
|
|
||||||
import me.tofaa.entitylib.meta.Metadata;
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
|
@ -1,4 +1,4 @@
|
||||||
package me.tofaa.entitylib.meta.mobs;
|
package me.tofaa.entitylib.meta.mobs.passive;
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
import com.github.retrooper.packetevents.util.Vector3i;
|
import com.github.retrooper.packetevents.util.Vector3i;
|
|
@ -0,0 +1,24 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.villager;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||||
|
|
||||||
|
public class BaseVillagerMeta extends AgeableMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||||
|
|
||||||
|
public BaseVillagerMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHeadShakeTimer() {
|
||||||
|
return super.metadata.getIndex(OFFSET, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeadShakeTimer(int value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.villager;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.villager.VillagerData;
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.villager.profession.VillagerProfession;
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.villager.profession.VillagerProfessions;
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.villager.type.VillagerType;
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.villager.type.VillagerTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class VillagerMeta extends BaseVillagerMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = BaseVillagerMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||||
|
|
||||||
|
@ApiStatus.Internal
|
||||||
|
public static final VillagerType[] TYPES = new VillagerType[] {
|
||||||
|
VillagerTypes.DESERT,
|
||||||
|
VillagerTypes.JUNGLE,
|
||||||
|
VillagerTypes.PLAINS,
|
||||||
|
VillagerTypes.SAVANNA,
|
||||||
|
VillagerTypes.SNOW,
|
||||||
|
VillagerTypes.SWAMP,
|
||||||
|
VillagerTypes.TAIGA
|
||||||
|
};
|
||||||
|
|
||||||
|
@ApiStatus.Internal
|
||||||
|
public static final VillagerProfession[] PROFESSIONS = new VillagerProfession[] {
|
||||||
|
VillagerProfessions.NONE,
|
||||||
|
VillagerProfessions.ARMORER,
|
||||||
|
VillagerProfessions.BUTCHER,
|
||||||
|
VillagerProfessions.CARTOGRAPHER,
|
||||||
|
VillagerProfessions.CLERIC,
|
||||||
|
VillagerProfessions.FARMER,
|
||||||
|
VillagerProfessions.FISHERMAN,
|
||||||
|
VillagerProfessions.FLETCHER,
|
||||||
|
VillagerProfessions.LEATHERWORKER,
|
||||||
|
VillagerProfessions.LIBRARIAN,
|
||||||
|
VillagerProfessions.MASON,
|
||||||
|
VillagerProfessions.NITWIT,
|
||||||
|
VillagerProfessions.SHEPHERD,
|
||||||
|
VillagerProfessions.TOOLSMITH,
|
||||||
|
VillagerProfessions.WEAPONSMITH
|
||||||
|
};
|
||||||
|
|
||||||
|
public VillagerMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public VillagerData getVillagerData() {
|
||||||
|
int[] data = super.metadata.getIndex(OFFSET, null);
|
||||||
|
if (data == null) {
|
||||||
|
return new VillagerData(VillagerTypes.PLAINS, VillagerProfessions.NONE, Level.NOVICE.ordinal());
|
||||||
|
}
|
||||||
|
return new VillagerData(TYPES[data[0]], PROFESSIONS[data[1]], Level.VALUES[data[2] - 1].ordinal());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVillagerData(@NotNull VillagerData data) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.VILLAGER_DATA, new VillagerData(
|
||||||
|
data.getType().getId(),
|
||||||
|
data.getProfession().getId(),
|
||||||
|
data.getLevel()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public enum Level {
|
||||||
|
NOVICE,
|
||||||
|
APPRENTICE,
|
||||||
|
JOURNEYMAN,
|
||||||
|
EXPERT,
|
||||||
|
MASTER;
|
||||||
|
|
||||||
|
public final static Level[] VALUES = values();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.villager;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class WanderingTraderMeta extends VillagerMeta{
|
||||||
|
|
||||||
|
public static final byte OFFSET = VillagerMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public WanderingTraderMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.water;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.WaterMobMeta;
|
||||||
|
|
||||||
|
public class AxolotlMeta extends WaterMobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = WaterMobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||||
|
|
||||||
|
public AxolotlMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Variant getVariant() {
|
||||||
|
return Variant.VALUES[super.metadata.getIndex(OFFSET, 0)];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVariant(Variant variant) {
|
||||||
|
metadata.setIndex(OFFSET, EntityDataTypes.INT, variant.ordinal());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPlayingDead() {
|
||||||
|
return metadata.getIndex(offset(OFFSET, 1), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayingDead(boolean playingDead) {
|
||||||
|
metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BOOLEAN, playingDead);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFromBucket() {
|
||||||
|
return metadata.getIndex(offset(OFFSET, 2), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFromBucket(boolean fromBucket) {
|
||||||
|
metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, fromBucket);
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Variant {
|
||||||
|
LUCY,
|
||||||
|
WILD,
|
||||||
|
GOLD,
|
||||||
|
CYAN,
|
||||||
|
BLUE;
|
||||||
|
|
||||||
|
private final static AxolotlMeta.Variant[] VALUES = values();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.water;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.WaterMobMeta;
|
||||||
|
|
||||||
|
public class BaseFishMeta extends WaterMobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = WaterMobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||||
|
|
||||||
|
public BaseFishMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isFromBucket() {
|
||||||
|
return super.metadata.getIndex(OFFSET, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFromBucket(boolean value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.water;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class CodMeta extends BaseFishMeta{
|
||||||
|
|
||||||
|
public static final byte OFFSET = BaseFishMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public CodMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.water;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import com.github.retrooper.packetevents.util.Vector3i;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.WaterMobMeta;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class DolphinMeta extends WaterMobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = WaterMobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||||
|
|
||||||
|
public DolphinMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Vector3i getTreasurePosition() {
|
||||||
|
return super.metadata.getIndex(OFFSET, Vector3i.zero());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTreasurePosition(@NotNull Vector3i value) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.BLOCK_POSITION, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCanFindTreasure() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 1), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCanFindTreasure(boolean value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHasFish() {
|
||||||
|
return super.metadata.getIndex(offset(OFFSET, 2), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHasFish(boolean value) {
|
||||||
|
super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.water;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class GlowSquidMeta extends SquidMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = SquidMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||||
|
|
||||||
|
public GlowSquidMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDarkTicksRemaining() {
|
||||||
|
return metadata.getIndex(OFFSET, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDarkTicksRemaining(int ticks) {
|
||||||
|
metadata.setIndex(OFFSET, EntityDataTypes.INT, ticks);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.water;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class PufferFishMeta extends BaseFishMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = BaseFishMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||||
|
|
||||||
|
public PufferFishMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public State getState() {
|
||||||
|
return State.VALUES[super.metadata.getIndex(OFFSET, 0)];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(State state) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, state.ordinal());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public enum State {
|
||||||
|
UNPUFFED,
|
||||||
|
SEMI_PUFFED,
|
||||||
|
FULLY_PUFFED;
|
||||||
|
|
||||||
|
private final static State[] VALUES = values();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.water;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class SalmonMeta extends BaseFishMeta{
|
||||||
|
public SalmonMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.water;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.WaterMobMeta;
|
||||||
|
|
||||||
|
public class SquidMeta extends WaterMobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = WaterMobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public SquidMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,128 @@
|
||||||
|
package me.tofaa.entitylib.meta.mobs.water;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.ObjectData;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class TropicalFishMeta extends BaseFishMeta implements ObjectData {
|
||||||
|
|
||||||
|
public static final byte OFFSET = BaseFishMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||||
|
|
||||||
|
public TropicalFishMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Variant getVariant() {
|
||||||
|
return getVariantFromID(super.metadata.getIndex(OFFSET, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVariant(Variant variant) {
|
||||||
|
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, getVariantID(variant));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getVariantID(Variant variant) {
|
||||||
|
int id = 0;
|
||||||
|
id |= variant.patternColor;
|
||||||
|
id <<= 8;
|
||||||
|
id |= variant.bodyColor;
|
||||||
|
id <<= 8;
|
||||||
|
id |= variant.pattern.ordinal();
|
||||||
|
id <<= 8;
|
||||||
|
id |= variant.type.ordinal();
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Variant getVariantFromID(int variantID) {
|
||||||
|
Type type = Type.VALUES[variantID & 0xFF];
|
||||||
|
variantID >>= 8;
|
||||||
|
Pattern pattern = Pattern.VALUES[variantID & 0xFF];
|
||||||
|
variantID >>= 8;
|
||||||
|
byte bodyColor = (byte) (variantID & 0xFF);
|
||||||
|
variantID >>= 8;
|
||||||
|
byte patternColor = (byte) (variantID & 0xFF);
|
||||||
|
return new Variant(type, pattern, bodyColor, patternColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getObjectData() {
|
||||||
|
// TODO: returns Entity ID of the owner (???)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresVelocityPacketAtSpawn() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Variant {
|
||||||
|
|
||||||
|
private Type type;
|
||||||
|
private Pattern pattern;
|
||||||
|
private byte bodyColor;
|
||||||
|
private byte patternColor;
|
||||||
|
|
||||||
|
public Variant(@NotNull Type type, @NotNull Pattern pattern, byte bodyColor, byte patternColor) {
|
||||||
|
this.type = type;
|
||||||
|
this.pattern = pattern;
|
||||||
|
this.bodyColor = bodyColor;
|
||||||
|
this.patternColor = patternColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Type getType() {
|
||||||
|
return this.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(@NotNull Type type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Pattern getPattern() {
|
||||||
|
return this.pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPattern(@NotNull Pattern pattern) {
|
||||||
|
this.pattern = pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getBodyColor() {
|
||||||
|
return this.bodyColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBodyColor(byte bodyColor) {
|
||||||
|
this.bodyColor = bodyColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getPatternColor() {
|
||||||
|
return this.patternColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPatternColor(byte patternColor) {
|
||||||
|
this.patternColor = patternColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Type {
|
||||||
|
SMALL,
|
||||||
|
LARGE,
|
||||||
|
INVISIBLE;
|
||||||
|
|
||||||
|
private final static Type[] VALUES = values();
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Pattern {
|
||||||
|
KOB, // FLOPPER for LARGE fish
|
||||||
|
SUNSTREAK, // STRIPEY for LARGE fish
|
||||||
|
SNOOPER, // GLITTER for LARGE fish
|
||||||
|
DASHER, // BLOCKFISH for LARGE fish
|
||||||
|
BRINELY, // BETTY for LARGE fish
|
||||||
|
SPOTTY, // CLAYFISH for LARGE fish
|
||||||
|
NONE;
|
||||||
|
|
||||||
|
private final static Pattern[] VALUES = values();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package me.tofaa.entitylib.meta.projectile;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
import me.tofaa.entitylib.meta.types.ObjectData;
|
||||||
|
|
||||||
|
public class ShulkerBulletMeta extends EntityMeta implements ObjectData {
|
||||||
|
|
||||||
|
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public ShulkerBulletMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getObjectData() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresVelocityPacketAtSpawn() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package me.tofaa.entitylib.meta.types;
|
||||||
|
|
||||||
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
||||||
|
public class WaterMobMeta extends MobMeta {
|
||||||
|
|
||||||
|
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||||
|
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||||
|
|
||||||
|
public WaterMobMeta(int entityId, Metadata metadata) {
|
||||||
|
super(entityId, metadata);
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ public final class EntityLibPlugin extends JavaPlugin {
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
EntityLib.init(PacketEvents.getAPI());
|
EntityLib.init(PacketEvents.getAPI());
|
||||||
getCommand("testapi").setExecutor(new TestCommand());
|
getCommand("testapi").setExecutor(new TestCommand());
|
||||||
|
getCommand("testentity").setExecutor(new TestEntityCommand());
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,7 @@ import com.github.retrooper.packetevents.util.Vector3d;
|
||||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityMetadata;
|
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityMetadata;
|
||||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSpawnEntity;
|
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSpawnEntity;
|
||||||
import me.tofaa.entitylib.meta.EntityMeta;
|
import me.tofaa.entitylib.meta.EntityMeta;
|
||||||
import me.tofaa.entitylib.meta.mobs.PigMeta;
|
import me.tofaa.entitylib.meta.mobs.passive.SheepMeta;
|
||||||
import me.tofaa.entitylib.meta.mobs.SheepMeta;
|
|
||||||
import me.tofaa.entitylib.meta.types.PlayerMeta;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue