├── .github └── workflows │ ├── close-invalid-prs.yml │ └── dev-build-release.yml ├── .gitignore ├── LICENSE ├── README.md ├── api ├── build.gradle.kts └── src │ └── main │ └── java │ └── me │ └── tofaa │ └── entitylib │ ├── APIConfig.java │ ├── EntityIdProvider.java │ ├── EntityLib.java │ ├── EntityLibAPI.java │ ├── EntityUuidProvider.java │ ├── Platform.java │ ├── container │ ├── AbstractEntityContainer.java │ ├── ContainerImpl.java │ ├── EmptyContainer.java │ └── EntityContainer.java │ ├── event │ ├── CancellableEntityLibEvent.java │ ├── EntityLibEvent.java │ ├── EventCallback.java │ ├── EventHandler.java │ ├── EventHandlerImpl.java │ └── EventListener.java │ ├── extras │ ├── Color.java │ ├── CoordinateUtil.java │ ├── DyeColor.java │ ├── InvalidVersionException.java │ ├── MojangApiError.java │ ├── Rotation.java │ ├── VersionChecker.java │ └── skin │ │ ├── CSFBImpl.java │ │ ├── CachedSkinFetcherBuilder.java │ │ ├── CachedSkinFetcherImpl.java │ │ ├── ErroredTextureProperties.java │ │ ├── SFBImpl.java │ │ ├── SFUtils.java │ │ ├── SkinFetcher.java │ │ ├── SkinFetcherBuilder.java │ │ └── SkinFetcherImpl.java │ ├── meta │ ├── EntityMeta.java │ ├── MetaConverterRegistry.java │ ├── MetaOffsetConverter.java │ ├── Metadata.java │ ├── display │ │ ├── AbstractDisplayMeta.java │ │ ├── BlockDisplayMeta.java │ │ ├── ItemDisplayMeta.java │ │ └── TextDisplayMeta.java │ ├── mobs │ │ ├── BatMeta.java │ │ ├── BeeMeta.java │ │ ├── DonkeyMeta.java │ │ ├── FoxMeta.java │ │ ├── FrogMeta.java │ │ ├── GoatMeta.java │ │ ├── HoglinMeta.java │ │ ├── OcelotMeta.java │ │ ├── PandaMeta.java │ │ ├── PolarBearMeta.java │ │ ├── SnifferMeta.java │ │ ├── StriderMeta.java │ │ ├── cuboid │ │ │ ├── MagmaCubeMeta.java │ │ │ └── SlimeMeta.java │ │ ├── golem │ │ │ ├── IronGolemMeta.java │ │ │ ├── ShulkerMeta.java │ │ │ └── SnowGolemMeta.java │ │ ├── horse │ │ │ ├── BaseHorseMeta.java │ │ │ ├── CamelMeta.java │ │ │ ├── ChestedHorseMeta.java │ │ │ ├── DonkeyMeta.java │ │ │ ├── HorseMeta.java │ │ │ ├── LlamaMeta.java │ │ │ ├── MuleMeta.java │ │ │ ├── SkeletonHorseMeta.java │ │ │ ├── TraderLlamaMeta.java │ │ │ └── ZombieHorseMeta.java │ │ ├── minecart │ │ │ ├── BaseMinecartMeta.java │ │ │ ├── ChestMinecartMeta.java │ │ │ ├── CommandBlockMinecartMeta.java │ │ │ ├── FurnaceMinecartMeta.java │ │ │ ├── HopperMinecartMeta.java │ │ │ ├── MinecartMeta.java │ │ │ ├── SpawnerMinecartMeta.java │ │ │ └── TntMinecartMeta.java │ │ ├── monster │ │ │ ├── BlazeMeta.java │ │ │ ├── BreezeMeta.java │ │ │ ├── CaveSpiderMeta.java │ │ │ ├── CreeperMeta.java │ │ │ ├── ElderGuardianMeta.java │ │ │ ├── EndermanMeta.java │ │ │ ├── EndermiteMeta.java │ │ │ ├── GhastMeta.java │ │ │ ├── GiantMeta.java │ │ │ ├── GuardianMeta.java │ │ │ ├── PhantomMeta.java │ │ │ ├── SilverfishMeta.java │ │ │ ├── SpiderMeta.java │ │ │ ├── VexMeta.java │ │ │ ├── WardenMeta.java │ │ │ ├── WitherMeta.java │ │ │ ├── ZoglinMeta.java │ │ │ ├── piglin │ │ │ │ ├── BasePiglinMeta.java │ │ │ │ ├── PiglinBruteMeta.java │ │ │ │ └── PiglinMeta.java │ │ │ ├── raider │ │ │ │ ├── EvokerMeta.java │ │ │ │ ├── IllusionerMeta.java │ │ │ │ ├── PillagerMeta.java │ │ │ │ ├── RaiderMeta.java │ │ │ │ ├── RavagerMeta.java │ │ │ │ ├── SpellcasterIllagerMeta.java │ │ │ │ ├── VindicatorMeta.java │ │ │ │ └── WitchMeta.java │ │ │ ├── skeleton │ │ │ │ ├── BoggedMeta.java │ │ │ │ ├── SkeletonMeta.java │ │ │ │ ├── StrayMeta.java │ │ │ │ └── WitherSkeletonMeta.java │ │ │ └── zombie │ │ │ │ ├── DrownedMeta.java │ │ │ │ ├── HuskMeta.java │ │ │ │ ├── ZombieMeta.java │ │ │ │ ├── ZombieVillagerMeta.java │ │ │ │ └── ZombifiedPiglinMeta.java │ │ ├── passive │ │ │ ├── ArmadilloMeta.java │ │ │ ├── ChickenMeta.java │ │ │ ├── CowMeta.java │ │ │ ├── MooshroomMeta.java │ │ │ ├── PigMeta.java │ │ │ ├── RabbitMeta.java │ │ │ ├── SheepMeta.java │ │ │ └── TurtleMeta.java │ │ ├── tameable │ │ │ ├── CatMeta.java │ │ │ ├── ParrotMeta.java │ │ │ └── WolfMeta.java │ │ ├── villager │ │ │ ├── BaseVillagerMeta.java │ │ │ ├── VillagerMeta.java │ │ │ └── WanderingTraderMeta.java │ │ └── water │ │ │ ├── AxolotlMeta.java │ │ │ ├── BaseFishMeta.java │ │ │ ├── CodMeta.java │ │ │ ├── DolphinMeta.java │ │ │ ├── GlowSquidMeta.java │ │ │ ├── PufferFishMeta.java │ │ │ ├── SalmonMeta.java │ │ │ ├── SquidMeta.java │ │ │ └── TropicalFishMeta.java │ ├── other │ │ ├── AreaEffectCloudMeta.java │ │ ├── ArmorStandMeta.java │ │ ├── BoatMeta.java │ │ ├── EndCrystalMeta.java │ │ ├── EnderDragonMeta.java │ │ ├── EvokerFangsMeta.java │ │ ├── FallingBlockMeta.java │ │ ├── FireworkRocketMeta.java │ │ ├── FishingHookMeta.java │ │ ├── GlowItemFrameMeta.java │ │ ├── InteractionMeta.java │ │ ├── ItemFrameMeta.java │ │ ├── LeashKnotMeta.java │ │ ├── LightningBoltMeta.java │ │ ├── LlamaSpitMeta.java │ │ ├── MarkerMeta.java │ │ ├── PaintingMeta.java │ │ └── PrimedTntMeta.java │ ├── projectile │ │ ├── ArrowMeta.java │ │ ├── BaseArrowMeta.java │ │ ├── DragonFireballMeta.java │ │ ├── EyeOfEnderMeta.java │ │ ├── ItemEntityMeta.java │ │ ├── LargeFireballMeta.java │ │ ├── ShulkerBulletMeta.java │ │ ├── SmallFireballMeta.java │ │ ├── SnowballMeta.java │ │ ├── SpectralArrowMeta.java │ │ ├── ThrownEggMeta.java │ │ ├── ThrownEnderPearlMeta.java │ │ ├── ThrownExpBottleMeta.java │ │ ├── ThrownPotionMeta.java │ │ ├── ThrownTridentMeta.java │ │ └── WitherSkullMeta.java │ └── types │ │ ├── AgeableMeta.java │ │ ├── DisplayMeta.java │ │ ├── ItemContainerMeta.java │ │ ├── LivingEntityMeta.java │ │ ├── MobMeta.java │ │ ├── ObjectData.java │ │ ├── PlayerMeta.java │ │ ├── ProjectileMeta.java │ │ ├── TameableMeta.java │ │ └── WaterMobMeta.java │ ├── packetconversion │ ├── CommonSpawningMethods.java │ ├── EntitySpawningMethod.java │ ├── EntitySpawningPacketConversion.java │ ├── LegacySpawningMethods.java │ └── ModernSpawningMethods.java │ ├── storage │ ├── ByteEntitySerializer.java │ ├── EntitySerializer.java │ ├── EntityStorage.java │ └── FSEntityStorage.java │ ├── tick │ ├── TickContainer.java │ └── Tickable.java │ ├── utils │ ├── Check.java │ ├── ConcurrentWeakIdentityHashMap.java │ ├── GithubUpdater.java │ └── VersionUtil.java │ ├── ve │ ├── ViewerEngine.java │ ├── ViewerEngineListener.java │ └── ViewerRule.java │ └── wrapper │ ├── WrapperEntity.java │ ├── WrapperEntityAttributes.java │ ├── WrapperEntityCreature.java │ ├── WrapperEntityEquipment.java │ ├── WrapperEntityPotionEffect.java │ ├── WrapperExperienceOrbEntity.java │ ├── WrapperLivingEntity.java │ ├── WrapperPerPlayerEntity.java │ ├── WrapperPlayer.java │ ├── ai │ ├── AIGroup.java │ ├── GoalSelector.java │ ├── GoalSelectorList.java │ └── goals │ │ └── RandomHeadMovementGoal.java │ ├── hologram │ ├── Hologram.java │ ├── LegacyHologram.java │ └── ModernHologram.java │ └── spawning │ ├── SpawnPacketProvider.java │ └── SpawnPacketProviders.java ├── block-bench-addon ├── README.md ├── build.gradle.kts └── src │ └── main │ └── java │ └── me │ └── tofaa │ └── entitylib │ └── bb │ ├── ModelEngine.java │ ├── ModelLoader.java │ ├── ModelMath.java │ ├── Quaternion.java │ ├── animation │ └── FrameProvider.java │ └── mql │ ├── MQLData.java │ ├── MQLEvaluator.java │ └── MQLPoint.java ├── build.gradle.kts ├── buildSrc ├── build.gradle.kts ├── libs.versions.toml ├── settings.gradle.kts └── src │ └── main │ ├── kotlin │ ├── entitylib.library-conventions.gradle.kts │ ├── entitylib.shadow-conventions.gradle.kts │ └── me │ │ └── tofaa │ │ └── entitylib │ │ └── version │ │ ├── ELVersionPlugin.kt │ │ └── ELVersionTask.kt │ └── resources │ └── META-INF │ └── gradle-plugins │ └── el-version.properties ├── code-gen ├── build.gradle.kts └── src │ └── main │ ├── java │ └── me │ │ └── tofaa │ │ └── entitylib │ │ └── codegen │ │ ├── Main.java │ │ ├── MetaOffset.java │ │ ├── TypeHolder.java │ │ ├── VersionCheck.java │ │ └── modern │ │ └── Main.java │ └── resources │ └── offset-calculator.json ├── common ├── build.gradle.kts └── src │ └── main │ └── java │ └── me │ └── tofaa │ └── entitylib │ └── common │ ├── AbstractEntityLibAPI.java │ └── AbstractPlatform.java ├── discord-bot ├── build.gradle.kts └── src │ └── main │ ├── java │ └── me │ │ └── tofaa │ │ └── entitylib │ │ └── discord │ │ ├── DiscordBot.java │ │ ├── commands │ │ ├── Command.java │ │ └── impl │ │ │ ├── PingCommand.java │ │ │ └── SendMessageCommand.java │ │ └── listeners │ │ └── CommandListener.java │ └── resources │ └── logback.xml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── libs.versions.toml ├── platforms ├── spigot │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── me │ │ └── tofaa │ │ └── entitylib │ │ └── spigot │ │ ├── ExtraConversionUtil.java │ │ ├── SpigotEntityIdProvider.java │ │ ├── SpigotEntityLibAPI.java │ │ └── SpigotEntityLibPlatform.java ├── standalone │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── me │ │ └── tofaa │ │ └── entitylib │ │ └── standalone │ │ ├── StandaloneEntityLibApi.java │ │ ├── StandaloneEntityLibPlatform.java │ │ └── task │ │ ├── ExecutionType.java │ │ ├── Scheduler.java │ │ ├── SchedulerImpl.java │ │ ├── Task.java │ │ ├── TaskImpl.java │ │ └── TaskSchedule.java └── velocity │ ├── build.gradle.kts │ └── src │ └── main │ └── java │ └── me │ └── tofaa │ └── entitylib │ └── velocity │ ├── VelocityEntityLibAPI.java │ └── VelocityEntityLibPlatform.java ├── settings.gradle.kts └── test-plugin ├── .gitignore ├── build.gradle.kts └── src └── main ├── java └── me │ └── tofaa │ └── testentitylib │ ├── TestEntityLibPlugin.java │ ├── TestHologramsCommand.java │ ├── TestMassivePigCommand.java │ ├── TestPlayerCommand.java │ └── TestTextDisplayCommand.java └── resources └── plugin.yml /.github/workflows/close-invalid-prs.yml: -------------------------------------------------------------------------------- 1 | # Thanks paper: https://github.com/papermc/paper/blob/master/.github/workflows/close_invalid_prs.yml 2 | name: Close invalid PRs 3 | 4 | on: 5 | pull_request_target: 6 | types: [ opened ] 7 | 8 | jobs: 9 | run: 10 | name: Close invalid PRs 11 | if: | 12 | github.repository != github.event.pull_request.head.repo.full_name && 13 | ( 14 | github.head_ref == 'master' || 15 | github.event.pull_request.head.repo.owner.type != 'User' 16 | ) 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: superbrothers/close-pull-request@v3 20 | id: "master_branch" 21 | if: github.head_ref == 'master' 22 | with: 23 | comment: "Please do not open pull requests from the `master` branch, create a new branch instead." 24 | 25 | - uses: superbrothers/close-pull-request@v3 26 | id: "org_account" 27 | if: github.event.pull_request.head.repo.owner.type != 'User' && steps.master_branch.outcome == 'skipped' 28 | with: 29 | comment: "Please do not open pull requests from non-user accounts like organisations. Create a fork on a user account instead." 30 | -------------------------------------------------------------------------------- /.github/workflows/dev-build-release.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: ['*'] 7 | pull_request: 8 | branches: ['*'] 9 | 10 | permissions: 11 | contents: write 12 | 13 | jobs: 14 | build: 15 | runs-on: ubuntu-latest 16 | env: 17 | TYCOONS_REPO_USER: ${{ secrets.EVOKE_REPO_USERNAME }} 18 | TYCOONS_REPO_PASS: ${{ secrets.EVOKE_REPO_PASSWORD }} 19 | steps: 20 | - name: Clone project 21 | uses: actions/checkout@v4 22 | 23 | - name: Install JDK 8 24 | uses: actions/setup-java@v4 25 | with: 26 | java-version: '8' 27 | distribution: 'temurin' 28 | check-latest: true 29 | 30 | - name: Setup gradle 31 | uses: gradle/actions/setup-gradle@v4 32 | 33 | - name: Run build & publish with Gradle Wrapper 34 | if: github.ref == 'refs/heads/master' 35 | run: chmod +x ./gradlew && ./gradlew publishAllPublicationsToMavenRepository 36 | 37 | - name: Run build with Gradle Wrapper 38 | if: github.ref != 'refs/heads/master' 39 | run: chmod +x ./gradlew && ./gradlew build 40 | 41 | - name: Create Release 42 | if: github.ref != 'refs/heads/master' 43 | uses: softprops/action-gh-release@v2 44 | with: 45 | name: '${{ github.ref_name }}: ${{ github.event.head_commit.message }} (${{ github.sha }})' 46 | prerelease: ${{ github.ref != 'refs/heads/master' }} 47 | tag_name: ${{ github.ref_name }}-${{ github.sha }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build/ 3 | .idea 4 | run 5 | test-plugin/build 6 | test-plugin/run 7 | !gradle/wrapper/gradle-wrapper.jar 8 | !**/src/main/**/build/ 9 | !**/src/test/**/build/ 10 | 11 | discord-bot/.env 12 | 13 | /website 14 | 15 | ### IntelliJ IDEA ### 16 | .idea/ 17 | *.iws 18 | *.iml 19 | *.ipr 20 | out/ 21 | !**/src/main/**/out/ 22 | !**/src/test/**/out/ 23 | 24 | ### Eclipse ### 25 | .apt_generated 26 | .classpath 27 | .factorypath 28 | .project 29 | .settings 30 | .springBeans 31 | .sts4-cache 32 | bin/ 33 | !**/src/main/**/bin/ 34 | !**/src/test/**/bin/ 35 | 36 | ### NetBeans ### 37 | /nbproject/private/ 38 | /nbbuild/ 39 | /dist/ 40 | /nbdist/ 41 | /.nb-gradle/ 42 | 43 | ### VS Code ### 44 | .vscode/ 45 | 46 | ### Mac OS ### 47 | .DS_Store -------------------------------------------------------------------------------- /api/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | entitylib.`shadow-conventions` 3 | entitylib.`library-conventions` 4 | `el-version` 5 | } 6 | 7 | dependencies { 8 | api(libs.jetbrains.annotations) 9 | 10 | compileOnly(libs.bundles.adventure) 11 | compileOnly(libs.packetevents.api) 12 | testCompileOnly(libs.packetevents.api) 13 | } 14 | 15 | tasks { 16 | javadoc { 17 | mustRunAfter(generateVersionsFile) 18 | } 19 | 20 | sourcesJar { 21 | mustRunAfter(generateVersionsFile) 22 | } 23 | 24 | withType { 25 | dependsOn(generateVersionsFile) 26 | } 27 | 28 | generateVersionsFile { 29 | packageName = "me.tofaa.entitylib.utils" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/EntityIdProvider.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.type.EntityType; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | import java.util.UUID; 7 | import java.util.concurrent.atomic.AtomicInteger; 8 | 9 | /** 10 | * Represents a int provider that gives an id for each entity created. When using EntityLib with platform specific entities (Such as bukkit entities), make sure the id's do not 11 | * conflict with the platform's entity id's. 12 | * {@link DefaultEntityIdProvider} is a default implementation of this interface. 13 | */ 14 | public interface EntityIdProvider { 15 | 16 | int provide(@NotNull UUID entityUUID, @NotNull EntityType entityType); 17 | 18 | class DefaultEntityIdProvider implements EntityIdProvider { 19 | 20 | private final AtomicInteger integer = new AtomicInteger(100000); 21 | 22 | @Override 23 | public int provide(@NotNull UUID entityUUID, @NotNull EntityType entityType) { 24 | return integer.incrementAndGet(); 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/EntityLib.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib; 2 | 3 | import com.github.retrooper.packetevents.util.PEVersion; 4 | import me.tofaa.entitylib.utils.ELVersions; 5 | import me.tofaa.entitylib.utils.GithubUpdater; 6 | 7 | import java.util.Optional; 8 | 9 | public final class EntityLib { 10 | 11 | private EntityLib() {} 12 | 13 | private static Platform platform; 14 | private static EntityLibAPI api; 15 | 16 | public static void init(Platform platform, APIConfig settings) { 17 | EntityLib.platform = platform; 18 | platform.setupApi(settings); 19 | api = platform.getAPI(); 20 | 21 | new GithubUpdater("Tofaa2", "EntityLib"); 22 | } 23 | 24 | public static Optional> getOptionalApi() { 25 | return Optional.ofNullable(api); 26 | } 27 | 28 | public static EntityLibAPI getApi() { 29 | return api; 30 | } 31 | 32 | public static Platform getPlatform() { 33 | return platform; 34 | } 35 | 36 | public static PEVersion getVersion() { 37 | return ELVersions.CURRENT; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/EntityLibAPI.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib; 2 | 3 | import com.github.retrooper.packetevents.PacketEventsAPI; 4 | import me.tofaa.entitylib.container.EntityContainer; 5 | import me.tofaa.entitylib.tick.TickContainer; 6 | import me.tofaa.entitylib.wrapper.WrapperEntity; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | import java.util.Collection; 11 | import java.util.UUID; 12 | 13 | /** 14 | * Represents the API for EntityLib. 15 | * Handles the loading, enabling, and disabling of the API. And handles platform specific creation of EntityLib content. 16 | * @param The {@link TickContainer}'s param type for the platform specific TickContainer. 17 | */ 18 | public interface EntityLibAPI { 19 | 20 | /** 21 | * @return The {@link PacketEventsAPI} that EntityLib uses. 22 | */ 23 | PacketEventsAPI getPacketEvents(); 24 | 25 | void onLoad(); 26 | 27 | void onEnable(); 28 | 29 | @NotNull

P cloneEntity(@NotNull Object platformEntity); 30 | 31 | @Nullable WrapperEntity getEntity(int id); 32 | 33 | @Nullable WrapperEntity getEntity(@NotNull UUID uuid); 34 | 35 | @NotNull Collection getAllEntities(); 36 | 37 | /** 38 | * @return The {@link APIConfig} for the API. 39 | */ 40 | @NotNull APIConfig getSettings(); 41 | 42 | /** 43 | * @return An unmodifiable collection of TickContainers. 44 | */ 45 | @NotNull Collection> getTickContainers(); 46 | 47 | /** 48 | * Adds a TickContainer to the API. Automatically starts ticking it. 49 | * @param tickContainer the TickContainer to add. 50 | */ 51 | void addTickContainer(@NotNull TickContainer tickContainer); 52 | 53 | @NotNull 54 | EntityContainer getDefaultContainer(); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/EntityUuidProvider.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.type.EntityType; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | import java.util.UUID; 7 | 8 | public interface EntityUuidProvider { 9 | 10 | @NotNull UUID provide(EntityType entityType); 11 | 12 | 13 | class DefaultEntityUuidProvider implements EntityUuidProvider { 14 | 15 | @Override 16 | public @NotNull UUID provide(EntityType entityType) { 17 | return UUID.randomUUID(); 18 | } 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/container/ContainerImpl.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.container; 2 | 3 | class ContainerImpl extends AbstractEntityContainer { 4 | } 5 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/container/EmptyContainer.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.container; 2 | 3 | import me.tofaa.entitylib.wrapper.WrapperEntity; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.jetbrains.annotations.Nullable; 6 | 7 | import java.util.Collection; 8 | import java.util.Collections; 9 | import java.util.Iterator; 10 | import java.util.UUID; 11 | 12 | final class EmptyContainer implements EntityContainer { 13 | 14 | static EmptyContainer INSTANCE = new EmptyContainer(); 15 | 16 | @Override public void addEntity(WrapperEntity entity) {} 17 | @Override public void removeEntity(WrapperEntity entity, boolean despawn) {} 18 | @Override public void removeEntity(int entityId, boolean despawn) {} 19 | @Override public void removeEntity(UUID uuid, boolean despawn) {} 20 | @Override public void clearEntities(boolean despawn) {} 21 | @Override public void tick() {} 22 | @Override public Collection getEntities() {return Collections.emptyList();} 23 | @Override 24 | public @Nullable WrapperEntity getEntity(UUID uuid) { 25 | return null; 26 | } 27 | @Override 28 | public @Nullable WrapperEntity getEntity(int entityId) { 29 | return null; 30 | } 31 | @Override 32 | public boolean containsEntity(UUID uuid) { 33 | return false; 34 | } 35 | 36 | @Override 37 | public boolean containsEntity(int entityId) { 38 | return false; 39 | } 40 | 41 | @Override 42 | public boolean containsEntity(WrapperEntity entity) { 43 | return false; 44 | } 45 | 46 | @Override 47 | public @NotNull Iterator iterator() { 48 | return getEntities().iterator(); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/container/EntityContainer.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.container; 2 | 3 | import me.tofaa.entitylib.wrapper.WrapperEntity; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.jetbrains.annotations.Nullable; 6 | 7 | import java.util.*; 8 | 9 | 10 | /** 11 | * Containers are basic iterable classes that hold entities. These containers can be extended to provide more functionality, and this allows for seperation of logic between certain entities. 12 | *

13 | * To access a specific {@link WrapperEntity}'s container you can use {@link WrapperEntity#getParentContainer()}. 14 | *

15 | */ 16 | public interface EntityContainer extends Iterable { 17 | 18 | static EntityContainer basic() { 19 | return new ContainerImpl(); 20 | } 21 | 22 | static EntityContainer empty() { 23 | return EmptyContainer.INSTANCE; 24 | } 25 | 26 | 27 | void addEntity(WrapperEntity entity); 28 | 29 | void removeEntity(WrapperEntity entity, boolean despawn); 30 | 31 | default void removeEntity(WrapperEntity entity) { 32 | removeEntity(entity, false); 33 | } 34 | 35 | void removeEntity(int entityId, boolean despawn); 36 | 37 | default void removeEntity(int entityId) { 38 | removeEntity(entityId, false); 39 | } 40 | 41 | void removeEntity(UUID uuid, boolean despawn); 42 | 43 | default void removeEntity(UUID entity) { 44 | removeEntity(entity, false); 45 | } 46 | 47 | void clearEntities(boolean despawn); 48 | 49 | default void clearEntities() { 50 | clearEntities(false); 51 | } 52 | 53 | void tick(); 54 | 55 | Collection getEntities(); 56 | 57 | @Nullable WrapperEntity getEntity(UUID uuid); 58 | 59 | @Nullable WrapperEntity getEntity(int entityId); 60 | 61 | boolean containsEntity(UUID uuid); 62 | 63 | boolean containsEntity(int entityId); 64 | 65 | /** Value based contains, not reference based */ 66 | boolean containsEntity(WrapperEntity entity); 67 | 68 | } 69 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/event/CancellableEntityLibEvent.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.event; 2 | 3 | public interface CancellableEntityLibEvent extends EntityLibEvent { 4 | 5 | void setCancelled(boolean cancelled); 6 | 7 | boolean isCancelled(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/event/EntityLibEvent.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.event; 2 | 3 | public interface EntityLibEvent { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/event/EventCallback.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.event; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | @FunctionalInterface 6 | public interface EventCallback { 7 | 8 | void run(@NotNull E event); 9 | 10 | } -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/event/EventHandlerImpl.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.event; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.util.Collection; 6 | import java.util.Map; 7 | import java.util.concurrent.ConcurrentHashMap; 8 | 9 | final class EventHandlerImpl implements EventHandler { 10 | 11 | // Events 12 | private final Map, Collection> eventCallbacks = new ConcurrentHashMap<>(); 13 | 14 | EventHandlerImpl() { 15 | } 16 | 17 | public void registerListener(EventListener listener) { 18 | addEventCallback(listener.getEventClass(), EventListener.createEventCallback(listener)); 19 | } 20 | 21 | @NotNull 22 | @Override 23 | public Map, Collection> getEventCallbacksMap() { 24 | return eventCallbacks; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/event/EventListener.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.event; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.util.function.Consumer; 6 | 7 | public interface EventListener { 8 | 9 | @NotNull Class getEventClass(); 10 | 11 | void handle(@NotNull E event); 12 | 13 | static EventCallback createEventCallback(@NotNull EventListener listener) { 14 | return listener::handle; 15 | } 16 | 17 | static EventListener generateListener(Class eventClass, Consumer consumer) { 18 | return new EventListener() { 19 | @Override 20 | public @NotNull Class getEventClass() { 21 | return eventClass; 22 | } 23 | 24 | @Override 25 | public void handle(@NotNull T event) { 26 | consumer.accept(event); 27 | } 28 | }; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/extras/Color.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.extras; 2 | 3 | import net.kyori.adventure.util.RGBLike; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.jetbrains.annotations.Range; 6 | 7 | /* 8 | @Deprecated: My PR for this was accepted a while ago into PacketEvents, 3.0 will convert to the packet events version of this class. 9 | */ 10 | @Deprecated 11 | public final class Color implements RGBLike { 12 | 13 | private static final int BIT_MASK = 0xFF; 14 | 15 | private final int red, green, blue; 16 | 17 | public Color(@Range(from = 0L, to = 255L) int red, @Range(from = 0L, to = 255L) int green, @Range(from = 0L, to = 255L) int blue) { 18 | this.red = red; 19 | this.green = green; 20 | this.blue = blue; 21 | } 22 | 23 | public Color(int rgb) { 24 | this((rgb >> 16) & BIT_MASK, (rgb >> 8) & BIT_MASK, rgb & BIT_MASK); 25 | } 26 | 27 | public @NotNull Color withRed(@Range(from = 0L, to = 255L) int red) { 28 | return new Color(red, green, blue); 29 | } 30 | 31 | public @NotNull Color withGreen(@Range(from = 0L, to = 255L) int green) { 32 | return new Color(red, green, blue); 33 | } 34 | 35 | public @NotNull Color withBlue(@Range(from = 0L, to = 255L) int blue) { 36 | return new Color(red, green, blue); 37 | } 38 | 39 | public int asRGB() { 40 | int rgb = red; 41 | rgb = (rgb << 8) + green; 42 | return (rgb << 8) + blue; 43 | } 44 | 45 | @Override 46 | public @Range(from = 0L, to = 255L) int red() { 47 | return red; 48 | } 49 | 50 | @Override 51 | public @Range(from = 0L, to = 255L) int green() { 52 | return green; 53 | } 54 | 55 | @Override 56 | public @Range(from = 0L, to = 255L) int blue() { 57 | return blue; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/extras/CoordinateUtil.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.extras; 2 | 3 | import com.github.retrooper.packetevents.protocol.world.Location; 4 | import com.github.retrooper.packetevents.util.Vector3d; 5 | 6 | public final class CoordinateUtil { 7 | 8 | private CoordinateUtil() {} 9 | 10 | public static Location withDirection(Location location, Vector3d direction) { 11 | /* 12 | * Sin = Opp / Hyp 13 | * Cos = Adj / Hyp 14 | * Tan = Opp / Adj 15 | * 16 | * x = -Opp 17 | * z = Adj 18 | */ 19 | final double x = direction.getX(); 20 | final double z = direction.getZ(); 21 | if (x == 0 && z == 0) { 22 | float pitch = direction.getY() > 0 ? -90f : 90f; 23 | return new Location(location.getX(), location.getY(), location.getZ(), location.getYaw(), pitch); 24 | } 25 | final double theta = Math.atan2(-x, z); 26 | final double xz = Math.sqrt(square(x) + square(z)); 27 | final double _2PI = 2 * Math.PI; 28 | 29 | return new Location(location.getX(), location.getY(), location.getZ(), 30 | (float) Math.toDegrees((theta + _2PI) % _2PI), 31 | (float) Math.toDegrees(Math.atan(-direction.getY() / xz))); 32 | } 33 | 34 | public static double square(double in) { 35 | return in * in; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/extras/InvalidVersionException.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.extras; 2 | 3 | public class InvalidVersionException extends RuntimeException { 4 | 5 | public InvalidVersionException() { 6 | } 7 | 8 | public InvalidVersionException(String message) { 9 | super(message); 10 | } 11 | 12 | public InvalidVersionException(String message, Throwable cause) { 13 | super(message, cause); 14 | } 15 | 16 | public InvalidVersionException(Throwable cause) { 17 | super(cause); 18 | } 19 | 20 | public InvalidVersionException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 21 | super(message, cause, enableSuppression, writableStackTrace); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/extras/MojangApiError.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.extras; 2 | 3 | public class MojangApiError extends RuntimeException { 4 | 5 | public MojangApiError() { 6 | } 7 | 8 | public MojangApiError(String message) { 9 | super(message); 10 | } 11 | 12 | public MojangApiError(String message, Throwable cause) { 13 | super(message, cause); 14 | } 15 | 16 | public MojangApiError(Throwable cause) { 17 | super(cause); 18 | } 19 | 20 | public MojangApiError(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 21 | super(message, cause, enableSuppression, writableStackTrace); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/extras/Rotation.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.extras; 2 | 3 | /* 4 | @Deprecated: My PR for this was accepted a while ago into PacketEvents, 3.0 will convert to the packet events version of this class. 5 | */ 6 | @Deprecated 7 | public enum Rotation { 8 | 9 | /** 10 | * No rotation 11 | */ 12 | NONE, 13 | /** 14 | * Rotated clockwise by 45 degrees 15 | */ 16 | CLOCKWISE_45, 17 | /** 18 | * Rotated clockwise by 90 degrees 19 | */ 20 | CLOCKWISE, 21 | /** 22 | * Rotated clockwise by 135 degrees 23 | */ 24 | CLOCKWISE_135, 25 | /** 26 | * Flipped upside-down, a 180-degree rotation 27 | */ 28 | FLIPPED, 29 | /** 30 | * Flipped upside-down + 45-degree rotation 31 | */ 32 | FLIPPED_45, 33 | /** 34 | * Rotated counter-clockwise by 90 degrees 35 | */ 36 | COUNTER_CLOCKWISE, 37 | /** 38 | * Rotated counter-clockwise by 45 degrees 39 | */ 40 | COUNTER_CLOCKWISE_45; 41 | 42 | } -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/extras/VersionChecker.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.extras; 2 | 3 | import com.github.retrooper.packetevents.manager.server.ServerVersion; 4 | import me.tofaa.entitylib.EntityLib; 5 | 6 | public final class VersionChecker { 7 | 8 | private VersionChecker() {} 9 | 10 | 11 | public static void verifyVersion(ServerVersion version, String message) { 12 | if (!version.isNewerThanOrEquals(EntityLib.getApi().getPacketEvents().getServerManager().getVersion())) { 13 | throw new InvalidVersionException(message); 14 | } 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/extras/skin/CSFBImpl.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.extras.skin; 2 | 3 | import me.tofaa.entitylib.extras.MojangApiError; 4 | 5 | import java.util.function.Consumer; 6 | 7 | final class CSFBImpl implements CachedSkinFetcherBuilder{ 8 | 9 | private Consumer onErr; 10 | private long cacheDuration = -1; 11 | 12 | CSFBImpl(Consumer onErr) { 13 | this.onErr = onErr; 14 | } 15 | 16 | @Override 17 | public CachedSkinFetcherBuilder cacheDuration(long duration) { 18 | this.cacheDuration = duration; 19 | return this; 20 | } 21 | 22 | @Override 23 | public CachedSkinFetcherBuilder cached() { 24 | return this; 25 | } 26 | 27 | @Override 28 | public CachedSkinFetcherBuilder onErr(Consumer onErr) { 29 | this.onErr = onErr; 30 | return this; 31 | } 32 | 33 | @Override 34 | public SkinFetcher build() { 35 | return new CachedSkinFetcherImpl(onErr, cacheDuration); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/extras/skin/CachedSkinFetcherBuilder.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.extras.skin; 2 | 3 | import me.tofaa.entitylib.extras.MojangApiError; 4 | 5 | import java.util.function.Consumer; 6 | 7 | public interface CachedSkinFetcherBuilder extends SkinFetcherBuilder { 8 | 9 | CachedSkinFetcherBuilder cacheDuration(long duration); 10 | 11 | @Override 12 | CachedSkinFetcherBuilder onErr(Consumer onErr); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/extras/skin/ErroredTextureProperties.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.extras.skin; 2 | 3 | import com.github.retrooper.packetevents.protocol.player.TextureProperty; 4 | import me.tofaa.entitylib.extras.MojangApiError; 5 | 6 | import java.util.List; 7 | import java.util.UUID; 8 | 9 | final class ErroredTextureProperties { 10 | 11 | UUID uuid; 12 | private MojangApiError error; 13 | private List textureProperties; 14 | 15 | ErroredTextureProperties(MojangApiError error) { 16 | this.error = error; 17 | } 18 | 19 | ErroredTextureProperties(List textureProperties) { 20 | this.textureProperties = textureProperties; 21 | } 22 | 23 | boolean didError() { 24 | return error != null; 25 | } 26 | 27 | MojangApiError getError() { 28 | return error; 29 | } 30 | 31 | List getTextureProperties() { 32 | return textureProperties; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/extras/skin/SFBImpl.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.extras.skin; 2 | 3 | import me.tofaa.entitylib.extras.MojangApiError; 4 | 5 | import java.util.function.Consumer; 6 | 7 | class SFBImpl implements SkinFetcherBuilder { 8 | 9 | private Consumer rateLimitErrorConsumer; 10 | 11 | @Override 12 | public CachedSkinFetcherBuilder cached() { 13 | return new CSFBImpl(rateLimitErrorConsumer); 14 | } 15 | 16 | @Override 17 | public SkinFetcherBuilder onErr(Consumer onErr) { 18 | this.rateLimitErrorConsumer = onErr; 19 | return this; 20 | } 21 | 22 | @Override 23 | public SkinFetcher build() { 24 | return new SkinFetcherImpl(rateLimitErrorConsumer); 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/extras/skin/SkinFetcher.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.extras.skin; 2 | 3 | import com.github.retrooper.packetevents.protocol.player.TextureProperty; 4 | 5 | import java.util.List; 6 | import java.util.UUID; 7 | 8 | /** 9 | * Represents an interface that fetches the skin of a player. 10 | * This class is non-static, you should create and store an instance of it. 11 | * Creating one should be done using the builder. SkinFetcher is synchronous. You must handle that yourself. 12 | */ 13 | public interface SkinFetcher { 14 | 15 | static SkinFetcherBuilder builder() { 16 | return new SFBImpl(); 17 | } 18 | 19 | 20 | List getSkin(String playerName); 21 | 22 | List getSkin(UUID uuid); 23 | 24 | List getSkinOrDefault(String playerName, List defaults); 25 | 26 | List getSkinOrDefault(UUID uuid, List defaults); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/extras/skin/SkinFetcherBuilder.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.extras.skin; 2 | 3 | import me.tofaa.entitylib.extras.MojangApiError; 4 | 5 | import java.util.function.Consumer; 6 | 7 | public interface SkinFetcherBuilder { 8 | 9 | CachedSkinFetcherBuilder cached(); 10 | 11 | SkinFetcherBuilder onErr(Consumer onErr); 12 | 13 | SkinFetcher build(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/extras/skin/SkinFetcherImpl.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.extras.skin; 2 | 3 | import com.github.retrooper.packetevents.protocol.player.TextureProperty; 4 | import me.tofaa.entitylib.extras.MojangApiError; 5 | 6 | import java.util.Collections; 7 | import java.util.List; 8 | import java.util.UUID; 9 | import java.util.function.Consumer; 10 | 11 | final class SkinFetcherImpl implements SkinFetcher { 12 | 13 | private final Consumer rateLimitErrorConsumer; 14 | 15 | public SkinFetcherImpl(Consumer rateLimitErrorConsumer) { 16 | this.rateLimitErrorConsumer = rateLimitErrorConsumer; 17 | } 18 | 19 | @Override 20 | public List getSkin(String playerName) { 21 | ErroredTextureProperties p = SFUtils.getTextures(playerName); 22 | if (p.didError()) { 23 | rateLimitErrorConsumer.accept(p.getError()); 24 | return Collections.emptyList(); 25 | } 26 | return p.getTextureProperties(); 27 | } 28 | 29 | @Override 30 | public List getSkin(UUID uuid) { 31 | ErroredTextureProperties p = SFUtils.getTextures(uuid); 32 | if (p.didError()) { 33 | rateLimitErrorConsumer.accept(p.getError()); 34 | return Collections.emptyList(); 35 | } 36 | return p.getTextureProperties(); 37 | } 38 | 39 | @Override 40 | public List getSkinOrDefault(String playerName, List defaults) { 41 | ErroredTextureProperties p = SFUtils.getTextures(playerName); 42 | if (p.didError()) { 43 | rateLimitErrorConsumer.accept(p.getError()); 44 | return defaults; 45 | } 46 | return p.getTextureProperties(); 47 | } 48 | 49 | @Override 50 | public List getSkinOrDefault(UUID uuid, List defaults) { 51 | ErroredTextureProperties p = SFUtils.getTextures(uuid); 52 | if (p.didError()) { 53 | rateLimitErrorConsumer.accept(p.getError()); 54 | return defaults; 55 | } 56 | return p.getTextureProperties(); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/display/BlockDisplayMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.display; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | 6 | public class BlockDisplayMeta extends AbstractDisplayMeta { 7 | 8 | public static final byte OFFSET = AbstractDisplayMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = offset(OFFSET, 1); 10 | 11 | public BlockDisplayMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | 15 | public int getBlockId() { 16 | return super.metadata.getIndex(OFFSET, 0); 17 | } 18 | 19 | public void setBlockId(int blockId) { 20 | super.metadata.setIndex(OFFSET, EntityDataTypes.BLOCK_STATE, blockId); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/display/ItemDisplayMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.display; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 5 | import me.tofaa.entitylib.meta.Metadata; 6 | 7 | public class ItemDisplayMeta extends AbstractDisplayMeta { 8 | 9 | public static final byte OFFSET = AbstractDisplayMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = offset(OFFSET, 1); 11 | 12 | public ItemDisplayMeta(int entityId, Metadata metadata) { 13 | super(entityId, metadata); 14 | } 15 | 16 | public ItemStack getItem() { 17 | return super.metadata.getIndex(OFFSET, ItemStack.EMPTY); 18 | } 19 | 20 | public void setItem(ItemStack itemStack) { 21 | super.metadata.setIndex(OFFSET, EntityDataTypes.ITEMSTACK, itemStack); 22 | } 23 | 24 | public DisplayType getDisplayType() { 25 | return DisplayType.VALUES[super.metadata.getIndex(offset(OFFSET, 1), (byte) 0)]; 26 | } 27 | 28 | public void setDisplayType(DisplayType displayType) { 29 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BYTE, (byte) displayType.ordinal()); 30 | } 31 | 32 | public enum DisplayType { 33 | NONE, 34 | THIRD_PERSON_LEFT_HAND, 35 | THIRD_PERSON_RIGHT_HAND, 36 | FIRST_PERSON_LEFT_HAND, 37 | FIRST_PERSON_RIGHT_HAND, 38 | HEAD, 39 | GUI, 40 | GROUND, 41 | FIXED; 42 | 43 | private static final DisplayType[] VALUES = values(); 44 | } 45 | 46 | } 47 | 48 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/BatMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | import me.tofaa.entitylib.meta.types.MobMeta; 5 | 6 | public class BatMeta extends MobMeta { 7 | 8 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 0; 10 | 11 | private final static byte IS_HANGING_BIT = 0x01; 12 | 13 | public BatMeta(int entityId, Metadata metadata) { 14 | super(entityId, metadata); 15 | } 16 | 17 | public boolean isHanging() { 18 | return getMaskBit(OFFSET, IS_HANGING_BIT); 19 | } 20 | 21 | public void setHanging(boolean value) { 22 | setMaskBit(OFFSET, IS_HANGING_BIT, value); 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/BeeMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.AgeableMeta; 6 | 7 | public class BeeMeta extends AgeableMeta { 8 | 9 | public static final byte OFFSET = AgeableMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 2; 11 | 12 | private final static byte ANGRY_BIT = 0x02; 13 | private final static byte HAS_STUNG_BIT = 0x04; 14 | private final static byte HAS_NECTAR_BIT = 0x08; 15 | 16 | public BeeMeta(int entityId, Metadata metadata) { 17 | super(entityId, metadata); 18 | } 19 | 20 | public boolean isAngry() { 21 | return getMaskBit(OFFSET, ANGRY_BIT); 22 | } 23 | 24 | public void setAngry(boolean value) { 25 | setMaskBit(OFFSET, ANGRY_BIT, value); 26 | } 27 | 28 | public boolean hasStung() { 29 | return getMaskBit(OFFSET, HAS_STUNG_BIT); 30 | } 31 | 32 | public void setHasStung(boolean value) { 33 | setMaskBit(OFFSET, HAS_STUNG_BIT, value); 34 | } 35 | 36 | public boolean hasNectar() { 37 | return getMaskBit(OFFSET, HAS_NECTAR_BIT); 38 | } 39 | 40 | public void setHasNectar(boolean value) { 41 | setMaskBit(OFFSET, HAS_NECTAR_BIT, value); 42 | } 43 | 44 | public int getAngerTicks() { 45 | return super.metadata.getIndex(offset(OFFSET,1), 0); 46 | } 47 | 48 | public void setAngerTicks(int value) { 49 | super.metadata.setIndex(offset(OFFSET,1), EntityDataTypes.INT, value); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/DonkeyMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | import me.tofaa.entitylib.meta.types.AgeableMeta; 5 | 6 | public class DonkeyMeta extends AgeableMeta { 7 | 8 | public static final byte OFFSET = AgeableMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 0; 10 | 11 | public DonkeyMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/FrogMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.AgeableMeta; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import java.util.Optional; 9 | 10 | public class FrogMeta extends AgeableMeta { 11 | 12 | public static final byte OFFSET = AgeableMeta.MAX_OFFSET; 13 | public static final byte MAX_OFFSET = OFFSET + 2; 14 | 15 | 16 | public FrogMeta(int entityId, Metadata metadata) { 17 | super(entityId, metadata); 18 | } 19 | 20 | 21 | public @NotNull Variant getVariant() { 22 | return super.metadata.getIndex(OFFSET, Variant.TEMPERATE); 23 | } 24 | 25 | public void setVariant(@NotNull Variant value) { 26 | super.metadata.setIndex(OFFSET, EntityDataTypes.FROG_VARIANT, value.ordinal()); 27 | } 28 | 29 | public Optional getTongueTarget() { 30 | return super.metadata.getIndex(offset(OFFSET, 1), Optional.empty()); 31 | } 32 | 33 | public void setTongueTarget(int value) { 34 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.OPTIONAL_INT, Optional.of(value)); 35 | } 36 | 37 | 38 | public enum Variant { 39 | TEMPERATE, 40 | WARM, 41 | COLD; 42 | 43 | private final static FrogMeta.Variant[] VALUES = values(); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/GoatMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.AgeableMeta; 6 | 7 | public class GoatMeta extends AgeableMeta { 8 | 9 | public static final byte OFFSET = AgeableMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 1; 11 | 12 | 13 | public GoatMeta(int entityId, Metadata metadata) { 14 | super(entityId, metadata); 15 | } 16 | 17 | public boolean isScreaming() { 18 | return metadata.getIndex(OFFSET, false); 19 | } 20 | 21 | public void setScreaming(boolean screaming) { 22 | metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, screaming); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/HoglinMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.AgeableMeta; 6 | 7 | public class HoglinMeta extends AgeableMeta { 8 | 9 | public static final byte OFFSET = AgeableMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 1; 11 | 12 | public HoglinMeta(int entityId, Metadata metadata) { 13 | super(entityId, metadata); 14 | } 15 | 16 | 17 | public boolean isImmuneToZombification() { 18 | return super.metadata.getIndex(OFFSET, false); 19 | } 20 | 21 | public void setImmuneToZombification(boolean value) { 22 | super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value); 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/OcelotMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs; 2 | 3 | import com.github.retrooper.packetevents.manager.server.ServerVersion; 4 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 5 | import me.tofaa.entitylib.meta.Metadata; 6 | import me.tofaa.entitylib.meta.types.AgeableMeta; 7 | 8 | public class OcelotMeta extends AgeableMeta { 9 | 10 | public static final byte OFFSET = AgeableMeta.MAX_OFFSET; 11 | public static final byte MAX_OFFSET = OFFSET + 1; 12 | 13 | public OcelotMeta(int entityId, Metadata metadata) { 14 | super(entityId, metadata); 15 | } 16 | 17 | public boolean isTrusting() { 18 | isVersionNewer(ServerVersion.V_1_14); 19 | return super.metadata.getIndex(OFFSET, false); 20 | } 21 | 22 | public void setTrusting(boolean value) { 23 | isVersionNewer(ServerVersion.V_1_14); 24 | super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/PolarBearMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.AgeableMeta; 6 | 7 | public class PolarBearMeta extends AgeableMeta { 8 | 9 | public static final byte OFFSET = AgeableMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 1; 11 | 12 | public PolarBearMeta(int entityId, Metadata metadata) { 13 | super(entityId, metadata); 14 | } 15 | 16 | public boolean isStandingUp() { 17 | return super.metadata.getIndex(OFFSET, false); 18 | } 19 | 20 | public void setStandingUp(boolean value) { 21 | super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/SnifferMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import com.github.retrooper.packetevents.protocol.entity.sniffer.SnifferState; 5 | import me.tofaa.entitylib.meta.Metadata; 6 | import me.tofaa.entitylib.meta.types.AgeableMeta; 7 | 8 | public class SnifferMeta extends AgeableMeta { 9 | 10 | public static final byte OFFSET = AgeableMeta.MAX_OFFSET; 11 | public static final byte MAX_OFFSET = OFFSET + 1; 12 | 13 | public SnifferMeta(int entityId, Metadata metadata) { 14 | super(entityId, metadata); 15 | } 16 | 17 | public SnifferState getState() { 18 | return metadata.getIndex(OFFSET, SnifferState.IDLING); 19 | } 20 | 21 | public void setState(SnifferState state) { 22 | super.metadata.setIndex(OFFSET, EntityDataTypes.SNIFFER_STATE, state); 23 | } 24 | 25 | public int getDropSeedAtTick() { 26 | return metadata.getIndex(offset(OFFSET, 1), 0); 27 | } 28 | 29 | public void setDropSeedAtTick(int tick) { 30 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.INT, tick); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/StriderMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.AgeableMeta; 6 | 7 | public class StriderMeta extends AgeableMeta { 8 | 9 | public static final byte OFFSET = AgeableMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 3; 11 | 12 | public StriderMeta(int entityId, Metadata metadata) { 13 | super(entityId, metadata); 14 | } 15 | 16 | 17 | public int getTimeToBoost() { 18 | return super.metadata.getIndex(OFFSET, 0); 19 | } 20 | 21 | public void setTimeToBoost(int value) { 22 | super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value); 23 | } 24 | 25 | public boolean isShaking() { 26 | return super.metadata.getIndex(offset(OFFSET,1), false); 27 | } 28 | 29 | public void setShaking(boolean value) { 30 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BOOLEAN, value); 31 | } 32 | 33 | public boolean isHasSaddle() { 34 | return super.metadata.getIndex(offset(OFFSET, 2), false); 35 | } 36 | 37 | public void setHasSaddle(boolean value) { 38 | super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, value); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/cuboid/MagmaCubeMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.cuboid; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class MagmaCubeMeta extends SlimeMeta { 6 | 7 | public static final byte OFFSET = SlimeMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | public MagmaCubeMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/cuboid/SlimeMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.cuboid; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.MobMeta; 6 | 7 | public class SlimeMeta extends MobMeta { 8 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 1; 10 | 11 | public SlimeMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | 15 | public int getSize() { 16 | return super.metadata.getIndex(OFFSET, 0); 17 | } 18 | 19 | public void setSize(int value) { 20 | super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/golem/IronGolemMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.golem; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | import me.tofaa.entitylib.meta.types.MobMeta; 5 | 6 | public class IronGolemMeta extends MobMeta { 7 | 8 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 1; 10 | 11 | private final static byte PLAYER_CREATED_BIT = 0x01; 12 | 13 | public IronGolemMeta(int entityId, Metadata metadata) { 14 | super(entityId, metadata); 15 | } 16 | 17 | public boolean isPlayerCreated() { 18 | return getMaskBit(OFFSET, PLAYER_CREATED_BIT); 19 | } 20 | 21 | public void setPlayerCreated(boolean value) { 22 | setMaskBit(OFFSET, PLAYER_CREATED_BIT, value); 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/golem/ShulkerMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.golem; 2 | 3 | import com.github.retrooper.packetevents.protocol.color.DyeColor; 4 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 5 | import com.github.retrooper.packetevents.protocol.world.Direction; 6 | import com.github.retrooper.packetevents.util.Vector3i; 7 | import me.tofaa.entitylib.meta.Metadata; 8 | import me.tofaa.entitylib.meta.types.MobMeta; 9 | import net.kyori.adventure.text.format.NamedTextColor; 10 | 11 | import java.util.Optional; 12 | 13 | public class ShulkerMeta extends MobMeta { 14 | 15 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 16 | public static final byte MAX_OFFSET = OFFSET + 1; 17 | 18 | private static final DyeColor[] DYE_COLORS = DyeColor.values(); 19 | 20 | 21 | public ShulkerMeta(int entityId, Metadata metadata) { 22 | super(entityId, metadata); 23 | } 24 | 25 | public Direction getAttachFace() { 26 | return super.metadata.getIndex((byte)16, Direction.DOWN); 27 | } 28 | 29 | public void setAttachFace(Direction value) { 30 | super.metadata.setIndex((byte)16, EntityDataTypes.INT, value.ordinal()); 31 | } 32 | 33 | public byte getShieldHeight() { 34 | return super.metadata.getIndex(offset(OFFSET, 1), (byte) 0); 35 | } 36 | 37 | public void setShieldHeight(byte value) { 38 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BYTE, value); 39 | } 40 | 41 | public byte getColor() { 42 | return super.metadata.getIndex(offset(OFFSET, 2), (byte) 16); 43 | } 44 | 45 | public DyeColor getColorEnum() { 46 | return DYE_COLORS[getColor()]; 47 | } 48 | 49 | public void setColor(byte value) { 50 | super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BYTE, value); 51 | } 52 | 53 | public void setColor(DyeColor color) { 54 | setColor((byte)color.ordinal()); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/golem/SnowGolemMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.golem; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.MobMeta; 6 | 7 | public class SnowGolemMeta extends MobMeta { 8 | 9 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 1; 11 | 12 | public SnowGolemMeta(int entityId, Metadata metadata) { 13 | super(entityId, metadata); 14 | } 15 | 16 | public boolean isHasPumpkinHat() { 17 | return super.metadata.getIndex(OFFSET, (byte) 0x10) == (byte) 0x10; 18 | } 19 | 20 | public void setHasPumpkinHat(boolean value) { 21 | byte var = value ? (byte) 0x10 : (byte) 0x00; 22 | super.metadata.setIndex(OFFSET, EntityDataTypes.BYTE, var); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/horse/BaseHorseMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.horse; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | import me.tofaa.entitylib.meta.types.AgeableMeta; 5 | 6 | public abstract class BaseHorseMeta extends AgeableMeta { 7 | 8 | public static final byte OFFSET = AgeableMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 1; 10 | 11 | private final static byte TAMED_BIT = 0x02; 12 | private final static byte SADDLED_BIT = 0x04; 13 | private final static byte HAS_BRED_BIT = 0x08; 14 | private final static byte EATING_BIT = 0x10; 15 | private final static byte REARING_BIT = 0x20; 16 | private final static byte MOUTH_OPEN_BIT = 0x40; 17 | 18 | protected BaseHorseMeta(int entityId, Metadata metadata) { 19 | super(entityId, metadata); 20 | } 21 | 22 | public boolean isTamed() { 23 | return getMaskBit(OFFSET, TAMED_BIT); 24 | } 25 | 26 | public void setTamed(boolean value) { 27 | setMaskBit(OFFSET, TAMED_BIT, value); 28 | } 29 | 30 | public boolean isSaddled() { 31 | return getMaskBit(OFFSET, SADDLED_BIT); 32 | } 33 | 34 | public void setSaddled(boolean value) { 35 | setMaskBit(OFFSET, SADDLED_BIT, value); 36 | } 37 | 38 | public boolean isHasBred() { 39 | return getMaskBit(OFFSET, HAS_BRED_BIT); 40 | } 41 | 42 | public void setHasBred(boolean value) { 43 | setMaskBit(OFFSET, HAS_BRED_BIT, value); 44 | } 45 | 46 | public boolean isEating() { 47 | return getMaskBit(OFFSET, EATING_BIT); 48 | } 49 | 50 | public void setEating(boolean value) { 51 | setMaskBit(OFFSET, EATING_BIT, value); 52 | } 53 | 54 | public boolean isRearing() { 55 | return getMaskBit(OFFSET, REARING_BIT); 56 | } 57 | 58 | public void setRearing(boolean value) { 59 | setMaskBit(OFFSET, REARING_BIT, value); 60 | } 61 | 62 | public boolean isMouthOpen() { 63 | return getMaskBit(OFFSET, MOUTH_OPEN_BIT); 64 | } 65 | 66 | public void setMouthOpen(boolean value) { 67 | setMaskBit(OFFSET, MOUTH_OPEN_BIT, value); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/horse/CamelMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.horse; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | 6 | public class CamelMeta extends BaseHorseMeta { 7 | 8 | public static final byte OFFSET = BaseHorseMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 2; 10 | 11 | public CamelMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | 15 | public boolean isDashing() { 16 | return super.metadata.getIndex(OFFSET, false); 17 | } 18 | 19 | public void setDashing(boolean value) { 20 | super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value); 21 | } 22 | 23 | public long getLastPoseChangeTick() { 24 | return super.metadata.getIndex(offset(OFFSET, 1), 0L); 25 | } 26 | 27 | public void setLastPoseChangeTick(long value) { 28 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.LONG, value); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/horse/ChestedHorseMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.horse; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | 6 | public class ChestedHorseMeta extends BaseHorseMeta { 7 | 8 | public static final byte OFFSET = BaseHorseMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 1; 10 | 11 | public ChestedHorseMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | 15 | public boolean isHasChest() { 16 | return super.metadata.getIndex(OFFSET, false); 17 | } 18 | 19 | public void setHasChest(boolean value) { 20 | super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value); 21 | } 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/horse/DonkeyMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.horse; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | import me.tofaa.entitylib.meta.types.MobMeta; 5 | 6 | public class DonkeyMeta extends ChestedHorseMeta{ 7 | 8 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 0; 10 | 11 | public DonkeyMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/horse/LlamaMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.horse; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | 6 | public class LlamaMeta extends ChestedHorseMeta{ 7 | 8 | public static final byte OFFSET = ChestedHorseMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 3; 10 | 11 | public LlamaMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | 15 | public int getStrength() { 16 | return super.metadata.getIndex(OFFSET, 0); 17 | } 18 | 19 | public void setStrength(int value) { 20 | super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value); 21 | } 22 | 23 | public int getCarpetColor() { 24 | return super.metadata.getIndex(offset(OFFSET, 1), -1); 25 | } 26 | 27 | public void setCarpetColor(int value) { 28 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.INT, value); 29 | } 30 | 31 | public Variant getVariant() { 32 | return Variant.VALUES[super.metadata.getIndex(offset(OFFSET, 2), 0)]; 33 | } 34 | 35 | public void setVariant(Variant value) { 36 | super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.INT, value.ordinal()); 37 | } 38 | 39 | public enum Variant { 40 | CREAMY, 41 | WHITE, 42 | BROWN, 43 | GRAY; 44 | 45 | private final static Variant[] VALUES = values(); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/horse/MuleMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.horse; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class MuleMeta extends ChestedHorseMeta{ 6 | 7 | public static final byte OFFSET = ChestedHorseMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | public MuleMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/horse/SkeletonHorseMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.horse; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class SkeletonHorseMeta extends BaseHorseMeta { 6 | 7 | public static final byte OFFSET = BaseHorseMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | public SkeletonHorseMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/horse/TraderLlamaMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.horse; 2 | 3 | import me.tofaa.entitylib.meta.EntityMeta; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | 6 | public class TraderLlamaMeta extends EntityMeta { 7 | 8 | public static final byte OFFSET = EntityMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 0; 10 | 11 | public TraderLlamaMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/horse/ZombieHorseMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.horse; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class ZombieHorseMeta extends BaseHorseMeta { 6 | 7 | public static final byte OFFSET = BaseHorseMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | public ZombieHorseMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/minecart/BaseMinecartMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.minecart; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.EntityMeta; 5 | import me.tofaa.entitylib.meta.Metadata; 6 | import me.tofaa.entitylib.meta.types.ObjectData; 7 | 8 | public abstract class BaseMinecartMeta extends EntityMeta implements ObjectData { 9 | 10 | public static final byte OFFSET = EntityMeta.MAX_OFFSET; 11 | public static final byte MAX_OFFSET = OFFSET + 6; 12 | 13 | protected BaseMinecartMeta(int entityId, Metadata metadata) { 14 | super(entityId, metadata); 15 | } 16 | 17 | public int getShakingPower() { 18 | return super.metadata.getIndex(OFFSET, 0); 19 | } 20 | 21 | public void setShakingPower(int value) { 22 | super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value); 23 | } 24 | 25 | public int getShakingDirection() { 26 | return super.metadata.getIndex(offset(OFFSET, 1), 1); 27 | } 28 | 29 | public void setShakingDirection(int value) { 30 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.INT, value); 31 | } 32 | 33 | public float getShakingMultiplier() { 34 | return super.metadata.getIndex(offset(OFFSET, 2), 0F); 35 | } 36 | 37 | public void setShakingMultiplier(float value) { 38 | super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.FLOAT, value); 39 | } 40 | 41 | public int getCustomBlockIdAndDamage() { 42 | return super.metadata.getIndex(offset(OFFSET, 3), 0); 43 | } 44 | 45 | public void setCustomBlockIdAndDamage(int value) { 46 | super.metadata.setIndex(offset(OFFSET, 3), EntityDataTypes.INT, value); 47 | } 48 | 49 | // in 16th of a block 50 | public int getCustomBlockYPosition() { 51 | return super.metadata.getIndex(offset(OFFSET, 4), 6); 52 | } 53 | 54 | public void setCustomBlockYPosition(int value) { 55 | super.metadata.setIndex(offset(OFFSET, 4), EntityDataTypes.INT, value); 56 | } 57 | 58 | @Override 59 | public boolean requiresVelocityPacketAtSpawn() { 60 | return true; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/minecart/ChestMinecartMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.minecart; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class ChestMinecartMeta extends BaseMinecartMeta{ 6 | 7 | public static final byte OFFSET = BaseMinecartMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | 11 | public ChestMinecartMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | 15 | @Override 16 | public int getObjectData() { 17 | return 1; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/minecart/CommandBlockMinecartMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.minecart; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import net.kyori.adventure.text.Component; 6 | import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | public class CommandBlockMinecartMeta extends BaseMinecartMeta{ 10 | 11 | public static final byte OFFSET = BaseMinecartMeta.MAX_OFFSET; 12 | public static final byte MAX_OFFSET = OFFSET + 2; 13 | 14 | public CommandBlockMinecartMeta(int entityId, Metadata metadata) { 15 | super(entityId, metadata); 16 | } 17 | 18 | public @NotNull String getCommand() { 19 | return super.metadata.getIndex(OFFSET, ""); 20 | } 21 | 22 | public void setCommand(@NotNull String value) { 23 | super.metadata.setIndex(OFFSET, EntityDataTypes.STRING, value); 24 | } 25 | 26 | public @NotNull Component getLastOutput() { 27 | return super.metadata.getIndex(offset(OFFSET, 1), Component.empty()); 28 | } 29 | 30 | public void setLastOutput(@NotNull Component value) { 31 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.COMPONENT, GsonComponentSerializer.gson().serialize(value)); 32 | } 33 | 34 | @Override 35 | public int getObjectData() { 36 | return 6; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/minecart/FurnaceMinecartMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.minecart; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | 6 | public class FurnaceMinecartMeta extends BaseMinecartMeta { 7 | 8 | public static final byte OFFSET = BaseMinecartMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 1; 10 | 11 | public FurnaceMinecartMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | 15 | public boolean isHasFuel() { 16 | return super.metadata.getIndex(OFFSET, false); 17 | } 18 | 19 | public void setHasFuel(boolean value) { 20 | super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value); 21 | } 22 | 23 | @Override 24 | public int getObjectData() { 25 | return 2; } 26 | } 27 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/minecart/HopperMinecartMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.minecart; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class HopperMinecartMeta extends BaseMinecartMeta { 6 | 7 | public static final byte OFFSET = BaseMinecartMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | public HopperMinecartMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | 14 | @Override 15 | public int getObjectData() { 16 | return 5; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/minecart/MinecartMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.minecart; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class MinecartMeta extends BaseMinecartMeta { 6 | 7 | public static final byte OFFSET = BaseMinecartMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | public MinecartMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | 14 | @Override 15 | public int getObjectData() { 16 | return 0; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/minecart/SpawnerMinecartMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.minecart; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class SpawnerMinecartMeta extends BaseMinecartMeta { 6 | 7 | public static final byte OFFSET = BaseMinecartMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | public SpawnerMinecartMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | 14 | @Override 15 | public int getObjectData() { 16 | return 4; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/minecart/TntMinecartMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.minecart; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class TntMinecartMeta extends BaseMinecartMeta{ 6 | 7 | public static final byte OFFSET = BaseMinecartMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | public TntMinecartMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | 14 | @Override 15 | public int getObjectData() { 16 | return 3; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/BlazeMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | import me.tofaa.entitylib.meta.types.MobMeta; 5 | 6 | public class BlazeMeta extends MobMeta { 7 | 8 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 1; 10 | 11 | private final static byte ON_FIRE_BIT = 0x01; 12 | 13 | public BlazeMeta(int entityId, Metadata metadata) { 14 | super(entityId, metadata); 15 | } 16 | 17 | public boolean isOnFire() { 18 | return getMaskBit(OFFSET, ON_FIRE_BIT); 19 | } 20 | 21 | public void setOnFire(boolean value) { 22 | setMaskBit(OFFSET, ON_FIRE_BIT, value); 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/BreezeMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | import me.tofaa.entitylib.meta.types.MobMeta; 5 | 6 | public class BreezeMeta extends MobMeta { 7 | 8 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 0; 10 | 11 | public BreezeMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/CaveSpiderMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class CaveSpiderMeta extends SpiderMeta{ 6 | 7 | public static final byte OFFSET = SpiderMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | public CaveSpiderMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/CreeperMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.MobMeta; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class CreeperMeta extends MobMeta { 9 | 10 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 11 | public static final byte MAX_OFFSET = OFFSET + 3; 12 | 13 | public CreeperMeta(int entityId, Metadata metadata) { 14 | super(entityId, metadata); 15 | } 16 | 17 | @NotNull 18 | public State getState() { 19 | int id = super.metadata.getIndex(OFFSET, -1); 20 | return id == -1 ? State.IDLE : State.FUSE; 21 | } 22 | 23 | public void setState(@NotNull State value) { 24 | super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value == State.IDLE ? -1 : 1); 25 | } 26 | 27 | public boolean isCharged() { 28 | return super.metadata.getIndex(offset(OFFSET, 1), false); 29 | } 30 | 31 | public void setCharged(boolean value) { 32 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BOOLEAN, value); 33 | } 34 | 35 | public boolean isIgnited() { 36 | return super.metadata.getIndex(offset(OFFSET, 2), false); 37 | } 38 | 39 | public void setIgnited(boolean value) { 40 | super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, value); 41 | } 42 | 43 | public enum State { 44 | IDLE, 45 | FUSE 46 | } 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/ElderGuardianMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class ElderGuardianMeta extends GuardianMeta{ 6 | 7 | public static final byte OFFSET = GuardianMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | public ElderGuardianMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/EndermanMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.MobMeta; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | import java.util.Optional; 9 | 10 | public class EndermanMeta extends MobMeta { 11 | 12 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 13 | public static final byte MAX_OFFSET = OFFSET + 3; 14 | 15 | public EndermanMeta(int entityId, Metadata metadata) { 16 | super(entityId, metadata); 17 | } 18 | 19 | public Integer getCarriedBlockID() { 20 | return super.metadata.getIndex(OFFSET, null); 21 | } 22 | 23 | public void setCarriedBlockID(@Nullable Integer value) { 24 | super.metadata.setIndex(OFFSET, EntityDataTypes.OPTIONAL_INT, Optional.ofNullable(value)); 25 | } 26 | 27 | public boolean isScreaming() { 28 | return super.metadata.getIndex(offset(OFFSET, 1), false); 29 | } 30 | 31 | public void setScreaming(boolean value) { 32 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BOOLEAN, value); 33 | } 34 | 35 | public boolean isStaring() { 36 | return super.metadata.getIndex(offset(OFFSET, 2), false); 37 | } 38 | 39 | public void setStaring(boolean value) { 40 | super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, value); 41 | } 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/EndermiteMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | import me.tofaa.entitylib.meta.types.MobMeta; 5 | 6 | public class EndermiteMeta extends MobMeta { 7 | 8 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 0; 10 | 11 | public EndermiteMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/GhastMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.MobMeta; 6 | 7 | public class GhastMeta extends MobMeta { 8 | 9 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 1; 11 | 12 | public GhastMeta(int entityId, Metadata metadata) { 13 | super(entityId, metadata); 14 | } 15 | 16 | 17 | public boolean isAttacking() { 18 | return super.metadata.getIndex(OFFSET, false); 19 | } 20 | 21 | public void setAttacking(boolean value) { 22 | super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/GiantMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | import me.tofaa.entitylib.meta.types.MobMeta; 5 | 6 | public class GiantMeta extends MobMeta { 7 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | public GiantMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/GuardianMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.MobMeta; 6 | 7 | public class GuardianMeta extends MobMeta { 8 | 9 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 2; 11 | 12 | private int target = -1; 13 | 14 | public GuardianMeta(int entityId, Metadata metadata) { 15 | super(entityId, metadata); 16 | } 17 | 18 | public boolean isRetractingSpikes() { 19 | return super.metadata.getIndex(OFFSET, false); 20 | } 21 | 22 | public void setRetractingSpikes(boolean retractingSpikes) { 23 | super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, retractingSpikes); 24 | } 25 | 26 | public int getTarget() { 27 | return this.target; 28 | } 29 | 30 | public void setTarget(int target) { 31 | this.target = target; 32 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.INT, target == -1 ? 0 : target); 33 | } 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/PhantomMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.MobMeta; 6 | 7 | public class PhantomMeta extends MobMeta { 8 | 9 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 1; 11 | 12 | public PhantomMeta(int entityId, Metadata metadata) { 13 | super(entityId, metadata); 14 | } 15 | 16 | public int getSize() { 17 | return super.metadata.getIndex(OFFSET, 0); 18 | } 19 | 20 | public void setSize(int value) { 21 | super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/SilverfishMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | import me.tofaa.entitylib.meta.types.MobMeta; 5 | 6 | public class SilverfishMeta extends MobMeta { 7 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | 11 | public SilverfishMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/SpiderMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | import me.tofaa.entitylib.meta.types.MobMeta; 5 | 6 | public class SpiderMeta extends MobMeta { 7 | 8 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 1; 10 | 11 | private final static byte CLIMBING_BIT = 0x01; 12 | 13 | 14 | public SpiderMeta(int entityId, Metadata metadata) { 15 | super(entityId, metadata); 16 | } 17 | 18 | public boolean isClimbing() { 19 | return getMaskBit(OFFSET, CLIMBING_BIT); 20 | } 21 | 22 | public void setClimbing(boolean value) { 23 | setMaskBit(OFFSET, CLIMBING_BIT, value); 24 | } 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/VexMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | import me.tofaa.entitylib.meta.types.MobMeta; 5 | 6 | public class VexMeta extends MobMeta { 7 | 8 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 1; 10 | 11 | private final static byte ATTACKING_BIT = 0x01; 12 | 13 | public VexMeta(int entityId, Metadata metadata) { 14 | super(entityId, metadata); 15 | } 16 | 17 | public boolean isAttacking() { 18 | return getMaskBit(OFFSET, ATTACKING_BIT); 19 | } 20 | 21 | public void setAttacking(boolean value) { 22 | setMaskBit(OFFSET, ATTACKING_BIT, value); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/WardenMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.MobMeta; 6 | 7 | public class WardenMeta extends MobMeta { 8 | 9 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 1; 11 | 12 | public WardenMeta(int entityId, Metadata metadata) { 13 | super(entityId, metadata); 14 | } 15 | 16 | public int getAngerLevel() { 17 | return super.metadata.getIndex(OFFSET, 0); 18 | } 19 | 20 | public void setAngerLevel(int value) { 21 | if (getAngerLevel() == value) { 22 | return; 23 | } 24 | super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/WitherMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.MobMeta; 6 | 7 | public class WitherMeta extends MobMeta { 8 | 9 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 4; 11 | 12 | private int centerHead = -1; 13 | private int leftHead = -1; 14 | private int rightHead = -1; 15 | 16 | public WitherMeta(int entityId, Metadata metadata) { 17 | super(entityId, metadata); 18 | } 19 | 20 | public void setCenterHead(int centerHead) { 21 | this.centerHead = centerHead; 22 | super.metadata.setIndex(offset(OFFSET,0), EntityDataTypes.INT, centerHead == -1 ? 0 : centerHead); 23 | } 24 | 25 | public void setLeftHead(int leftHead) { 26 | this.leftHead = leftHead; 27 | super.metadata.setIndex(offset(OFFSET,1), EntityDataTypes.INT, leftHead == -1 ? 0 : leftHead); 28 | } 29 | 30 | public void setRightHead(int rightHead) { 31 | this.rightHead = rightHead; 32 | super.metadata.setIndex(offset(OFFSET,2), EntityDataTypes.INT, rightHead == -1 ? 0 : rightHead); 33 | } 34 | 35 | public int getCenterHead() { 36 | return centerHead; 37 | } 38 | 39 | public int getLeftHead() { 40 | return leftHead; 41 | } 42 | 43 | public int getRightHead() { 44 | return rightHead; 45 | } 46 | 47 | public int getInvulnerableTime() { 48 | return super.metadata.getIndex(offset(OFFSET, 3), 0); 49 | } 50 | 51 | public void setInvulnerableTime(int value) { 52 | super.metadata.setIndex(offset(OFFSET, 3), EntityDataTypes.INT, value); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/ZoglinMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.MobMeta; 6 | 7 | public class ZoglinMeta extends MobMeta { 8 | 9 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 1; 11 | 12 | public ZoglinMeta(int entityId, Metadata metadata) { 13 | super(entityId, metadata); 14 | } 15 | 16 | 17 | public boolean isBaby() { 18 | return super.metadata.getIndex(OFFSET, false); 19 | } 20 | 21 | public void setBaby(boolean value) { 22 | if (isBaby() == value) { 23 | return; 24 | } 25 | super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/piglin/BasePiglinMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster.piglin; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.MobMeta; 6 | 7 | public abstract class BasePiglinMeta extends MobMeta { 8 | 9 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 1; 11 | 12 | protected BasePiglinMeta(int entityId, Metadata metadata) { 13 | super(entityId, metadata); 14 | } 15 | 16 | public boolean isImmuneToZombification() { 17 | return super.metadata.getIndex(OFFSET, false); 18 | } 19 | 20 | public void setImmuneToZombification(boolean value) { 21 | super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value); 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/piglin/PiglinBruteMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster.piglin; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class PiglinBruteMeta extends BasePiglinMeta{ 6 | 7 | public static final byte OFFSET = BasePiglinMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | public PiglinBruteMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/piglin/PiglinMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster.piglin; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | 6 | public class PiglinMeta extends BasePiglinMeta{ 7 | 8 | public static final byte OFFSET = BasePiglinMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 3; 10 | 11 | public PiglinMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | 15 | public boolean isBaby() { 16 | return super.metadata.getIndex(OFFSET, false); 17 | } 18 | 19 | public void setBaby(boolean value) { 20 | if (isBaby() == value) { 21 | return; 22 | } 23 | super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value); 24 | } 25 | 26 | public boolean isChargingCrossbow() { 27 | return super.metadata.getIndex(offset(OFFSET, 1), false); 28 | } 29 | 30 | public void setChargingCrossbow(boolean value) { 31 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BOOLEAN, value); 32 | } 33 | 34 | public boolean isDancing() { 35 | return super.metadata.getIndex(offset(OFFSET, 2), false); 36 | } 37 | 38 | public void setDancing(boolean value) { 39 | super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, value); 40 | } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/raider/EvokerMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster.raider; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class EvokerMeta extends SpellcasterIllagerMeta { 6 | 7 | public static final byte OFFSET = SpellcasterIllagerMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | public EvokerMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/raider/IllusionerMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster.raider; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class IllusionerMeta extends SpellcasterIllagerMeta { 6 | 7 | public static final byte OFFSET = SpellcasterIllagerMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | public IllusionerMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/raider/PillagerMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster.raider; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class PillagerMeta extends RaiderMeta{ 6 | 7 | public static final byte OFFSET = RaiderMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | 11 | public PillagerMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/raider/RaiderMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster.raider; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.MobMeta; 6 | 7 | public class RaiderMeta extends MobMeta { 8 | 9 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 1; 11 | 12 | public RaiderMeta(int entityId, Metadata metadata) { 13 | super(entityId, metadata); 14 | } 15 | 16 | public boolean isCelebrating() { 17 | return super.metadata.getIndex(OFFSET, false); 18 | } 19 | 20 | public void setCelebrating(boolean value) { 21 | super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value); 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/raider/RavagerMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster.raider; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class RavagerMeta extends RaiderMeta { 6 | 7 | public static final byte OFFSET = RaiderMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | 11 | public RavagerMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/raider/SpellcasterIllagerMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster.raider; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class SpellcasterIllagerMeta extends RaiderMeta{ 6 | 7 | public static final byte OFFSET = RaiderMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 1; 9 | 10 | public SpellcasterIllagerMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/raider/VindicatorMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster.raider; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class VindicatorMeta extends RaiderMeta{ 6 | 7 | public static final byte OFFSET = RaiderMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | public VindicatorMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/raider/WitchMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster.raider; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | 6 | public class WitchMeta extends RaiderMeta { 7 | 8 | public static final byte OFFSET = RaiderMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 1; 10 | 11 | public WitchMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | 15 | public boolean isDrinkingPotion() { 16 | return super.metadata.getIndex(OFFSET, false); 17 | } 18 | 19 | public void setDrinkingPotion(boolean value) { 20 | super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/skeleton/BoggedMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster.skeleton; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class BoggedMeta extends SkeletonMeta { 6 | 7 | public BoggedMeta(int entityId, Metadata metadata) { 8 | super(entityId, metadata); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/skeleton/SkeletonMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster.skeleton; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | import me.tofaa.entitylib.meta.types.MobMeta; 5 | 6 | public class SkeletonMeta extends MobMeta { 7 | 8 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 0; 10 | 11 | public SkeletonMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/skeleton/StrayMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster.skeleton; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class StrayMeta extends SkeletonMeta{ 6 | 7 | 8 | public StrayMeta(int entityId, Metadata metadata) { 9 | super(entityId, metadata); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/skeleton/WitherSkeletonMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster.skeleton; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class WitherSkeletonMeta extends SkeletonMeta { 6 | public static final byte OFFSET = SkeletonMeta.MAX_OFFSET; 7 | public static final byte MAX_OFFSET = OFFSET + 0; 8 | 9 | public WitherSkeletonMeta(int entityId, Metadata metadata) { 10 | super(entityId, metadata); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/zombie/DrownedMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster.zombie; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class DrownedMeta extends ZombieMeta { 6 | 7 | public static final byte OFFSET = ZombieMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | public DrownedMeta(int entityId, Metadata metadata) { 10 | super(entityId, metadata); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/zombie/HuskMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster.zombie; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class HuskMeta extends ZombieMeta { 6 | 7 | public static final byte OFFSET = ZombieMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | public HuskMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/zombie/ZombieMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster.zombie; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.MobMeta; 6 | 7 | public class ZombieMeta extends MobMeta { 8 | 9 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 3; 11 | 12 | public ZombieMeta(int entityId, Metadata metadata) { 13 | super(entityId, metadata); 14 | } 15 | 16 | public boolean isBaby() { 17 | return super.metadata.getIndex(OFFSET, false); 18 | } 19 | 20 | public void setBaby(boolean value) { 21 | if (isBaby() == value) { 22 | return; 23 | } 24 | super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value); 25 | } 26 | 27 | public boolean isBecomingDrowned() { 28 | return super.metadata.getIndex(offset(OFFSET, 2), false); 29 | } 30 | 31 | public void setBecomingDrowned(boolean value) { 32 | super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, value); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/zombie/ZombieVillagerMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster.zombie; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import com.github.retrooper.packetevents.protocol.entity.villager.VillagerData; 5 | import com.github.retrooper.packetevents.protocol.entity.villager.profession.VillagerProfessions; 6 | import com.github.retrooper.packetevents.protocol.entity.villager.type.VillagerTypes; 7 | import me.tofaa.entitylib.meta.Metadata; 8 | import me.tofaa.entitylib.meta.mobs.villager.VillagerMeta; 9 | 10 | public class ZombieVillagerMeta extends ZombieMeta { 11 | 12 | public static final byte OFFSET = ZombieMeta.MAX_OFFSET; 13 | public static final byte MAX_OFFSET = OFFSET + 2; 14 | 15 | public ZombieVillagerMeta(int entityId, Metadata metadata) { 16 | super(entityId, metadata); 17 | } 18 | 19 | public boolean isConverting() { 20 | return super.metadata.getIndex(OFFSET, false); 21 | } 22 | 23 | public void setConverting(boolean value) { 24 | super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value); 25 | } 26 | 27 | public VillagerData getVillagerData() { 28 | int[] data = super.metadata.getIndex(offset(OFFSET, 1), null); 29 | if (data == null) { 30 | return new VillagerData(VillagerTypes.PLAINS, VillagerProfessions.NONE, VillagerMeta.Level.NOVICE.ordinal()); 31 | } 32 | return new VillagerData(VillagerMeta.TYPES[data[0]], VillagerMeta.PROFESSIONS[data[1]], VillagerMeta.Level.VALUES[data[2] - 1].ordinal()); 33 | } 34 | 35 | public void setVillagerData(VillagerData data) { 36 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.VILLAGER_DATA, new VillagerData( 37 | data.getType().getId(), 38 | data.getProfession().getId(), 39 | data.getLevel() + 1 40 | )); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/zombie/ZombifiedPiglinMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.monster.zombie; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class ZombifiedPiglinMeta extends ZombieMeta { 6 | 7 | public static final byte OFFSET = ZombieMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | public ZombifiedPiglinMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/passive/ArmadilloMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.passive; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.armadillo.ArmadilloState; 4 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 5 | import me.tofaa.entitylib.meta.Metadata; 6 | import me.tofaa.entitylib.meta.types.AgeableMeta; 7 | 8 | public class ArmadilloMeta extends AgeableMeta { 9 | 10 | public static final byte OFFSET = AgeableMeta.MAX_OFFSET; 11 | public static final byte MAX_OFFSET = OFFSET + 1; 12 | 13 | public ArmadilloMeta(int entityId, Metadata metadata) { 14 | super(entityId, metadata); 15 | } 16 | 17 | public ArmadilloState getState() { 18 | return metadata.getIndex(OFFSET, ArmadilloState.IDLE); 19 | } 20 | 21 | public void setState(ArmadilloState state) { 22 | super.metadata.setIndex(OFFSET, EntityDataTypes.ARMADILLO_STATE, state); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/passive/ChickenMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.passive; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | import me.tofaa.entitylib.meta.types.AgeableMeta; 5 | 6 | public class ChickenMeta extends AgeableMeta { 7 | 8 | public static final byte OFFSET = AgeableMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 0; 10 | 11 | public ChickenMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/passive/CowMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.passive; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | import me.tofaa.entitylib.meta.types.AgeableMeta; 5 | 6 | public class CowMeta extends AgeableMeta { 7 | 8 | public static final byte OFFSET = AgeableMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 0; 10 | 11 | public CowMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/passive/MooshroomMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.passive; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import java.util.Locale; 8 | 9 | public class MooshroomMeta extends CowMeta{ 10 | 11 | public static final byte OFFSET = CowMeta.MAX_OFFSET; 12 | public static final byte MAX_OFFSET = OFFSET + 1; 13 | 14 | public MooshroomMeta(int entityId, Metadata metadata) { 15 | super(entityId, metadata); 16 | } 17 | 18 | @NotNull 19 | public Variant getVariant() { 20 | return Variant.valueOf(super.metadata.getIndex(OFFSET, "red").toUpperCase(Locale.ROOT)); 21 | } 22 | 23 | public void setVariant(@NotNull Variant value) { 24 | super.metadata.setIndex(OFFSET, EntityDataTypes.STRING, value.name().toLowerCase(Locale.ROOT)); 25 | } 26 | 27 | public enum Variant { 28 | RED, 29 | BROWN 30 | } 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/passive/PigMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.passive; 2 | 3 | import com.github.retrooper.packetevents.manager.server.ServerVersion; 4 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 5 | import me.tofaa.entitylib.meta.Metadata; 6 | import me.tofaa.entitylib.meta.types.AgeableMeta; 7 | 8 | public class PigMeta extends AgeableMeta { 9 | 10 | public static final byte OFFSET = AgeableMeta.MAX_OFFSET; 11 | public static final byte MAX_OFFSET = OFFSET + 2; 12 | 13 | public PigMeta(int entityId, Metadata metadata) { 14 | super(entityId, metadata); 15 | } 16 | 17 | public boolean hasSaddle() { 18 | return super.metadata.getIndex(OFFSET, false); 19 | } 20 | 21 | public void setHasSaddle(boolean value) { 22 | super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value); 23 | } 24 | 25 | public int getTimeToBoost() { 26 | isVersionNewer(ServerVersion.V_1_16); 27 | return super.metadata.getIndex(offset(OFFSET,1), 0); 28 | } 29 | 30 | public void setTimeToBoost(int value) { 31 | isVersionNewer(ServerVersion.V_1_16); 32 | super.metadata.setIndex(offset(OFFSET,1), EntityDataTypes.INT, value); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/passive/RabbitMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.passive; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.AgeableMeta; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class RabbitMeta extends AgeableMeta { 9 | 10 | public static final byte OFFSET = AgeableMeta.MAX_OFFSET; 11 | public static final byte MAX_OFFSET = OFFSET + 1; 12 | 13 | 14 | public RabbitMeta(int entityId, Metadata metadata) { 15 | super(entityId, metadata); 16 | } 17 | 18 | public @NotNull Type getType() { 19 | int id = super.metadata.getIndex(OFFSET, 0); 20 | if (id == 99) { 21 | return Type.KILLER_BUNNY; 22 | } 23 | return Type.VALUES[id]; 24 | } 25 | 26 | public void setType(@NotNull Type value) { 27 | int id = value == Type.KILLER_BUNNY ? 99 : value.ordinal(); 28 | super.metadata.setIndex(OFFSET, EntityDataTypes.INT, id); 29 | } 30 | 31 | 32 | public enum Type { 33 | BROWN, 34 | WHITE, 35 | BLACK, 36 | BLACK_AND_WHITE, 37 | GOLD, 38 | SALT_AND_PEPPER, 39 | KILLER_BUNNY; 40 | 41 | private final static Type[] VALUES = values(); 42 | } 43 | 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/passive/SheepMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.passive; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | import me.tofaa.entitylib.meta.types.AgeableMeta; 5 | 6 | public class SheepMeta extends AgeableMeta { 7 | 8 | public static final byte OFFSET = AgeableMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 1; 10 | 11 | 12 | private final static byte COLOR_BITS = 0x0F; 13 | private final static byte SHEARED_BIT = 0x10; 14 | 15 | public SheepMeta(int entityId, Metadata metadata) { 16 | super(entityId, metadata); 17 | } 18 | 19 | public int getColor() { 20 | return getMask(OFFSET) & COLOR_BITS; 21 | } 22 | 23 | public void setColor(byte color) { 24 | byte before = getMask(OFFSET); 25 | byte mask = before; 26 | mask &= ~COLOR_BITS; 27 | mask |= (color & COLOR_BITS); 28 | if (mask != before) { 29 | setMask(OFFSET, mask); 30 | } 31 | } 32 | 33 | public boolean isSheared() { 34 | return getMaskBit(OFFSET, SHEARED_BIT); 35 | } 36 | 37 | public void setSheared(boolean value) { 38 | setMaskBit(OFFSET, SHEARED_BIT, value); 39 | } 40 | 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/tameable/ParrotMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.tameable; 2 | 3 | import com.github.retrooper.packetevents.manager.server.ServerVersion; 4 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 5 | import me.tofaa.entitylib.meta.Metadata; 6 | import me.tofaa.entitylib.meta.types.TameableMeta; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | public class ParrotMeta extends TameableMeta { 10 | 11 | public static final byte OFFSET = TameableMeta.MAX_OFFSET; 12 | public static final byte MAX_OFFSET = OFFSET + 1; 13 | 14 | public ParrotMeta(int entityId, Metadata metadata) { 15 | super(entityId, metadata); 16 | isVersionNewer(ServerVersion.V_1_14); 17 | } 18 | 19 | @NotNull 20 | public Color getColor() { 21 | return Color.VALUES[super.metadata.getIndex(OFFSET, 0)]; 22 | } 23 | 24 | public void setColor(@NotNull Color value) { 25 | super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value.ordinal()); 26 | } 27 | 28 | public enum Color { 29 | RED_BLUE, 30 | BLUE, 31 | GREEN, 32 | YELLOW_BLUE, 33 | GREY; 34 | 35 | private final static Color[] VALUES = values(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/tameable/WolfMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.tameable; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.extras.DyeColor; 5 | import me.tofaa.entitylib.meta.Metadata; 6 | import me.tofaa.entitylib.meta.types.TameableMeta; 7 | 8 | public class WolfMeta extends TameableMeta { 9 | 10 | public static final byte OFFSET = TameableMeta.MAX_OFFSET; 11 | public static final byte MAX_OFFSET = OFFSET + 3; 12 | 13 | public WolfMeta(int entityId, Metadata metadata) { 14 | super(entityId, metadata); 15 | } 16 | 17 | public boolean isBegging() { 18 | return super.metadata.getIndex(OFFSET, false); 19 | } 20 | 21 | public void setBegging(boolean value) { 22 | super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value); 23 | } 24 | 25 | public int getCollarColor() { 26 | return super.metadata.getIndex(offset(OFFSET, 1), 14); 27 | } 28 | 29 | public void setCollarColor(int value) { 30 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.INT, value); 31 | } 32 | 33 | public DyeColor getCollarColorAsDye() { 34 | return DyeColor.values()[super.metadata.getIndex(offset(OFFSET, 1), DyeColor.RED.ordinal())]; 35 | } 36 | 37 | public void setCollarColor(DyeColor color) { 38 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.INT, color.ordinal()); 39 | } 40 | 41 | public int getAngerTime() { 42 | return super.metadata.getIndex(offset(OFFSET, 2), 0); 43 | } 44 | 45 | public void setAngerTime(int value) { 46 | super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.INT, value); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/villager/BaseVillagerMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.villager; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.AgeableMeta; 6 | 7 | public class BaseVillagerMeta extends AgeableMeta { 8 | 9 | public static final byte OFFSET = AgeableMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 1; 11 | 12 | public BaseVillagerMeta(int entityId, Metadata metadata) { 13 | super(entityId, metadata); 14 | } 15 | 16 | public int getHeadShakeTimer() { 17 | return super.metadata.getIndex(OFFSET, 0); 18 | } 19 | 20 | public void setHeadShakeTimer(int value) { 21 | super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/villager/WanderingTraderMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.villager; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class WanderingTraderMeta extends VillagerMeta{ 6 | 7 | public static final byte OFFSET = VillagerMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | public WanderingTraderMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/water/AxolotlMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.water; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.WaterMobMeta; 6 | 7 | public class AxolotlMeta extends WaterMobMeta { 8 | 9 | public static final byte OFFSET = WaterMobMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 3; 11 | 12 | public AxolotlMeta(int entityId, Metadata metadata) { 13 | super(entityId, metadata); 14 | } 15 | 16 | public Variant getVariant() { 17 | return Variant.VALUES[super.metadata.getIndex(OFFSET, 0)]; 18 | } 19 | 20 | public void setVariant(Variant variant) { 21 | metadata.setIndex(OFFSET, EntityDataTypes.INT, variant.ordinal()); 22 | } 23 | 24 | public boolean isPlayingDead() { 25 | return metadata.getIndex(offset(OFFSET, 1), false); 26 | } 27 | 28 | public void setPlayingDead(boolean playingDead) { 29 | metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BOOLEAN, playingDead); 30 | } 31 | 32 | public boolean isFromBucket() { 33 | return metadata.getIndex(offset(OFFSET, 2), false); 34 | } 35 | 36 | public void setFromBucket(boolean fromBucket) { 37 | metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, fromBucket); 38 | } 39 | 40 | public enum Variant { 41 | LUCY, 42 | WILD, 43 | GOLD, 44 | CYAN, 45 | BLUE; 46 | 47 | private final static AxolotlMeta.Variant[] VALUES = values(); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/water/BaseFishMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.water; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.WaterMobMeta; 6 | 7 | public class BaseFishMeta extends WaterMobMeta { 8 | 9 | public static final byte OFFSET = WaterMobMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 1; 11 | 12 | public BaseFishMeta(int entityId, Metadata metadata) { 13 | super(entityId, metadata); 14 | } 15 | 16 | 17 | public boolean isFromBucket() { 18 | return super.metadata.getIndex(OFFSET, false); 19 | } 20 | 21 | public void setFromBucket(boolean value) { 22 | super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/water/CodMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.water; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class CodMeta extends BaseFishMeta{ 6 | 7 | public static final byte OFFSET = BaseFishMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | public CodMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/water/DolphinMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.water; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import com.github.retrooper.packetevents.util.Vector3i; 5 | import me.tofaa.entitylib.meta.Metadata; 6 | import me.tofaa.entitylib.meta.types.WaterMobMeta; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | public class DolphinMeta extends WaterMobMeta { 10 | 11 | public static final byte OFFSET = WaterMobMeta.MAX_OFFSET; 12 | public static final byte MAX_OFFSET = OFFSET + 3; 13 | 14 | public DolphinMeta(int entityId, Metadata metadata) { 15 | super(entityId, metadata); 16 | } 17 | 18 | @NotNull 19 | public Vector3i getTreasurePosition() { 20 | return super.metadata.getIndex(OFFSET, Vector3i.zero()); 21 | } 22 | 23 | public void setTreasurePosition(@NotNull Vector3i value) { 24 | super.metadata.setIndex(OFFSET, EntityDataTypes.BLOCK_POSITION, value); 25 | } 26 | 27 | public boolean isCanFindTreasure() { 28 | return super.metadata.getIndex(offset(OFFSET, 1), false); 29 | } 30 | 31 | public void setCanFindTreasure(boolean value) { 32 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BOOLEAN, value); 33 | } 34 | 35 | public boolean isHasFish() { 36 | return super.metadata.getIndex(offset(OFFSET, 2), false); 37 | } 38 | 39 | public void setHasFish(boolean value) { 40 | super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, value); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/water/GlowSquidMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.water; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | 6 | public class GlowSquidMeta extends SquidMeta { 7 | 8 | public static final byte OFFSET = SquidMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 1; 10 | 11 | public GlowSquidMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | 15 | public int getDarkTicksRemaining() { 16 | return metadata.getIndex(OFFSET, 0); 17 | } 18 | 19 | public void setDarkTicksRemaining(int ticks) { 20 | metadata.setIndex(OFFSET, EntityDataTypes.INT, ticks); 21 | } 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/water/PufferFishMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.water; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | 6 | public class PufferFishMeta extends BaseFishMeta { 7 | 8 | public static final byte OFFSET = BaseFishMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 1; 10 | 11 | public PufferFishMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | 15 | public State getState() { 16 | return State.VALUES[super.metadata.getIndex(OFFSET, 0)]; 17 | } 18 | 19 | public void setState(State state) { 20 | super.metadata.setIndex(OFFSET, EntityDataTypes.INT, state.ordinal()); 21 | } 22 | 23 | 24 | public enum State { 25 | UNPUFFED, 26 | SEMI_PUFFED, 27 | FULLY_PUFFED; 28 | 29 | private final static State[] VALUES = values(); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/water/SalmonMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.water; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class SalmonMeta extends BaseFishMeta{ 6 | public SalmonMeta(int entityId, Metadata metadata) { 7 | super(entityId, metadata); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/mobs/water/SquidMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.mobs.water; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | import me.tofaa.entitylib.meta.types.WaterMobMeta; 5 | 6 | public class SquidMeta extends WaterMobMeta { 7 | 8 | public static final byte OFFSET = WaterMobMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 0; 10 | 11 | public SquidMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/other/AreaEffectCloudMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.other; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.EntityMeta; 5 | import me.tofaa.entitylib.meta.Metadata; 6 | 7 | public class AreaEffectCloudMeta extends EntityMeta { 8 | 9 | public static final byte OFFSET = EntityMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 4; 11 | 12 | public AreaEffectCloudMeta(int entityId, Metadata metadata) { 13 | super(entityId, metadata); 14 | } 15 | 16 | public float getRadius() { 17 | return super.metadata.getIndex(OFFSET, .5F); 18 | } 19 | 20 | public void setRadius(float value) { 21 | super.metadata.setIndex(OFFSET, EntityDataTypes.FLOAT, value); 22 | } 23 | 24 | public int getColor() { 25 | return super.metadata.getIndex(offset(OFFSET, 1), 0); 26 | } 27 | 28 | public void setColor(int value) { 29 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.INT, value); 30 | } 31 | 32 | public boolean isSinglePoint() { 33 | return super.metadata.getIndex(offset(OFFSET, 2), false); 34 | } 35 | 36 | public void setSinglePoint(boolean value) { 37 | super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, value); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/other/EndCrystalMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.other; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import com.github.retrooper.packetevents.util.Vector3i; 5 | import me.tofaa.entitylib.meta.EntityMeta; 6 | import me.tofaa.entitylib.meta.Metadata; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | import java.util.Optional; 10 | 11 | public class EndCrystalMeta extends EntityMeta { 12 | 13 | public static final byte OFFSET = EntityMeta.MAX_OFFSET; 14 | public static final byte MAX_OFFSET = OFFSET + 2; 15 | 16 | public EndCrystalMeta(int entityId, Metadata metadata) { 17 | super(entityId, metadata); 18 | } 19 | 20 | public @Nullable Optional getBeamTarget() { 21 | return super.metadata.getIndex(OFFSET, Optional.empty()); 22 | } 23 | 24 | public void setBeamTarget(@Nullable Vector3i value) { 25 | super.metadata.setIndex(OFFSET, EntityDataTypes.OPTIONAL_BLOCK_POSITION, Optional.ofNullable(value)); 26 | } 27 | 28 | public boolean isShowingBottom() { 29 | return super.metadata.getIndex(offset(OFFSET, 1), true); 30 | } 31 | 32 | public void setShowingBottom(boolean value) { 33 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BOOLEAN, value); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/other/EnderDragonMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.other; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.MobMeta; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class EnderDragonMeta extends MobMeta { 9 | 10 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 11 | public static final byte MAX_OFFSET = OFFSET + 0; 12 | 13 | 14 | public EnderDragonMeta(int entityId, Metadata metadata) { 15 | super(entityId, metadata); 16 | } 17 | 18 | @NotNull 19 | public Phase getPhase() { 20 | return Phase.VALUES[super.metadata.getIndex(OFFSET, 0)]; 21 | } 22 | 23 | public void setPhase(@NotNull Phase value) { 24 | super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value.ordinal()); 25 | } 26 | 27 | public enum Phase { 28 | CIRCLING, 29 | STRAFING, 30 | FLYING_TO_THE_PORTAL, 31 | LANDING_ON_THE_PORTAL, 32 | TAKING_OFF_FROM_THE_PORTAL, 33 | BREATH_ATTACK, 34 | LOOKING_FOR_BREATH_ATTACK_PLAYER, 35 | ROAR, 36 | CHARGING_PLAYER, 37 | FLYING_TO_THE_PORTAL_TO_DIE, 38 | HOVERING_WITHOUT_AI; 39 | 40 | private final static Phase[] VALUES = values(); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/other/EvokerFangsMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.other; 2 | 3 | import me.tofaa.entitylib.meta.EntityMeta; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | 6 | public class EvokerFangsMeta extends EntityMeta { 7 | 8 | public static final byte OFFSET = EntityMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 0; 10 | 11 | public EvokerFangsMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/other/FallingBlockMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.other; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import com.github.retrooper.packetevents.util.Vector3i; 5 | import me.tofaa.entitylib.meta.EntityMeta; 6 | import me.tofaa.entitylib.meta.Metadata; 7 | import me.tofaa.entitylib.meta.types.ObjectData; 8 | 9 | public class FallingBlockMeta extends EntityMeta implements ObjectData { 10 | 11 | public static final byte OFFSET = EntityMeta.MAX_OFFSET; 12 | public static final byte MAX_OFFSET = OFFSET + 1; 13 | 14 | private int blockStateId; 15 | 16 | public FallingBlockMeta(int entityId, Metadata metadata) { 17 | super(entityId, metadata); 18 | } 19 | 20 | public Vector3i getSpawnPosition() { 21 | return super.metadata.getIndex(OFFSET, Vector3i.zero()); 22 | } 23 | 24 | public void setSpawnPosition(Vector3i value) { 25 | super.metadata.setIndex(OFFSET, EntityDataTypes.BLOCK_POSITION, value); 26 | } 27 | 28 | 29 | public int getBlockStateId() { 30 | return blockStateId; 31 | } 32 | 33 | public void setBlockStateId(int blockStateId) { 34 | this.blockStateId = blockStateId; 35 | } 36 | 37 | @Override 38 | public int getObjectData() { 39 | return blockStateId; 40 | } 41 | 42 | @Override 43 | public boolean requiresVelocityPacketAtSpawn() { 44 | return false; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/other/FireworkRocketMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.other; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 5 | import me.tofaa.entitylib.meta.EntityMeta; 6 | import me.tofaa.entitylib.meta.Metadata; 7 | import me.tofaa.entitylib.meta.types.ProjectileMeta; 8 | 9 | import java.util.Optional; 10 | 11 | public class FireworkRocketMeta extends EntityMeta implements ProjectileMeta { 12 | 13 | public static final byte OFFSET = EntityMeta.MAX_OFFSET; 14 | public static final byte MAX_OFFSET = OFFSET + 3; 15 | 16 | private int shooter = -1; 17 | 18 | public FireworkRocketMeta(int entityId, Metadata metadata) { 19 | super(entityId, metadata); 20 | } 21 | 22 | public ItemStack getFireworkItem() { 23 | return super.metadata.getIndex(OFFSET, ItemStack.EMPTY); 24 | } 25 | 26 | public void setFireworkItem(ItemStack value) { 27 | super.metadata.setIndex(OFFSET, EntityDataTypes.ITEMSTACK, value); 28 | } 29 | 30 | 31 | public boolean isShotAtAngle() { 32 | return super.metadata.getIndex(offset(OFFSET, 2), false); 33 | } 34 | 35 | public void setShotAtAngle(boolean value) { 36 | super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, value); 37 | } 38 | 39 | @Override 40 | public int getShooter() { 41 | return shooter; 42 | } 43 | 44 | @Override 45 | public void setShooter(int entityId) { 46 | this.shooter = entityId; 47 | Optional optional = Optional.ofNullable(entityId == -1 ? null : entityId); 48 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.OPTIONAL_INT, optional); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/other/FishingHookMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.other; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.EntityMeta; 5 | import me.tofaa.entitylib.meta.Metadata; 6 | import me.tofaa.entitylib.meta.types.ObjectData; 7 | 8 | import java.util.Optional; 9 | 10 | public class FishingHookMeta extends EntityMeta implements ObjectData { 11 | 12 | public static final byte OFFSET = EntityMeta.MAX_OFFSET; 13 | public static final byte MAX_OFFSET = OFFSET + 2; 14 | 15 | private int shooterId; 16 | private int hookedId; 17 | 18 | public FishingHookMeta(int entityId, Metadata metadata) { 19 | super(entityId, metadata); 20 | } 21 | 22 | public boolean isCatchable() { 23 | return super.metadata.getIndex(offset(OFFSET, 1), false); 24 | } 25 | 26 | public void setCatchable(boolean value) { 27 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BOOLEAN, value); 28 | } 29 | 30 | public int getHookedEntity() { 31 | return hookedId; 32 | } 33 | 34 | public void setShooter(int entityId) { 35 | this.shooterId = entityId; 36 | } 37 | 38 | public void setHookedEntity(int entityId) { 39 | this.hookedId = entityId; 40 | super.metadata.setIndex(OFFSET, EntityDataTypes.INT, entityId == -1 ? 0 : entityId + 1); 41 | } 42 | 43 | @Override 44 | public int getObjectData() { 45 | return shooterId != -1 ? shooterId : 0; 46 | } 47 | 48 | @Override 49 | public boolean requiresVelocityPacketAtSpawn() { 50 | return false; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/other/GlowItemFrameMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.other; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class GlowItemFrameMeta extends ItemFrameMeta { 6 | 7 | public static final byte OFFSET = ItemFrameMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | public GlowItemFrameMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/other/InteractionMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.other; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.EntityMeta; 5 | import me.tofaa.entitylib.meta.Metadata; 6 | 7 | public class InteractionMeta extends EntityMeta { 8 | 9 | public static final byte OFFSET = EntityMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 3; 11 | 12 | public InteractionMeta(int entityId, Metadata metadata) { 13 | super(entityId, metadata); 14 | } 15 | 16 | public float getWidth() { 17 | return super.metadata.getIndex(OFFSET, 1.0F); 18 | } 19 | 20 | public void setWidth(float value) { 21 | super.metadata.setIndex(OFFSET, EntityDataTypes.FLOAT, value); 22 | } 23 | 24 | public float getHeight() { 25 | return super.metadata.getIndex(offset(OFFSET, 1), 1.0F); 26 | } 27 | 28 | public void setHeight(float value) { 29 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.FLOAT, value); 30 | } 31 | 32 | public boolean isResponsive() { 33 | return super.metadata.getIndex(offset(OFFSET, 2), false); 34 | } 35 | 36 | public void setResponsive(boolean value) { 37 | super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, value); 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/other/LeashKnotMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.other; 2 | 3 | import me.tofaa.entitylib.meta.EntityMeta; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | 6 | public class LeashKnotMeta extends EntityMeta { 7 | 8 | public static final byte OFFSET = EntityMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 0; 10 | 11 | public LeashKnotMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/other/LightningBoltMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.other; 2 | 3 | import me.tofaa.entitylib.meta.EntityMeta; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | 6 | public class LightningBoltMeta extends EntityMeta { 7 | 8 | public static final byte OFFSET = EntityMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 0; 10 | 11 | public LightningBoltMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/other/LlamaSpitMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.other; 2 | 3 | import me.tofaa.entitylib.meta.EntityMeta; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.ObjectData; 6 | 7 | public class LlamaSpitMeta extends EntityMeta implements ObjectData { 8 | public static final byte OFFSET = EntityMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 0; 10 | 11 | public LlamaSpitMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | 15 | 16 | @Override 17 | public int getObjectData() { 18 | return 0; 19 | } 20 | 21 | @Override 22 | public boolean requiresVelocityPacketAtSpawn() { 23 | return true; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/other/MarkerMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.other; 2 | 3 | import me.tofaa.entitylib.meta.EntityMeta; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | 6 | public class MarkerMeta extends EntityMeta { 7 | 8 | public static final byte OFFSET = EntityMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 0; 10 | 11 | public MarkerMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/other/PrimedTntMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.other; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.EntityMeta; 5 | import me.tofaa.entitylib.meta.Metadata; 6 | 7 | public class PrimedTntMeta extends EntityMeta { 8 | public static final byte OFFSET = EntityMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 1; 10 | 11 | 12 | public PrimedTntMeta(int entityId, Metadata metadata) { 13 | super(entityId, metadata); 14 | } 15 | 16 | public int getFuseTime() { 17 | return super.metadata.getIndex(OFFSET, 80); 18 | } 19 | 20 | public void setFuseTime(int value) { 21 | super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/projectile/ArrowMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.projectile; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.ObjectData; 6 | import me.tofaa.entitylib.meta.types.ProjectileMeta; 7 | 8 | public class ArrowMeta extends BaseArrowMeta implements ProjectileMeta, ObjectData { 9 | 10 | public static final byte OFFSET = BaseArrowMeta.MAX_OFFSET; 11 | public static final byte MAX_OFFSET = OFFSET + 1; 12 | 13 | private int shooterId = -1; 14 | 15 | public ArrowMeta(int entityId, Metadata metadata) { 16 | super(entityId, metadata); 17 | } 18 | 19 | public int getColor() { 20 | return super.metadata.getIndex(OFFSET, -1); 21 | } 22 | 23 | public void setColor(int value) { 24 | super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value); 25 | } 26 | 27 | @Override 28 | public int getShooter() { 29 | return shooterId; 30 | } 31 | 32 | @Override 33 | public void setShooter(int entityId) { 34 | this.shooterId = entityId; 35 | } 36 | 37 | 38 | @Override 39 | public int getObjectData() { 40 | return this.shooterId == -1 ? 0 : this.shooterId + 1; 41 | } 42 | 43 | @Override 44 | public boolean requiresVelocityPacketAtSpawn() { 45 | return true; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/projectile/BaseArrowMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.projectile; 2 | 3 | import com.github.retrooper.packetevents.manager.server.ServerVersion; 4 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 5 | import me.tofaa.entitylib.meta.EntityMeta; 6 | import me.tofaa.entitylib.meta.Metadata; 7 | 8 | public class BaseArrowMeta extends EntityMeta { 9 | 10 | public static final byte OFFSET = EntityMeta.MAX_OFFSET; 11 | public static final byte MAX_OFFSET = OFFSET + 2; 12 | 13 | private final static byte CRITICAL_BIT = 0x01; 14 | private final static byte NO_CLIP_BIT = 0x02; 15 | 16 | public BaseArrowMeta(int entityId, Metadata metadata) { 17 | super(entityId, metadata); 18 | } 19 | 20 | public boolean isCritical() { 21 | return getMaskBit(OFFSET, CRITICAL_BIT); 22 | } 23 | 24 | public void setCritical(boolean value) { 25 | setMaskBit(OFFSET, CRITICAL_BIT, value); 26 | } 27 | 28 | public boolean isNoClip() { 29 | isVersionNewer(ServerVersion.V_1_9); 30 | return getMaskBit(OFFSET, NO_CLIP_BIT); 31 | } 32 | 33 | public void setNoClip(boolean value) { 34 | isVersionNewer(ServerVersion.V_1_9); 35 | setMaskBit(OFFSET, NO_CLIP_BIT, value); 36 | } 37 | 38 | public int getPierceLevel() { 39 | isVersionNewer(ServerVersion.V_1_14); 40 | return super.metadata.getIndex(offset(OFFSET,1), 0); 41 | } 42 | 43 | public void setPierceLevel(int value) { 44 | isVersionNewer(ServerVersion.V_1_14); 45 | super.metadata.setIndex(offset(OFFSET,1), EntityDataTypes.INT, value); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/projectile/DragonFireballMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.projectile; 2 | 3 | import me.tofaa.entitylib.meta.EntityMeta; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.ObjectData; 6 | import me.tofaa.entitylib.meta.types.ProjectileMeta; 7 | 8 | public class DragonFireballMeta extends EntityMeta implements ProjectileMeta, ObjectData { 9 | 10 | public static final byte OFFSET = EntityMeta.MAX_OFFSET; 11 | public static final byte MAX_OFFSET = OFFSET + 0; 12 | 13 | private int shooter = -1; 14 | 15 | public DragonFireballMeta(int entityId, Metadata metadata) { 16 | super(entityId, metadata); 17 | } 18 | 19 | @Override 20 | public int getObjectData() { 21 | return this.shooter == -1 ? 0 : this.shooter; 22 | } 23 | 24 | @Override 25 | public boolean requiresVelocityPacketAtSpawn() { 26 | return true; 27 | } 28 | 29 | @Override 30 | public int getShooter() { 31 | return shooter; 32 | } 33 | 34 | @Override 35 | public void setShooter(int entityId) { 36 | this.shooter = entityId; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/projectile/EyeOfEnderMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.projectile; 2 | 3 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 4 | import com.github.retrooper.packetevents.protocol.item.type.ItemTypes; 5 | import me.tofaa.entitylib.meta.Metadata; 6 | import me.tofaa.entitylib.meta.types.ItemContainerMeta; 7 | 8 | public class EyeOfEnderMeta extends ItemContainerMeta { 9 | 10 | 11 | public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET; 12 | public static final byte MAX_OFFSET = OFFSET + 0; 13 | 14 | public static final ItemStack EYE_OF_ENDER = ItemStack.builder().type(ItemTypes.ENDER_EYE).build(); 15 | 16 | public EyeOfEnderMeta(int entityId, Metadata metadata) { 17 | super(entityId, metadata, EYE_OF_ENDER); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/projectile/ItemEntityMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.projectile; 2 | 3 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.ItemContainerMeta; 6 | import me.tofaa.entitylib.meta.types.ObjectData; 7 | 8 | public class ItemEntityMeta extends ItemContainerMeta implements ObjectData { 9 | 10 | public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET; 11 | public static final byte MAX_OFFSET = OFFSET + 0; 12 | 13 | public ItemEntityMeta(int entityId, Metadata metadata) { 14 | super(entityId, metadata, ItemStack.EMPTY); 15 | } 16 | 17 | @Override 18 | public int getObjectData() { 19 | return 1; 20 | } 21 | 22 | @Override 23 | public boolean requiresVelocityPacketAtSpawn() { 24 | return true; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/projectile/LargeFireballMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.projectile; 2 | 3 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.ItemContainerMeta; 6 | import me.tofaa.entitylib.meta.types.ObjectData; 7 | import me.tofaa.entitylib.meta.types.ProjectileMeta; 8 | 9 | public class LargeFireballMeta extends ItemContainerMeta implements ObjectData, ProjectileMeta { 10 | public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET; 11 | public static final byte MAX_OFFSET = OFFSET + 0; 12 | 13 | private int shooterId = -1; 14 | 15 | public LargeFireballMeta(int entityId, Metadata meta) { 16 | super(entityId, meta, ItemStack.EMPTY); 17 | } 18 | 19 | @Override 20 | public int getObjectData() { 21 | return this.shooterId == -1 ? 0 : this.shooterId; 22 | } 23 | 24 | @Override 25 | public boolean requiresVelocityPacketAtSpawn() { 26 | return true; 27 | } 28 | 29 | @Override 30 | public int getShooter() { 31 | return shooterId; 32 | } 33 | 34 | @Override 35 | public void setShooter(int entityId) { 36 | this.shooterId = entityId; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/projectile/ShulkerBulletMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.projectile; 2 | 3 | import me.tofaa.entitylib.meta.EntityMeta; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.ObjectData; 6 | 7 | public class ShulkerBulletMeta extends EntityMeta implements ObjectData { 8 | 9 | public static final byte OFFSET = EntityMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 0; 11 | 12 | public ShulkerBulletMeta(int entityId, Metadata metadata) { 13 | super(entityId, metadata); 14 | } 15 | 16 | @Override 17 | public int getObjectData() { 18 | return 0; 19 | } 20 | 21 | @Override 22 | public boolean requiresVelocityPacketAtSpawn() { 23 | return true; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/projectile/SmallFireballMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.projectile; 2 | 3 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 4 | import com.github.retrooper.packetevents.protocol.item.type.ItemTypes; 5 | import me.tofaa.entitylib.meta.Metadata; 6 | import me.tofaa.entitylib.meta.types.ItemContainerMeta; 7 | import me.tofaa.entitylib.meta.types.ObjectData; 8 | import me.tofaa.entitylib.meta.types.ProjectileMeta; 9 | 10 | public class SmallFireballMeta extends ItemContainerMeta implements ObjectData, ProjectileMeta { 11 | 12 | 13 | public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET; 14 | public static final byte MAX_OFFSET = OFFSET + 0; 15 | 16 | public static final ItemStack SMALL_FIREBALL = ItemStack.builder().type(ItemTypes.FIRE_CHARGE).build(); 17 | 18 | private int shooterId = -1; 19 | 20 | public SmallFireballMeta(int entityId, Metadata meta) { 21 | super(entityId, meta, SMALL_FIREBALL); 22 | } 23 | 24 | @Override 25 | public int getObjectData() { 26 | return this.shooterId == -1 ? 0 : this.shooterId; 27 | } 28 | 29 | @Override 30 | public boolean requiresVelocityPacketAtSpawn() { 31 | return true; 32 | } 33 | 34 | @Override 35 | public int getShooter() { 36 | return shooterId; 37 | } 38 | 39 | @Override 40 | public void setShooter(int entityId) { 41 | this.shooterId = entityId; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/projectile/SnowballMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.projectile; 2 | 3 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 4 | import com.github.retrooper.packetevents.protocol.item.type.ItemTypes; 5 | import me.tofaa.entitylib.meta.Metadata; 6 | import me.tofaa.entitylib.meta.types.ItemContainerMeta; 7 | 8 | public class SnowballMeta extends ItemContainerMeta { 9 | 10 | public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET; 11 | public static final byte MAX_OFFSET = OFFSET + 0; 12 | 13 | public static final ItemStack SNOWBALL = ItemStack.builder().type(ItemTypes.SNOWBALL).build(); 14 | 15 | public SnowballMeta(int entityId, Metadata metadata) { 16 | super(entityId, metadata, SNOWBALL); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/projectile/SpectralArrowMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.projectile; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | import me.tofaa.entitylib.meta.types.ObjectData; 5 | import me.tofaa.entitylib.meta.types.ProjectileMeta; 6 | 7 | public class SpectralArrowMeta extends BaseArrowMeta implements ProjectileMeta, ObjectData { 8 | 9 | public static final byte OFFSET = BaseArrowMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 0; 11 | 12 | private int shooterId = -1; 13 | 14 | public SpectralArrowMeta(int entityId, Metadata metadata) { 15 | super(entityId, metadata); 16 | } 17 | 18 | @Override 19 | public int getObjectData() { 20 | return this.shooterId == -1 ? 0 : this.shooterId + 1; 21 | } 22 | 23 | @Override 24 | public boolean requiresVelocityPacketAtSpawn() { 25 | return true; 26 | } 27 | 28 | @Override 29 | public int getShooter() { 30 | return shooterId; 31 | } 32 | 33 | @Override 34 | public void setShooter(int entityId) { 35 | this.shooterId = entityId; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/projectile/ThrownEggMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.projectile; 2 | 3 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 4 | import com.github.retrooper.packetevents.protocol.item.type.ItemTypes; 5 | import me.tofaa.entitylib.meta.Metadata; 6 | import me.tofaa.entitylib.meta.types.ItemContainerMeta; 7 | 8 | public class ThrownEggMeta extends ItemContainerMeta { 9 | 10 | 11 | public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET; 12 | public static final byte MAX_OFFSET = OFFSET + 0; 13 | 14 | private static final ItemStack EGG = ItemStack.builder().type(ItemTypes.EGG).build(); 15 | 16 | public ThrownEggMeta(int entityId, Metadata metadata) { 17 | super(entityId, metadata, EGG); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/projectile/ThrownEnderPearlMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.projectile; 2 | 3 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 4 | import com.github.retrooper.packetevents.protocol.item.type.ItemTypes; 5 | import me.tofaa.entitylib.meta.Metadata; 6 | import me.tofaa.entitylib.meta.types.ItemContainerMeta; 7 | 8 | public class ThrownEnderPearlMeta extends ItemContainerMeta { 9 | 10 | public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET; 11 | public static final byte MAX_OFFSET = OFFSET + 0; 12 | 13 | private static final ItemStack ENDER_PEARL = ItemStack.builder().type(ItemTypes.ENDER_PEARL).build(); 14 | 15 | public ThrownEnderPearlMeta(int entityId, Metadata metadata) { 16 | super(entityId, metadata, ENDER_PEARL); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/projectile/ThrownExpBottleMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.projectile; 2 | 3 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 4 | import com.github.retrooper.packetevents.protocol.item.type.ItemTypes; 5 | import me.tofaa.entitylib.meta.Metadata; 6 | import me.tofaa.entitylib.meta.types.ItemContainerMeta; 7 | 8 | public class ThrownExpBottleMeta extends ItemContainerMeta { 9 | 10 | public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET; 11 | public static final byte MAX_OFFSET = OFFSET + 0; 12 | 13 | private static final ItemStack EXP_BOTTLE = ItemStack.builder().type(ItemTypes.EXPERIENCE_BOTTLE).build(); 14 | 15 | public ThrownExpBottleMeta(int entityId, Metadata metadata) { 16 | super(entityId, metadata, EXP_BOTTLE); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/projectile/ThrownPotionMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.projectile; 2 | 3 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | import me.tofaa.entitylib.meta.types.ItemContainerMeta; 6 | 7 | public class ThrownPotionMeta extends ItemContainerMeta { 8 | 9 | public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 0; 11 | 12 | public ThrownPotionMeta(int entityId, Metadata metadata) { 13 | super(entityId, metadata, ItemStack.EMPTY); 14 | } 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/projectile/ThrownTridentMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.projectile; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | 6 | public class ThrownTridentMeta extends BaseArrowMeta{ 7 | 8 | public static final byte OFFSET = BaseArrowMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 2; 10 | 11 | public ThrownTridentMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | 15 | public int getLoyaltyLevel() { 16 | return super.metadata.getIndex(OFFSET, 0); 17 | } 18 | 19 | public void setLoyaltyLevel(int value) { 20 | super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value); 21 | } 22 | 23 | public boolean isHasEnchantmentGlint() { 24 | return super.metadata.getIndex(offset(OFFSET,1), false); 25 | } 26 | 27 | public void setHasEnchantmentGlint(boolean value) { 28 | super.metadata.setIndex(offset(OFFSET,1), EntityDataTypes.BOOLEAN, value); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/projectile/WitherSkullMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.projectile; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.EntityMeta; 5 | import me.tofaa.entitylib.meta.Metadata; 6 | import me.tofaa.entitylib.meta.types.ObjectData; 7 | import me.tofaa.entitylib.meta.types.ProjectileMeta; 8 | 9 | public class WitherSkullMeta extends EntityMeta implements ObjectData, ProjectileMeta { 10 | 11 | public static final byte OFFSET = EntityMeta.MAX_OFFSET; 12 | public static final byte MAX_OFFSET = OFFSET + 1; 13 | 14 | private int shooter = -1; 15 | 16 | public WitherSkullMeta(int entityId, Metadata metadata) { 17 | super(entityId, metadata); 18 | } 19 | 20 | 21 | public boolean isInvulnerable() { 22 | return super.metadata.getIndex(OFFSET, false); 23 | } 24 | 25 | public void setInvulnerable(boolean value) { 26 | super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value); 27 | } 28 | 29 | 30 | 31 | @Override 32 | public int getObjectData() { 33 | return this.shooter == -1 ? 0 : this.shooter; 34 | } 35 | 36 | @Override 37 | public boolean requiresVelocityPacketAtSpawn() { 38 | return true; 39 | } 40 | 41 | @Override 42 | public int getShooter() { 43 | return shooter; 44 | } 45 | 46 | @Override 47 | public void setShooter(int entityId) { 48 | this.shooter = entityId; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/types/AgeableMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.types; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | 6 | public class AgeableMeta extends MobMeta { 7 | 8 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 9 | public static final byte MAX_OFFSET = OFFSET + 1; 10 | 11 | public AgeableMeta(int entityId, Metadata metadata) { 12 | super(entityId, metadata); 13 | } 14 | 15 | public boolean isBaby() { 16 | return super.metadata.getIndex(OFFSET, false); 17 | } 18 | 19 | public void setBaby(boolean value) { 20 | super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/types/ItemContainerMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.types; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 5 | import me.tofaa.entitylib.meta.EntityMeta; 6 | import me.tofaa.entitylib.meta.Metadata; 7 | 8 | public abstract class ItemContainerMeta extends EntityMeta { 9 | public static final byte OFFSET = EntityMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 1; 11 | 12 | private final ItemStack baseItem; 13 | 14 | public ItemContainerMeta(int entityId, Metadata metadata, ItemStack baseItem) { 15 | super(entityId, metadata); 16 | this.baseItem = baseItem; 17 | } 18 | 19 | public ItemStack getItem() { 20 | return super.metadata.getIndex(OFFSET, baseItem); 21 | } 22 | 23 | public void setItem(ItemStack value) { 24 | super.metadata.setIndex(OFFSET, EntityDataTypes.ITEMSTACK, value); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/types/MobMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.types; 2 | 3 | import com.github.retrooper.packetevents.manager.server.ServerVersion; 4 | import me.tofaa.entitylib.meta.EntityMeta; 5 | import me.tofaa.entitylib.meta.Metadata; 6 | 7 | public class MobMeta extends LivingEntityMeta { 8 | 9 | public static final byte OFFSET = LivingEntityMeta.MAX_OFFSET; 10 | public static final byte MAX_OFFSET = OFFSET + 1; 11 | 12 | private final static byte NO_AI_BIT = 0x01; 13 | private final static byte IS_LEFT_HANDED_BIT = 0x02; 14 | private final static byte IS_AGGRESSIVE_BIT = 0x04; 15 | 16 | 17 | public MobMeta(int entityId, Metadata metadata) { 18 | super(entityId, metadata); 19 | } 20 | 21 | public boolean isNoAi() { 22 | return getMaskBit(OFFSET, NO_AI_BIT); 23 | } 24 | 25 | public void setNoAi(boolean value) { 26 | setMaskBit(OFFSET, NO_AI_BIT, value); 27 | } 28 | 29 | public boolean isLeftHanded() { 30 | EntityMeta.isVersionNewer(ServerVersion.V_1_9); 31 | return getMaskBit(OFFSET, IS_LEFT_HANDED_BIT); 32 | } 33 | 34 | public void setLeftHanded(boolean value) { 35 | EntityMeta.isVersionNewer(ServerVersion.V_1_9); 36 | setMaskBit(OFFSET, IS_LEFT_HANDED_BIT, value); 37 | } 38 | 39 | public boolean isAggressive() { 40 | EntityMeta.isVersionNewer(ServerVersion.V_1_14); 41 | return getMaskBit(OFFSET, IS_AGGRESSIVE_BIT); 42 | } 43 | 44 | public void setAggressive(boolean value) { 45 | EntityMeta.isVersionNewer(ServerVersion.V_1_14); 46 | setMaskBit(OFFSET, IS_AGGRESSIVE_BIT, value); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/types/ObjectData.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.types; 2 | 3 | public interface ObjectData { 4 | 5 | int getObjectData(); 6 | 7 | boolean requiresVelocityPacketAtSpawn(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/types/ProjectileMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.types; 2 | 3 | 4 | public interface ProjectileMeta { 5 | 6 | int getShooter(); 7 | 8 | void setShooter(int entityId); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/types/TameableMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.types; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; 4 | import me.tofaa.entitylib.meta.Metadata; 5 | 6 | import java.util.Optional; 7 | import java.util.UUID; 8 | 9 | public class TameableMeta extends AgeableMeta{ 10 | 11 | public static final byte OFFSET = AgeableMeta.MAX_OFFSET; 12 | public static final byte MAX_OFFSET = OFFSET + 2; 13 | 14 | private final static byte SITTING_BIT = 0x01; 15 | private final static byte TAMED_BIT = 0x04; 16 | 17 | public TameableMeta(int entityId, Metadata metadata) { 18 | super(entityId, metadata); 19 | } 20 | 21 | 22 | public boolean isSitting() { 23 | return getMaskBit(OFFSET, SITTING_BIT); 24 | } 25 | 26 | public void setSitting(boolean value) { 27 | setMaskBit(OFFSET, SITTING_BIT, value); 28 | } 29 | 30 | public boolean isTamed() { 31 | return getMaskBit(OFFSET, TAMED_BIT); 32 | } 33 | 34 | public void setTamed(boolean value) { 35 | setMaskBit(OFFSET, TAMED_BIT, value); 36 | } 37 | 38 | public Optional getOwner() { 39 | return super.metadata.getIndex(offset(OFFSET, 1), Optional.empty()); 40 | } 41 | 42 | public void setOwner(UUID value) { 43 | super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.OPTIONAL_UUID, Optional.ofNullable(value)); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/meta/types/WaterMobMeta.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.meta.types; 2 | 3 | import me.tofaa.entitylib.meta.Metadata; 4 | 5 | public class WaterMobMeta extends MobMeta { 6 | 7 | public static final byte OFFSET = MobMeta.MAX_OFFSET; 8 | public static final byte MAX_OFFSET = OFFSET + 0; 9 | 10 | public WaterMobMeta(int entityId, Metadata metadata) { 11 | super(entityId, metadata); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/packetconversion/CommonSpawningMethods.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.packetconversion; 2 | 3 | import com.github.retrooper.packetevents.wrapper.PacketWrapper; 4 | import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSpawnExperienceOrb; 5 | import me.tofaa.entitylib.wrapper.WrapperEntity; 6 | import me.tofaa.entitylib.wrapper.WrapperExperienceOrbEntity; 7 | 8 | final class CommonSpawningMethods { 9 | 10 | static final class ExperienceOrb implements EntitySpawningMethod { 11 | 12 | @Override 13 | public PacketWrapper getSpawnPacket(WrapperEntity entity) { 14 | short experience = entity instanceof WrapperExperienceOrbEntity ? ((WrapperExperienceOrbEntity) entity).getExperience() : 0; 15 | return new WrapperPlayServerSpawnExperienceOrb( 16 | entity.getEntityId(), 17 | entity.getLocation().getX(), 18 | entity.getLocation().getY(), 19 | entity.getLocation().getZ(), 20 | experience 21 | ); 22 | } 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/packetconversion/EntitySpawningMethod.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.packetconversion; 2 | 3 | import com.github.retrooper.packetevents.wrapper.PacketWrapper; 4 | import me.tofaa.entitylib.wrapper.WrapperEntity; 5 | 6 | public interface EntitySpawningMethod { 7 | 8 | EntitySpawningMethod EXPERIENCE_ORB = new CommonSpawningMethods.ExperienceOrb(); 9 | 10 | 11 | PacketWrapper getSpawnPacket(WrapperEntity entity); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/packetconversion/EntitySpawningPacketConversion.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.packetconversion; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.type.EntityType; 4 | import com.github.retrooper.packetevents.wrapper.PacketWrapper; 5 | import me.tofaa.entitylib.wrapper.WrapperEntity; 6 | 7 | import java.util.Map; 8 | import java.util.concurrent.ConcurrentHashMap; 9 | 10 | public final class EntitySpawningPacketConversion { 11 | 12 | private static Map methods = new ConcurrentHashMap<>(); 13 | 14 | static { 15 | 16 | } 17 | 18 | public PacketWrapper getSpawnPacket(WrapperEntity entity) { 19 | EntityType type = entity.getEntityType(); 20 | EntitySpawningMethod method = methods.get(type); 21 | return method.getSpawnPacket(entity); 22 | } 23 | 24 | private EntitySpawningPacketConversion() {} 25 | 26 | } 27 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/packetconversion/ModernSpawningMethods.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.packetconversion; 2 | 3 | import com.github.retrooper.packetevents.manager.server.ServerVersion; 4 | import com.github.retrooper.packetevents.wrapper.PacketWrapper; 5 | import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSpawnEntity; 6 | import me.tofaa.entitylib.meta.types.ObjectData; 7 | import me.tofaa.entitylib.utils.VersionUtil; 8 | import me.tofaa.entitylib.wrapper.WrapperEntity; 9 | 10 | import java.util.Optional; 11 | 12 | final class ModernSpawningMethods { 13 | 14 | private ModernSpawningMethods() {} 15 | 16 | static class Generic implements EntitySpawningMethod { 17 | 18 | @Override 19 | public PacketWrapper getSpawnPacket(WrapperEntity entity) { 20 | if (VersionUtil.isOlderThan(ServerVersion.V_1_19_3)) throw new UnsupportedOperationException("This method is not supported in this version."); 21 | return new WrapperPlayServerSpawnEntity( 22 | entity.getEntityId(), 23 | Optional.of(entity.getUuid()), 24 | entity.getEntityType(), 25 | entity.getLocation().getPosition(), 26 | entity.getLocation().getPitch(), 27 | entity.getLocation().getYaw(), 28 | entity.getLocation().getYaw(), 29 | entity.getEntityMeta() instanceof ObjectData ? (((ObjectData) entity.getEntityMeta()).getObjectData()) : 0, 30 | entity.createVeloPacket() 31 | ); 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/storage/ByteEntitySerializer.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.storage; 2 | 3 | import me.tofaa.entitylib.wrapper.WrapperEntity; 4 | 5 | import java.nio.ByteBuffer; 6 | 7 | public class ByteEntitySerializer implements EntitySerializer { 8 | @Override 9 | public WrapperEntity read(ByteBuffer reader) { 10 | return null; 11 | } 12 | 13 | @Override 14 | public void write(ByteBuffer writer, WrapperEntity wrapper) { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/storage/EntitySerializer.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.storage; 2 | 3 | import me.tofaa.entitylib.wrapper.WrapperEntity; 4 | 5 | /** 6 | * An interface that represents a way to serialize and deserialize {@link WrapperEntity} and its subclasses. 7 | * @param the reader generic 8 | * @param the writer generic 9 | */ 10 | public interface EntitySerializer { 11 | 12 | WrapperEntity read(R reader); 13 | 14 | void write(W writer, WrapperEntity wrapper); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/storage/EntityStorage.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.storage; 2 | 3 | import me.tofaa.entitylib.wrapper.WrapperEntity; 4 | 5 | import java.util.Collection; 6 | 7 | public interface EntityStorage { 8 | 9 | 10 | Collection readAll(); 11 | 12 | void writeAll(Collection entities); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/storage/FSEntityStorage.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.storage; 2 | 3 | import me.tofaa.entitylib.wrapper.WrapperEntity; 4 | 5 | import java.util.Collection; 6 | import java.util.Collections; 7 | 8 | public class FSEntityStorage implements EntityStorage{ 9 | @Override 10 | public Collection readAll() { 11 | return Collections.emptyList(); 12 | } 13 | 14 | @Override 15 | public void writeAll(Collection entities) { 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/tick/Tickable.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.tick; 2 | 3 | public interface Tickable { 4 | 5 | /** 6 | * @return if the entity is ticking. 7 | */ 8 | boolean isTicking(); 9 | 10 | /** 11 | * Sets the entities ticking status, incase you want to stop ticking for a moment then continue 12 | * @param ticking if the entity should tick. 13 | */ 14 | void setTicking(boolean ticking); 15 | 16 | /** 17 | * Ticks this entity. This method will not be called if {@link #isTicking()} returns false. 18 | * @param time the current time in milliseconds. 19 | */ 20 | void tick(long time); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/utils/VersionUtil.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.utils; 2 | 3 | import com.github.retrooper.packetevents.manager.server.ServerVersion; 4 | import com.github.retrooper.packetevents.manager.server.VersionComparison; 5 | import me.tofaa.entitylib.EntityLib; 6 | 7 | public final class VersionUtil { 8 | 9 | private VersionUtil () {} 10 | 11 | 12 | public static boolean isNewerThanOrEqual(ServerVersion version) { 13 | return EntityLib.getApi().getPacketEvents().getServerManager().getVersion().isNewerThanOrEquals(version); 14 | } 15 | 16 | public static boolean isNewerThan(ServerVersion version) { 17 | return EntityLib.getApi().getPacketEvents().getServerManager().getVersion().isNewerThan(version); 18 | } 19 | 20 | public static boolean isOlderThanOrEqual(ServerVersion version) { 21 | return EntityLib.getApi().getPacketEvents().getServerManager().getVersion().isOlderThanOrEquals(version); 22 | } 23 | 24 | public static boolean isOlderThan(ServerVersion version) { 25 | return EntityLib.getApi().getPacketEvents().getServerManager().getVersion().isOlderThan(version); 26 | } 27 | 28 | public static boolean is(ServerVersion version) { 29 | return EntityLib.getApi().getPacketEvents().getServerManager().getVersion().is(VersionComparison.EQUALS, version); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/ve/ViewerRule.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.ve; 2 | 3 | 4 | import com.github.retrooper.packetevents.protocol.player.User; 5 | 6 | @FunctionalInterface 7 | public interface ViewerRule { 8 | 9 | boolean shouldSee(User user); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/wrapper/ai/GoalSelectorList.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.wrapper.ai; 2 | 3 | 4 | import java.util.ArrayList; 5 | import java.util.Collection; 6 | import java.util.function.UnaryOperator; 7 | 8 | final class GoalSelectorList extends ArrayList { 9 | 10 | final AIGroup aiGroup; 11 | 12 | GoalSelectorList(AIGroup aiGroup) { 13 | this.aiGroup = aiGroup; 14 | } 15 | 16 | @Override 17 | public GoalSelector set(int index, GoalSelector element) { 18 | element.setAIGroup(aiGroup); 19 | return super.set(index, element); 20 | } 21 | 22 | @Override 23 | public boolean add(GoalSelector element) { 24 | element.setAIGroup(aiGroup); 25 | return super.add(element); 26 | } 27 | 28 | @Override 29 | public void add(int index, GoalSelector element) { 30 | element.setAIGroup(aiGroup); 31 | super.add(index, element); 32 | } 33 | 34 | @Override 35 | public boolean addAll(Collection c) { 36 | c.forEach(goalSelector -> goalSelector.setAIGroup(aiGroup)); 37 | return super.addAll(c); 38 | } 39 | 40 | @Override 41 | public boolean addAll(int index, Collection c) { 42 | c.forEach(goalSelector -> goalSelector.setAIGroup(aiGroup)); 43 | return super.addAll(index, c); 44 | } 45 | 46 | @Override 47 | public void replaceAll(UnaryOperator operator) { 48 | super.replaceAll(goalSelector -> { 49 | goalSelector = operator.apply(goalSelector); 50 | goalSelector.setAIGroup(aiGroup); 51 | return goalSelector; 52 | }); 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /api/src/main/java/me/tofaa/entitylib/wrapper/spawning/SpawnPacketProvider.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.wrapper.spawning; 2 | 3 | import com.github.retrooper.packetevents.protocol.player.User; 4 | import com.github.retrooper.packetevents.wrapper.PacketWrapper; 5 | import me.tofaa.entitylib.wrapper.WrapperEntity; 6 | 7 | @FunctionalInterface 8 | public interface SpawnPacketProvider> extends SpawnPacketProviders { 9 | 10 | T provide(WrapperEntity entity); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /block-bench-addon/README.md: -------------------------------------------------------------------------------- 1 | Block Bench addon for EntityLib 2 | 3 | Gives complete support of making block bench bedrock compatible models in EntityLib, with animations. 4 | This is a direct port of the WorldSeedEntityEngine made by my good pal iam https://github.com/AtlasEngineCa/WorldSeedEntityEngine/blob/master. Permission was granted to port this repository to EntityLib by iam himself. 5 | -------------------------------------------------------------------------------- /block-bench-addon/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | entitylib.`shadow-conventions` 3 | entitylib.`library-conventions` 4 | } 5 | 6 | repositories { 7 | maven { 8 | url = uri("https://mvn.lumine.io/repository/maven-public/") 9 | } 10 | maven("https://jitpack.io") 11 | } 12 | 13 | dependencies { 14 | api(project(":api")) 15 | compileOnly(libs.packetevents.api) 16 | compileOnly(libs.gson) 17 | implementation("commons-io:commons-io:2.11.0") 18 | implementation("org.zeroturnaround:zt-zip:1.8") 19 | 20 | implementation("javax.json:javax.json-api:1.1.4") 21 | implementation("org.glassfish:javax.json:1.1.4") 22 | 23 | implementation("com.github.hollow-cube.common:mql:2b48ad430f") 24 | } 25 | -------------------------------------------------------------------------------- /block-bench-addon/src/main/java/me/tofaa/entitylib/bb/animation/FrameProvider.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.bb.animation; 2 | 3 | 4 | import com.github.retrooper.packetevents.util.Vector3d; 5 | 6 | public interface FrameProvider { 7 | Vector3d RotationMul = new Vector3d(-1, -1, 1); 8 | Vector3d TranslationMul = new Vector3d(-1, 1, 1); 9 | 10 | Vector3d getFrame(int tick); 11 | } -------------------------------------------------------------------------------- /block-bench-addon/src/main/java/me/tofaa/entitylib/bb/mql/MQLData.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.bb.mql; 2 | 3 | import net.hollowcube.mql.foreign.Query; 4 | 5 | public class MQLData { 6 | private double time; 7 | 8 | public void setTime(double time) { 9 | this.time = time; 10 | } 11 | 12 | @Query 13 | public double anim_time() { 14 | return time; 15 | } 16 | } -------------------------------------------------------------------------------- /block-bench-addon/src/main/java/me/tofaa/entitylib/bb/mql/MQLEvaluator.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.bb.mql; 2 | 3 | import net.hollowcube.mql.jit.MqlEnv; 4 | 5 | public interface MQLEvaluator { 6 | double evaluate(@MqlEnv({"q", "query"}) MQLData data); 7 | } -------------------------------------------------------------------------------- /buildSrc/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | 5 | kotlin { 6 | compilerOptions { 7 | jvmToolchain(8) 8 | } 9 | } 10 | 11 | repositories { 12 | gradlePluginPortal() 13 | mavenCentral() 14 | } 15 | 16 | dependencies { 17 | implementation(libs.shadow) 18 | } -------------------------------------------------------------------------------- /buildSrc/libs.versions.toml: -------------------------------------------------------------------------------- 1 | [versions] 2 | shadow = "8.3.0" 3 | 4 | [libraries] 5 | shadow = { group = "com.gradleup.shadow", name = "shadow-gradle-plugin", version.ref = "shadow" } -------------------------------------------------------------------------------- /buildSrc/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | versionCatalogs { 3 | create("libs") { 4 | from(files("libs.versions.toml")) 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/entitylib.shadow-conventions.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | java 3 | com.gradleup.shadow 4 | } 5 | 6 | tasks { 7 | shadowJar { 8 | archiveFileName = "EntityLib-${project.name}-${rootProject.ext["versionNoHash"]}.jar" 9 | archiveClassifier = null 10 | 11 | mergeServiceFiles() 12 | } 13 | 14 | assemble { 15 | dependsOn(shadowJar) 16 | } 17 | } 18 | 19 | configurations.implementation.get().extendsFrom(configurations.shadow.get()) -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/me/tofaa/entitylib/version/ELVersionPlugin.kt: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.version 2 | 3 | import org.gradle.api.Plugin 4 | import org.gradle.api.Project 5 | import org.gradle.api.tasks.SourceSet 6 | import org.gradle.api.tasks.SourceSetContainer 7 | import org.gradle.kotlin.dsl.getByName 8 | import org.gradle.kotlin.dsl.register 9 | 10 | class ELVersionPlugin : Plugin { 11 | 12 | override fun apply(target: Project) { 13 | val task = target.tasks.register(ELVersionTask.TASK_NAME) { 14 | group = target.rootProject.name.toString() 15 | 16 | version = target.version.toString() 17 | outputDir = target.layout.buildDirectory.dir("generated/sources/src/java/main") 18 | } 19 | 20 | target.afterEvaluate { 21 | val sourceSets = target.extensions.getByName("sourceSets") 22 | 23 | sequenceOf(SourceSet.MAIN_SOURCE_SET_NAME, SourceSet.TEST_SOURCE_SET_NAME).forEach { 24 | sourceSets.getByName(it).java.srcDir(task.flatMap { it.outputDir }) 25 | } 26 | 27 | task.get().generate() 28 | } 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /buildSrc/src/main/resources/META-INF/gradle-plugins/el-version.properties: -------------------------------------------------------------------------------- 1 | implementation-class=me.tofaa.entitylib.version.ELVersionPlugin -------------------------------------------------------------------------------- /code-gen/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | entitylib.`library-conventions` 3 | entitylib.`shadow-conventions` 4 | } 5 | 6 | dependencies { 7 | implementation(libs.gson) 8 | implementation(libs.javapoet) 9 | implementation(libs.packetevents.api) 10 | implementation(libs.jetbrains.annotations) 11 | } 12 | -------------------------------------------------------------------------------- /code-gen/src/main/java/me/tofaa/entitylib/codegen/MetaOffset.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.codegen; 2 | 3 | public final class MetaOffset { 4 | 5 | private String name; 6 | private VersionCheck[] checks; 7 | 8 | public MetaOffset(String name, VersionCheck[] checks) { 9 | this.name = name; 10 | this.checks = checks; 11 | } 12 | 13 | public String name() { 14 | return name; 15 | } 16 | 17 | public VersionCheck[] checks() { 18 | return checks; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /code-gen/src/main/java/me/tofaa/entitylib/codegen/TypeHolder.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.codegen; 2 | 3 | public final class TypeHolder { 4 | 5 | private String className; 6 | private MetaOffset[] offsets; 7 | 8 | public TypeHolder(String className, MetaOffset[] offsets) { 9 | this.className = className; 10 | this.offsets = offsets; 11 | } 12 | 13 | 14 | public String className() { 15 | return className; 16 | } 17 | 18 | public MetaOffset[] offsets() { 19 | return offsets; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /code-gen/src/main/java/me/tofaa/entitylib/codegen/VersionCheck.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.codegen; 2 | 3 | public final class VersionCheck { 4 | 5 | private int from; 6 | private int to; 7 | private byte offset; 8 | 9 | public VersionCheck(int from, int to, byte offset) { 10 | this.from = from; 11 | this.to = to; 12 | this.offset = offset; 13 | } 14 | 15 | public int from() { 16 | return from; 17 | } 18 | 19 | public int to() { 20 | return to; 21 | } 22 | 23 | public byte offset() { 24 | return offset; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /code-gen/src/main/java/me/tofaa/entitylib/codegen/modern/Main.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.codegen.modern; 2 | 3 | public final class Main { 4 | 5 | private Main() {} 6 | 7 | } 8 | -------------------------------------------------------------------------------- /common/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | entitylib.`shadow-conventions` 3 | entitylib.`library-conventions` 4 | } 5 | 6 | dependencies { 7 | api(project(":api")) 8 | compileOnly(libs.bundles.adventure) 9 | compileOnly(libs.packetevents.api) 10 | } 11 | -------------------------------------------------------------------------------- /common/src/main/java/me/tofaa/entitylib/common/AbstractPlatform.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.common; 2 | 3 | import me.tofaa.entitylib.*; 4 | import me.tofaa.entitylib.event.EventHandler; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | import java.util.logging.Logger; 9 | import java.util.stream.Stream; 10 | 11 | public abstract class AbstractPlatform

implements Platform

{ 12 | 13 | 14 | protected final P handle; 15 | protected Logger logger; 16 | private EventHandler eventHandler; 17 | private EntityIdProvider entityIdProvider; 18 | private EntityUuidProvider entityUuidProvider; 19 | 20 | public AbstractPlatform(P handle) { 21 | this.handle = handle; 22 | this.entityIdProvider = new EntityIdProvider.DefaultEntityIdProvider(); 23 | this.entityUuidProvider = new EntityUuidProvider.DefaultEntityUuidProvider(); 24 | } 25 | 26 | @Override 27 | public void setupApi(@NotNull APIConfig settings) { 28 | this.eventHandler = EventHandler.create(); 29 | this.entityIdProvider = new EntityIdProvider.DefaultEntityIdProvider(); 30 | this.entityUuidProvider = new EntityUuidProvider.DefaultEntityUuidProvider(); 31 | } 32 | 33 | @NotNull 34 | @Override 35 | public Logger getLogger() { 36 | return logger; 37 | } 38 | 39 | @NotNull 40 | @Override 41 | public EntityIdProvider getEntityIdProvider() { 42 | return entityIdProvider; 43 | } 44 | 45 | @NotNull 46 | @Override 47 | public EntityUuidProvider getEntityUuidProvider() { 48 | return entityUuidProvider; 49 | } 50 | 51 | @Override 52 | public void setEntityIdProvider(@NotNull EntityIdProvider entityIdProvider) { 53 | this.entityIdProvider = entityIdProvider; 54 | } 55 | 56 | @Override 57 | public void setEntityUuidProvider(@NotNull EntityUuidProvider entityUuidProvider) { 58 | this.entityUuidProvider = entityUuidProvider; 59 | } 60 | 61 | @NotNull 62 | @Override 63 | public EventHandler getEventHandler() { 64 | return eventHandler; 65 | } 66 | 67 | @NotNull 68 | @Override 69 | public P getHandle() { 70 | return handle; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /discord-bot/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | entitylib.`shadow-conventions` 3 | entitylib.`library-conventions` 4 | } 5 | 6 | java { 7 | toolchain.languageVersion = JavaLanguageVersion.of(21) 8 | } 9 | 10 | dependencies { 11 | implementation("net.dv8tion:JDA:5.2.0") 12 | implementation("ch.qos.logback:logback-classic:1.4.12") 13 | 14 | implementation("com.google.auto.service:auto-service:1.1.1") 15 | annotationProcessor("com.google.auto.service:auto-service:1.1.1") 16 | } -------------------------------------------------------------------------------- /discord-bot/src/main/java/me/tofaa/entitylib/discord/commands/Command.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.discord.commands; 2 | 3 | import net.dv8tion.jda.api.Permission; 4 | import net.dv8tion.jda.api.interactions.Interaction; 5 | import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction; 6 | import net.dv8tion.jda.api.interactions.commands.build.OptionData; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | import java.util.Collection; 10 | 11 | public abstract class Command { 12 | 13 | private final String name; 14 | private final String description; 15 | private final Collection options; 16 | private final Permission permission; 17 | 18 | public Command(String name, String description, Collection options, @Nullable Permission permission) { 19 | this.name = name; 20 | this.description = description; 21 | this.options = options; 22 | this.permission = permission; 23 | } 24 | 25 | public Permission permission() { 26 | return permission; 27 | } 28 | 29 | public boolean hasPermission() { 30 | return permission != null; 31 | } 32 | 33 | public String name() { 34 | return name; 35 | } 36 | 37 | public String description() { 38 | return description; 39 | } 40 | 41 | public Collection options() { 42 | return options; 43 | } 44 | 45 | public abstract void handle(SlashCommandInteraction interaction); 46 | 47 | } 48 | -------------------------------------------------------------------------------- /discord-bot/src/main/java/me/tofaa/entitylib/discord/commands/impl/PingCommand.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.discord.commands.impl; 2 | 3 | import com.google.auto.service.AutoService; 4 | import me.tofaa.entitylib.discord.commands.Command; 5 | import net.dv8tion.jda.api.interactions.Interaction; 6 | import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction; 7 | 8 | import java.util.Collections; 9 | 10 | @AutoService(Command.class) 11 | public class PingCommand extends Command { 12 | 13 | public PingCommand() { 14 | super("ping", "Ping command", Collections.emptyList(), null); 15 | } 16 | 17 | @Override 18 | public void handle(SlashCommandInteraction interaction) { 19 | interaction.reply("Pong").queue(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /discord-bot/src/main/java/me/tofaa/entitylib/discord/commands/impl/SendMessageCommand.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.discord.commands.impl; 2 | 3 | import com.google.auto.service.AutoService; 4 | import me.tofaa.entitylib.discord.commands.Command; 5 | import net.dv8tion.jda.api.Permission; 6 | import net.dv8tion.jda.api.interactions.commands.OptionType; 7 | import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction; 8 | import net.dv8tion.jda.api.interactions.commands.build.OptionData; 9 | import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; 10 | 11 | import java.util.Arrays; 12 | import java.util.List; 13 | 14 | @AutoService(Command.class) 15 | public class SendMessageCommand extends Command { 16 | 17 | public SendMessageCommand() { 18 | super( 19 | "sendmessage", 20 | "Send a message in a channel", 21 | Arrays.asList( 22 | new OptionData(OptionType.STRING, "message", "The message", true), 23 | new OptionData(OptionType.STRING, "ping", "The type of ping to do", true) 24 | .addChoice("Everyone", "everyone") 25 | .addChoice("EntityLib", "elib") 26 | ), 27 | Permission.ADMINISTRATOR 28 | ); 29 | } 30 | 31 | @Override 32 | public void handle(SlashCommandInteraction interaction) { 33 | String msg = interaction.getOption("message").getAsString(); 34 | MessageCreateBuilder builder =new MessageCreateBuilder(); 35 | builder.setContent(msg); 36 | 37 | String pingType = interaction.getOption("ping").getAsString().toLowerCase(); 38 | switch (pingType) { 39 | case "elib": { 40 | builder =builder.mentionRoles(1304607456650985502L); 41 | break; 42 | } 43 | case "everyone": { 44 | builder =builder.mentionRoles(1197504277787201616L); 45 | break; 46 | } 47 | default: {} 48 | } 49 | interaction.getChannel().sendMessage(builder.build()).queue();; 50 | interaction.reply("Sent").setEphemeral(true).queue(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /discord-bot/src/main/java/me/tofaa/entitylib/discord/listeners/CommandListener.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.discord.listeners; 2 | 3 | import com.google.auto.service.AutoService; 4 | import me.tofaa.entitylib.discord.DiscordBot; 5 | import me.tofaa.entitylib.discord.commands.Command; 6 | import net.dv8tion.jda.api.events.GenericEvent; 7 | import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; 8 | import net.dv8tion.jda.api.hooks.EventListener; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | @AutoService(EventListener.class) 12 | public class CommandListener implements EventListener { 13 | 14 | @Override 15 | public void onEvent(@NotNull GenericEvent genericEvent) { 16 | if (!(genericEvent instanceof SlashCommandInteractionEvent)) { 17 | return; 18 | } 19 | SlashCommandInteractionEvent event = (SlashCommandInteractionEvent) genericEvent; 20 | Command command = DiscordBot.instance().commands().stream() 21 | .filter(f -> f.name().equalsIgnoreCase(event.getName())) 22 | .findAny().orElse(null); 23 | if (command == null) { 24 | return; 25 | } 26 | command.handle(event.getInteraction()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /discord-bot/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %d{HH:mm:ss.SSS} %boldCyan(%-34.-34thread) %boldGreen(%-15.-15logger{0}) %highlight(%-6level) %msg%n 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tofaa2/EntityLib/2a15c882db2444f5aa589a7448ebcf52834351fc/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Nov 27 02:38:48 TRT 2023 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /libs.versions.toml: -------------------------------------------------------------------------------- 1 | [versions] 2 | adventure = "4.16.0" 3 | jetbrains-annotations = "24.0.0" 4 | gson = "2.11.0" 5 | packetevents = "2.7.0" 6 | paper = "1.21-R0.1-SNAPSHOT" 7 | velocity = "3.3.0-SNAPSHOT" 8 | run-paper = "2.3.0" 9 | javapoet = "1.13.0" 10 | 11 | [libraries] 12 | adventure-api = { group = "net.kyori", name = "adventure-api", version.ref = "adventure" } 13 | adventure-text-serializer-gson = { group = "net.kyori", name = "adventure-text-serializer-gson", version.ref = "adventure" } 14 | adventure-text-serializer-legacy = { group = "net.kyori", name = "adventure-text-serializer-legacy", version.ref = "adventure" } 15 | adventure-text-serializer-gson-legacy = { group = "net.kyori", name = "adventure-text-serializer-gson-legacy-impl", version.ref = "adventure" } 16 | adventure-nbt = { group = "net.kyori", name = "adventure-nbt", version.ref = "adventure" } 17 | jetbrains-annotations = { group = "org.jetbrains", name = "annotations", version.ref = "jetbrains-annotations" } 18 | gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" } 19 | packetevents-api = { group = "com.github.retrooper", name = "packetevents-api", version.ref = "packetevents" } 20 | packetevents-spigot = { group = "com.github.retrooper", name = "packetevents-spigot", version.ref = "packetevents" } 21 | packetevents-velocity = { group = "com.github.retrooper", name = "packetevents-velocity", version.ref = "packetevents" } 22 | paper = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" } 23 | velocity = { group = "com.velocitypowered", name = "velocity-api", version.ref = "velocity" } 24 | javapoet = { group = "com.squareup", name = "javapoet", version.ref = "javapoet" } 25 | 26 | [bundles] 27 | adventure = ["adventure-api", "adventure-text-serializer-gson", "adventure-text-serializer-legacy", "adventure-nbt"] 28 | 29 | [plugins] 30 | run-paper = { id = "xyz.jpenilla.run-paper", version.ref = "run-paper" } 31 | run-velocity = { id = "xyz.jpenilla.run-velocity", version.ref = "run-paper" } -------------------------------------------------------------------------------- /platforms/spigot/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | entitylib.`shadow-conventions` 3 | entitylib.`library-conventions` 4 | } 5 | 6 | repositories { 7 | maven("https://repo.papermc.io/repository/maven-public/") 8 | } 9 | 10 | dependencies { 11 | api(project(":common")) 12 | compileOnly(libs.paper) 13 | compileOnly(libs.packetevents.spigot) 14 | } 15 | -------------------------------------------------------------------------------- /platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibPlatform.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.spigot; 2 | 3 | import com.github.retrooper.packetevents.PacketEventsAPI; 4 | import io.github.retrooper.packetevents.bstats.bukkit.Metrics; 5 | import io.github.retrooper.packetevents.bstats.charts.SimplePie; 6 | import me.tofaa.entitylib.APIConfig; 7 | import me.tofaa.entitylib.EntityLib; 8 | import me.tofaa.entitylib.common.AbstractPlatform; 9 | import me.tofaa.entitylib.utils.ConcurrentWeakIdentityHashMap; 10 | import org.bukkit.Bukkit; 11 | import org.bukkit.World; 12 | import org.bukkit.entity.Entity; 13 | import org.bukkit.plugin.Plugin; 14 | import org.bukkit.plugin.java.JavaPlugin; 15 | import org.jetbrains.annotations.NotNull; 16 | import org.jetbrains.annotations.Nullable; 17 | 18 | import java.util.Map; 19 | import java.util.logging.Logger; 20 | import java.util.stream.Stream; 21 | 22 | public class SpigotEntityLibPlatform extends AbstractPlatform { 23 | 24 | private SpigotEntityLibAPI api; 25 | 26 | public SpigotEntityLibPlatform(@NotNull JavaPlugin plugin) { 27 | super(plugin); 28 | } 29 | 30 | @Override 31 | public void setupApi(@NotNull APIConfig settings) { 32 | super.setupApi(settings); 33 | this.logger = settings.shouldUsePlatformLogger() ? handle.getLogger() : Logger.getLogger("EntityLib"); 34 | this.api = new SpigotEntityLibAPI(this, settings); 35 | this.setEntityIdProvider(new SpigotEntityIdProvider(this)); 36 | this.api.onLoad(); 37 | this.api.onEnable(); 38 | if (settings.shouldUseBstats()) { 39 | PacketEventsAPI pe = (PacketEventsAPI)api.getPacketEvents(); 40 | Metrics metrics = new Metrics(pe.getPlugin(), 21916); 41 | metrics.addCustomChart(new SimplePie("entitylib-version", () -> EntityLib.getVersion().toString())); 42 | } 43 | 44 | } 45 | 46 | @Override 47 | public SpigotEntityLibAPI getAPI() { 48 | return api; 49 | } 50 | 51 | @Override 52 | public String getName() { 53 | return "Spigot"; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /platforms/standalone/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | entitylib.`shadow-conventions` 3 | entitylib.`library-conventions` 4 | } 5 | 6 | dependencies { 7 | api(project(":common")) 8 | compileOnly(libs.packetevents.api) 9 | } 10 | -------------------------------------------------------------------------------- /platforms/standalone/src/main/java/me/tofaa/entitylib/standalone/StandaloneEntityLibApi.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.standalone; 2 | 3 | import com.github.retrooper.packetevents.protocol.world.Location; 4 | import me.tofaa.entitylib.APIConfig; 5 | import me.tofaa.entitylib.Platform; 6 | import me.tofaa.entitylib.common.AbstractEntityLibAPI; 7 | import me.tofaa.entitylib.standalone.task.ExecutionType; 8 | import me.tofaa.entitylib.standalone.task.Scheduler; 9 | import me.tofaa.entitylib.standalone.task.Task; 10 | import me.tofaa.entitylib.standalone.task.TaskSchedule; 11 | import me.tofaa.entitylib.tick.TickContainer; 12 | import me.tofaa.entitylib.wrapper.WrapperEntity; 13 | import org.jetbrains.annotations.NotNull; 14 | 15 | import java.util.logging.Level; 16 | 17 | public class StandaloneEntityLibApi extends AbstractEntityLibAPI { 18 | 19 | private final Scheduler scheduler = Scheduler.newScheduler(); 20 | 21 | protected StandaloneEntityLibApi(Platform platform, APIConfig settings) { 22 | super(platform, settings); 23 | } 24 | 25 | @Override 26 | public void onLoad() { 27 | 28 | } 29 | 30 | @Override 31 | public void onEnable() { 32 | 33 | } 34 | 35 | 36 | @Override 37 | public

@NotNull P cloneEntity(@NotNull Object platformEntity) { 38 | throw new UnsupportedOperationException("Not supported in standalone mode"); 39 | } 40 | 41 | @Override 42 | public void addTickContainer(@NotNull TickContainer tickContainer) { 43 | if (!settings.shouldTickTickables()) { 44 | if (settings.isDebugMode()) { 45 | platform.getLogger().log(Level.WARNING, "Tried to add a TickContainer when ticking tickables is disabled!"); 46 | } 47 | return; 48 | } 49 | tickContainers.add(tickContainer); 50 | if (settings.isDebugMode()) { 51 | platform.getLogger().log(Level.CONFIG, "Registering new tick container..."); 52 | } 53 | getTickContainers().add(tickContainer); 54 | Task task = scheduler.scheduleTask(() -> tickContainer.tick(System.currentTimeMillis()), TaskSchedule.duration(50L), TaskSchedule.duration(50L), ExecutionType.ASYNC); 55 | tickContainer.setHandle(task); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /platforms/standalone/src/main/java/me/tofaa/entitylib/standalone/StandaloneEntityLibPlatform.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.standalone; 2 | 3 | import me.tofaa.entitylib.APIConfig; 4 | import me.tofaa.entitylib.EntityLibAPI; 5 | import me.tofaa.entitylib.common.AbstractPlatform; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class StandaloneEntityLibPlatform extends AbstractPlatform { 9 | 10 | 11 | private StandaloneEntityLibApi api; 12 | 13 | public StandaloneEntityLibPlatform() { 14 | super(null); 15 | } 16 | 17 | @Override 18 | public void setupApi(@NotNull APIConfig settings) { 19 | super.setupApi(settings); 20 | api = new StandaloneEntityLibApi(this, settings); 21 | } 22 | 23 | @Override 24 | public @NotNull Object getHandle() { 25 | throw new UnsupportedOperationException("Standalone platform does not have a handle."); 26 | } 27 | 28 | @Override 29 | public EntityLibAPI getAPI() { 30 | return api; 31 | } 32 | 33 | @Override 34 | public String getName() { 35 | return "Standalone"; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /platforms/standalone/src/main/java/me/tofaa/entitylib/standalone/task/ExecutionType.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.standalone.task; 2 | 3 | public enum ExecutionType { 4 | 5 | BLOCKING, 6 | ASYNC, 7 | 8 | } 9 | -------------------------------------------------------------------------------- /platforms/standalone/src/main/java/me/tofaa/entitylib/standalone/task/Scheduler.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.standalone.task; 2 | 3 | import java.util.function.Supplier; 4 | 5 | public interface Scheduler { 6 | 7 | static Scheduler newScheduler() { 8 | return new SchedulerImpl(); 9 | } 10 | 11 | void process(); 12 | 13 | void shutdown(); 14 | 15 | Task submitTask(Supplier supplier, ExecutionType type); 16 | 17 | default Task scheduleTask(Runnable task, TaskSchedule delay, TaskSchedule repeat, ExecutionType type) { 18 | return buildTask(task) 19 | .delay(delay) 20 | .repeat(repeat) 21 | .executionType(type) 22 | .schedule(); 23 | } 24 | 25 | default Task.Builder buildTask(Runnable task) { 26 | return new Task.Builder(task, this); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /platforms/standalone/src/main/java/me/tofaa/entitylib/standalone/task/Task.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.standalone.task; 2 | 3 | import java.util.concurrent.atomic.AtomicBoolean; 4 | 5 | public interface Task { 6 | 7 | 8 | int id(); 9 | 10 | ExecutionType executionType(); 11 | 12 | void unpark(); 13 | boolean isParked(); 14 | 15 | void cancel(); 16 | 17 | 18 | class Builder { 19 | 20 | private final Runnable runnable; 21 | private final Scheduler scheduler; 22 | 23 | private ExecutionType executionType = ExecutionType.BLOCKING;//default 24 | private TaskSchedule delay = TaskSchedule.immediate(); 25 | private TaskSchedule repeat = TaskSchedule.stop(); 26 | 27 | Builder(Runnable runnable, Scheduler scheduler) { 28 | this.runnable = runnable; 29 | this.scheduler = scheduler; 30 | } 31 | 32 | public Builder executionType(ExecutionType executionType) { 33 | this.executionType = executionType; 34 | return this; 35 | } 36 | 37 | public Builder delay(TaskSchedule delay) { 38 | this.delay = delay; 39 | return this; 40 | } 41 | 42 | public Builder repeat(TaskSchedule repeat) { 43 | this.repeat = repeat; 44 | return this; 45 | } 46 | 47 | public Task schedule() { 48 | AtomicBoolean first = new AtomicBoolean(); 49 | return scheduler.submitTask(() -> { 50 | if (first.get()) { 51 | first.set(false); 52 | return delay; 53 | } 54 | runnable.run(); 55 | return repeat; 56 | }, executionType); 57 | } 58 | 59 | 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /platforms/velocity/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | entitylib.`shadow-conventions` 3 | entitylib.`library-conventions` 4 | } 5 | 6 | repositories { 7 | maven("https://repo.papermc.io/repository/maven-public/") 8 | } 9 | 10 | dependencies { 11 | api(project(":common")) 12 | compileOnly(libs.velocity) 13 | compileOnly(libs.packetevents.velocity) 14 | annotationProcessor(libs.velocity) 15 | } 16 | 17 | tasks { 18 | withType { 19 | options.encoding = Charsets.UTF_8.name() 20 | options.release = 17 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /platforms/velocity/src/main/java/me/tofaa/entitylib/velocity/VelocityEntityLibAPI.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.velocity; 2 | 3 | import com.velocitypowered.api.proxy.ProxyServer; 4 | import com.velocitypowered.api.scheduler.ScheduledTask; 5 | import me.tofaa.entitylib.APIConfig; 6 | import me.tofaa.entitylib.common.AbstractEntityLibAPI; 7 | import me.tofaa.entitylib.tick.TickContainer; 8 | import me.tofaa.entitylib.wrapper.WrapperEntity; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | import java.util.concurrent.TimeUnit; 12 | import java.util.logging.Level; 13 | 14 | public class VelocityEntityLibAPI extends AbstractEntityLibAPI { 15 | 16 | 17 | public VelocityEntityLibAPI(VelocityEntityLibPlatform platform, APIConfig settings) { 18 | super(platform, settings); 19 | } 20 | 21 | @Override 22 | public void onLoad() { 23 | 24 | } 25 | 26 | @Override 27 | public void onEnable() { 28 | 29 | } 30 | 31 | @Override 32 | public void addTickContainer(@NotNull TickContainer tickContainer) { 33 | if (!settings.shouldTickTickables()) { 34 | if (settings.isDebugMode()) { 35 | platform.getLogger().log(Level.WARNING, "Tried to add a TickContainer when ticking tickables is disabled!"); 36 | } 37 | return; 38 | } 39 | tickContainers.add(tickContainer); 40 | if (settings.isDebugMode()) { 41 | platform.getLogger().log(Level.CONFIG, "Registering new tick container..."); 42 | } 43 | getTickContainers().add(tickContainer); 44 | Object plugin = ((VelocityEntityLibPlatform)platform).getPlugin(); 45 | ScheduledTask task = platform.getHandle().getScheduler().buildTask(plugin, () -> tickContainer.tick(System.currentTimeMillis())).repeat(50L, TimeUnit.MILLISECONDS).schedule(); 46 | tickContainer.setHandle(task); 47 | } 48 | 49 | @NotNull 50 | @Override 51 | public

P cloneEntity(@NotNull Object platformEntity) { 52 | throw new UnsupportedOperationException("No support for cloning entities on Velocity"); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /platforms/velocity/src/main/java/me/tofaa/entitylib/velocity/VelocityEntityLibPlatform.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.entitylib.velocity; 2 | 3 | import com.github.retrooper.packetevents.PacketEventsAPI; 4 | import com.github.retrooper.packetevents.protocol.packettype.PacketType; 5 | import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerBlockAction; 6 | import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerBlockChange; 7 | import com.velocitypowered.api.plugin.PluginContainer; 8 | import com.velocitypowered.api.proxy.ProxyServer; 9 | import io.github.retrooper.packetevents.velocity.factory.VelocityPacketEventsBuilder; 10 | import me.tofaa.entitylib.APIConfig; 11 | import me.tofaa.entitylib.EntityLibAPI; 12 | import me.tofaa.entitylib.common.AbstractPlatform; 13 | import org.jetbrains.annotations.NotNull; 14 | 15 | import java.util.logging.Logger; 16 | 17 | public class VelocityEntityLibPlatform extends AbstractPlatform { 18 | private VelocityEntityLibAPI api; 19 | private Object plugin; 20 | 21 | public VelocityEntityLibPlatform(Object plugin, ProxyServer handle) { 22 | super(handle); 23 | this.plugin = plugin; 24 | } 25 | 26 | @Override 27 | public void setupApi(@NotNull APIConfig settings) { 28 | super.setupApi(settings); 29 | this.logger = Logger.getLogger("EntityLib"); // Velocity does not have a logger by default. 30 | this.api = new VelocityEntityLibAPI(this, settings); 31 | this.api.onLoad(); 32 | this.api.onEnable(); 33 | // if (settings.shouldUseBstats()) { 34 | // VelocityPacketEventsBuilder 35 | // PacketEventsAPI pe = (PacketEventsAPI) api.getPacketEvents(); 36 | // Metrics metrics = Metrics.createInstance( 37 | // plugin, 38 | // handle, 39 | // logger, 40 | // pe.getSettings(). 41 | // } 42 | } 43 | 44 | public Object getPlugin() { 45 | return plugin; 46 | } 47 | 48 | @Override 49 | public EntityLibAPI getAPI() { 50 | return api; 51 | } 52 | 53 | @Override 54 | public String getName() { 55 | return "Velocity"; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | mavenCentral() 4 | gradlePluginPortal() 5 | } 6 | } 7 | 8 | plugins { 9 | id("org.gradle.toolchains.foojay-resolver") version "0.8.0" 10 | } 11 | 12 | toolchainManagement { 13 | jvm { 14 | javaRepositories { 15 | repository("foojay") { 16 | resolverClass.set(org.gradle.toolchains.foojay.FoojayToolchainResolver::class.java) 17 | } 18 | } 19 | } 20 | } 21 | 22 | dependencyResolutionManagement { 23 | versionCatalogs { 24 | create("libs") { 25 | from(files("libs.versions.toml")) 26 | } 27 | } 28 | } 29 | 30 | rootProject.name = "EntityLib" 31 | include(":common") 32 | include(":api") 33 | include(":platforms:spigot") 34 | include(":platforms:velocity") 35 | include(":platforms:standalone") 36 | 37 | if (System.getenv("PRIVATE").toBoolean()) { 38 | include("discord-bot") 39 | include(":code-gen") 40 | include(":test-plugin") 41 | include(":block-bench-addon") 42 | } 43 | -------------------------------------------------------------------------------- /test-plugin/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build/ 3 | !gradle/wrapper/gradle-wrapper.jar 4 | !**/src/main/**/build/ 5 | !**/src/test/**/build/ 6 | 7 | run 8 | 9 | ### IntelliJ IDEA ### 10 | .idea/modules.xml 11 | .idea/jarRepositories.xml 12 | .idea/compiler.xml 13 | .idea/libraries/ 14 | *.iws 15 | *.iml 16 | *.ipr 17 | out/ 18 | !**/src/main/**/out/ 19 | !**/src/test/**/out/ 20 | 21 | ### Eclipse ### 22 | .apt_generated 23 | .classpath 24 | .factorypath 25 | .project 26 | .settings 27 | .springBeans 28 | .sts4-cache 29 | bin/ 30 | !**/src/main/**/bin/ 31 | !**/src/test/**/bin/ 32 | 33 | ### NetBeans ### 34 | /nbproject/private/ 35 | /nbbuild/ 36 | /dist/ 37 | /nbdist/ 38 | /.nb-gradle/ 39 | 40 | ### VS Code ### 41 | .vscode/ 42 | 43 | ### Mac OS ### 44 | .DS_Store -------------------------------------------------------------------------------- /test-plugin/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | entitylib.`shadow-conventions` 3 | entitylib.`library-conventions` 4 | alias(libs.plugins.run.paper) 5 | } 6 | 7 | repositories { 8 | maven("https://maven.evokegames.gg/snapshots") 9 | maven("https://repo.papermc.io/repository/maven-public/") 10 | } 11 | 12 | dependencies { 13 | compileOnly(libs.paper) 14 | compileOnly(libs.packetevents.spigot) 15 | implementation(project(":platforms:spigot")) 16 | // implementation(project(":platforms:spigot")) 17 | } 18 | 19 | tasks { 20 | // 1.8.8 - 1.16.5 = Java 8 21 | // 1.17 = Java 16 22 | // 1.18 - 1.20.4 = Java 17 23 | // 1-20.5+ = Java 21 24 | val version = "1.21.3" 25 | val javaVersion = JavaLanguageVersion.of(21) 26 | 27 | val jvmArgsExternal = listOf( 28 | "-Dcom.mojang.eula.agree=true" 29 | ) 30 | 31 | val sharedBukkitPlugins = runPaper.downloadPluginsSpec { 32 | modrinth("packetevents", "3Jr8ovul") 33 | } 34 | 35 | runServer { 36 | minecraftVersion(version) 37 | runDirectory = rootDir.resolve("run/paper/$version") 38 | 39 | javaLauncher = project.javaToolchains.launcherFor { 40 | languageVersion = javaVersion 41 | } 42 | 43 | downloadPlugins { 44 | from(sharedBukkitPlugins) 45 | } 46 | 47 | jvmArgs = jvmArgsExternal 48 | } 49 | 50 | runPaper.folia.registerTask { 51 | minecraftVersion(version) 52 | runDirectory = rootDir.resolve("run/folia/$version") 53 | 54 | javaLauncher = project.javaToolchains.launcherFor { 55 | languageVersion = javaVersion 56 | } 57 | 58 | downloadPlugins { 59 | from(sharedBukkitPlugins) 60 | } 61 | 62 | jvmArgs = jvmArgsExternal 63 | } 64 | } -------------------------------------------------------------------------------- /test-plugin/src/main/java/me/tofaa/testentitylib/TestEntityLibPlugin.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.testentitylib; 2 | 3 | import com.github.retrooper.packetevents.PacketEvents; 4 | import me.tofaa.entitylib.APIConfig; 5 | import me.tofaa.entitylib.EntityLib; 6 | import me.tofaa.entitylib.spigot.SpigotEntityLibPlatform; 7 | import org.bukkit.Bukkit; 8 | import org.bukkit.command.CommandMap; 9 | import org.bukkit.plugin.java.JavaPlugin; 10 | 11 | import java.lang.reflect.InvocationTargetException; 12 | import java.text.DateFormat; 13 | 14 | public class TestEntityLibPlugin extends JavaPlugin { 15 | 16 | @Override 17 | public void onEnable() { 18 | DateFormat.getDateTimeInstance().format(new java.util.Date(timestamp)); 19 | 20 | SpigotEntityLibPlatform platform = new SpigotEntityLibPlatform(this); 21 | APIConfig settings = new APIConfig(PacketEvents.getAPI()) 22 | .debugMode() 23 | .checkForUpdates() 24 | .tickTickables() 25 | .useBstats() 26 | .usePlatformLogger(); 27 | 28 | EntityLib.init(platform, settings); 29 | 30 | CommandMap commandMap; 31 | try { 32 | commandMap = (CommandMap) Bukkit.getServer().getClass().getMethod("getCommandMap").invoke(Bukkit.getServer()); 33 | commandMap.register("testapi", new TestTextDisplayCommand()); 34 | commandMap.register("testplayer", new TestPlayerCommand()); 35 | commandMap.register("testholo", new TestHologramsCommand()); 36 | commandMap.register("testmassivepig", new TestMassivePigCommand()); 37 | } 38 | catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { 39 | e.printStackTrace(); 40 | } 41 | 42 | 43 | 44 | } 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /test-plugin/src/main/java/me/tofaa/testentitylib/TestHologramsCommand.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.testentitylib; 2 | 3 | import io.github.retrooper.packetevents.util.SpigotConversionUtil; 4 | import me.tofaa.entitylib.wrapper.hologram.Hologram; 5 | import net.kyori.adventure.text.Component; 6 | import org.bukkit.command.CommandSender; 7 | import org.bukkit.command.defaults.BukkitCommand; 8 | import org.bukkit.entity.Player; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | import java.util.Arrays; 12 | import java.util.List; 13 | 14 | public class TestHologramsCommand extends BukkitCommand { 15 | 16 | 17 | TestHologramsCommand () { 18 | super("testholo"); 19 | } 20 | 21 | @Override 22 | public boolean execute(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) { 23 | if (strings.length == 0) { 24 | commandSender.sendMessage("Usage: /testholo "); 25 | return true; 26 | } 27 | Player player = (Player) commandSender; 28 | if (strings[0].equalsIgnoreCase("modern")) { 29 | Hologram.Modern holo =Hologram.modern(SpigotConversionUtil.fromBukkitLocation(player.getLocation())); 30 | holo.addLine(Component.text("Hello, World!")); 31 | holo.show(); 32 | holo.addViewer(player.getUniqueId()); 33 | } 34 | if (strings[0].equalsIgnoreCase("legacy")) { 35 | Hologram.Legacy holo = Hologram.legacy(SpigotConversionUtil.fromBukkitLocation(player.getLocation())); 36 | holo.addLine(Component.text("Hello, World!")); 37 | holo.show(); 38 | holo.addViewer(player.getUniqueId()); 39 | } 40 | return true; 41 | } 42 | 43 | @NotNull 44 | @Override 45 | public List tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException { 46 | return Arrays.asList("legacy", "modern"); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /test-plugin/src/main/java/me/tofaa/testentitylib/TestMassivePigCommand.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.testentitylib; 2 | 3 | import com.github.retrooper.packetevents.protocol.attribute.Attributes; 4 | import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes; 5 | import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerUpdateAttributes; 6 | import io.github.retrooper.packetevents.util.SpigotConversionUtil; 7 | import me.tofaa.entitylib.EntityLib; 8 | import me.tofaa.entitylib.wrapper.WrapperEntity; 9 | import me.tofaa.entitylib.wrapper.WrapperLivingEntity; 10 | import org.bukkit.command.CommandSender; 11 | import org.bukkit.command.defaults.BukkitCommand; 12 | import org.bukkit.entity.Player; 13 | import org.jetbrains.annotations.NotNull; 14 | 15 | import java.util.UUID; 16 | 17 | public class TestMassivePigCommand extends BukkitCommand { 18 | 19 | private WrapperEntity pig; 20 | 21 | public TestMassivePigCommand() { 22 | super("testmassivepig"); 23 | } 24 | 25 | @Override 26 | public boolean execute(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) { 27 | if (!(commandSender instanceof Player)) return false; 28 | Player player = (Player) commandSender; 29 | if (pig != null) { 30 | pig.remove(); 31 | pig = null; 32 | player.sendMessage("Large pig removed"); 33 | return true; 34 | } 35 | pig = new WrapperEntity(EntityTypes.TNT); 36 | pig.addViewer(player.getUniqueId()); 37 | pig.spawn(SpigotConversionUtil.fromBukkitLocation(player.getLocation())); 38 | player.sendMessage("Large pig spawned"); 39 | return true; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /test-plugin/src/main/java/me/tofaa/testentitylib/TestTextDisplayCommand.java: -------------------------------------------------------------------------------- 1 | package me.tofaa.testentitylib; 2 | 3 | import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes; 4 | import io.github.retrooper.packetevents.util.SpigotConversionUtil; 5 | import me.tofaa.entitylib.EntityLib; 6 | import me.tofaa.entitylib.meta.display.TextDisplayMeta; 7 | import me.tofaa.entitylib.meta.mobs.passive.PigMeta; 8 | import me.tofaa.entitylib.wrapper.WrapperEntity; 9 | import net.kyori.adventure.text.Component; 10 | import org.bukkit.command.CommandSender; 11 | import org.bukkit.command.defaults.BukkitCommand; 12 | import org.bukkit.entity.Player; 13 | import org.jetbrains.annotations.NotNull; 14 | 15 | public class TestTextDisplayCommand extends BukkitCommand { 16 | 17 | private WrapperEntity e; 18 | 19 | public TestTextDisplayCommand() { 20 | super("textdisplay"); 21 | } 22 | 23 | @Override 24 | public boolean execute(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) { 25 | // if (!(commandSender instanceof Player)) return true; 26 | // Player player = (Player) commandSender; 27 | // if (e == null) { 28 | // e = EntityLib.getApi().createEntity(EntityTypes.PIG); 29 | // e.spawn(SpigotConversionUtil.fromBukkitLocation(player.getLocation())); 30 | // e.addViewer(player.getUniqueId()); 31 | // player.sendMessage("Spawned"); 32 | // } 33 | // String msg = String.join(" ", strings); 34 | // PigMeta meta = (PigMeta) e.getEntityMeta(); 35 | // meta.setCustomNameVisible(true); 36 | // meta.setCustomName(Component.text(msg)); 37 | // player.sendMessage("Set text to: " + msg); 38 | return true; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /test-plugin/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: EntityLibPlugin 2 | version: ${version} 3 | depend: 4 | - packetevents 5 | main: me.tofaa.testentitylib.TestEntityLibPlugin 6 | api-version: "1.21" 7 | commands: 8 | testapi: 9 | description: Test EntityLib API 10 | usage: / --------------------------------------------------------------------------------