report meta and entity creation
This commit is contained in:
parent
3091083821
commit
9cc097aab2
185 changed files with 7102 additions and 464 deletions
.idea
api/src/main/java/me/tofaa/entitylib
APISettings.javaEntityIdProvider.javaEntityLib.javaEntityLibAPI.javaEntityUuidProvider.javaPlatform.javaWorldWrapper.java
event
extras
meta
EntityMeta.javaMetaConverterRegistry.javaUsedVersion.javaVersionCompatCheck.java
display
mobs
BatMeta.javaBeeMeta.javaDonkeyMeta.javaFoxMeta.javaFrogMeta.javaGoatMeta.javaHoglinMeta.javaOcelotMeta.javaPandaMeta.javaPolarBearMeta.javaSnifferMeta.javaStriderMeta.java
cuboid
golem
horse
BaseHorseMeta.javaChestedHorseMeta.javaDonkeyMeta.javaHorseMeta.javaLlamaMeta.javaMuleMeta.javaSkeletonHorseMeta.javaTraderLlamaMeta.javaZombieHorseMeta.java
minecart
BaseMinecartMeta.javaChestMinecartMeta.javaCommandBlockMinecartMeta.javaFurnaceMinecartMeta.javaHopperMinecartMeta.javaMinecartMeta.javaSpawnerMinecartMeta.javaTntMinecartMeta.java
monster
BlazeMeta.javaCaveSpiderMeta.javaCreeperMeta.javaElderGuardianMeta.javaEndermanMeta.javaEndermiteMeta.javaGhastMeta.javaGiantMeta.javaGuardianMeta.javaPhantomMeta.javaSilverfishMeta.javaSpiderMeta.javaVexMeta.javaWitherMeta.javaZoglinMeta.java
piglin
raider
EvokerMeta.javaIllusionerMeta.javaPillagerMeta.javaRaiderMeta.javaRavagerMeta.javaSpellcasterIllagerMeta.javaVindicatorMeta.javaWitchMeta.java
skeleton
zombie
passive
|
@ -9,6 +9,9 @@
|
|||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/api" />
|
||||
<option value="$PROJECT_DIR$/common" />
|
||||
<option value="$PROJECT_DIR$/platforms" />
|
||||
<option value="$PROJECT_DIR$/platforms/spigot" />
|
||||
<option value="$PROJECT_DIR$/test-plugin" />
|
||||
</set>
|
||||
</option>
|
||||
|
|
|
@ -5,20 +5,49 @@
|
|||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="9d5d9b6f-43c8-41a4-bb42-a66ffc96c9b0" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/EntityLib.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/EntityLibAPI.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/Platform.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/WorldWrapper.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/event/EntityLibEvent.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/event/UserReceiveMetaUpdateEvent.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/extras/InvalidVersionException.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/EntityMeta.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/Metadata.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/tick/TickContainer.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/EntityIdProvider.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/EntityUuidProvider.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/event/EventBus.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/event/EventBusAsync.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/event/EventBusSync.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/event/EventListener.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/extras/VersionChecker.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/MetaConverterRegistry.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/UsedVersion.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/VersionCompatCheck.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/display/AbstractDisplayMeta.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/display/BlockDisplayMeta.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/display/ItemDisplayMeta.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/display/TextDisplayMeta.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntity.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntityEquipment.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperLivingEntity.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/common/src/main/java/me/tofaa/entitylib/common/AbstractEntityLibAPI.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/common/src/main/java/me/tofaa/entitylib/common/AbstractPlatform.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/common/src/main/java/me/tofaa/entitylib/common/AbstractWorldWrapper.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotWorld.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/testentitylib/TestEntityLibPlugin.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/gradle.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/gradle.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/api/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/api/build.gradle" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/build.gradle" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/me/tofaa/entitylib/meta/Metadata.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/me/tofaa/entitylib/meta/Metadata.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/APISettings.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/APISettings.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/EntityLib.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/EntityLib.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/EntityLibAPI.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/EntityLibAPI.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/Platform.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/Platform.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/WorldWrapper.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/WorldWrapper.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/event/EntityLibEvent.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/event/EntityLibEvent.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/event/UserReceiveMetaUpdateEvent.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/event/types/UserReceiveMetaUpdateEvent.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/EntityMeta.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/EntityMeta.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/platforms/spigot/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/spigot/build.gradle" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibAPI.java" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibAPI.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibPlatform.java" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibPlatform.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/settings.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/settings.gradle" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/test-plugin/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/test-plugin/build.gradle" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/entitylib/EntityLibPlugin.java" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/entitylib/SpawnClickableFrogCommand.java" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/entitylib/TestCommand.java" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/entitylib/TestDisplayCommand.java" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/entitylib/TestEntityCommand.java" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/test-plugin/src/main/resources/plugin.yml" beforeDir="false" afterPath="$PROJECT_DIR$/test-plugin/src/main/resources/plugin.yml" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -81,40 +110,64 @@
|
|||
<option name="showExcludedFiles" value="false" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"Downloaded.Files.Path.Enabled": "false",
|
||||
"Gradle.Build EntityLib.executor": "Run",
|
||||
"Gradle.EntityLib:test-plugin [runServer].executor": "Run",
|
||||
"Repository.Attach.Annotations": "false",
|
||||
"Repository.Attach.JavaDocs": "false",
|
||||
"Repository.Attach.Sources": "false",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"WebServerToolWindowFactoryState": "false",
|
||||
"git-widget-placeholder": "feat/platform-api",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"jdk.selected.JAVA_MODULE": "corretto-17",
|
||||
"kotlin-language-version-configured": "true",
|
||||
"last_opened_file_path": "D:/Github/EntityLib",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"project.structure.last.edited": "Modules",
|
||||
"project.structure.proportion": "0.0",
|
||||
"project.structure.side.proportion": "0.0",
|
||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"Downloaded.Files.Path.Enabled": "false",
|
||||
"Gradle.Build EntityLib.executor": "Run",
|
||||
"Gradle.EntityLib [dependencies].executor": "Run",
|
||||
"Gradle.EntityLib:test-plugin [runServer].executor": "Run",
|
||||
"Repository.Attach.Annotations": "false",
|
||||
"Repository.Attach.JavaDocs": "false",
|
||||
"Repository.Attach.Sources": "false",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"WebServerToolWindowFactoryState": "false",
|
||||
"git-widget-placeholder": "feat/platform-api",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"jdk.selected.JAVA_MODULE": "corretto-17",
|
||||
"kotlin-language-version-configured": "true",
|
||||
"last_opened_file_path": "D:/Github/EntityLib/api/src/main/java/me/tofaa/entitylib/meta",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"project.structure.last.edited": "Modules",
|
||||
"project.structure.proportion": "0.15",
|
||||
"project.structure.side.proportion": "0.2",
|
||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}</component>
|
||||
}]]></component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="D:\Github\EntityLib\api\src\main\java\me\tofaa\entitylib\meta" />
|
||||
<recent name="D:\Github\EntityLib\test-plugin" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunManager" selected="Gradle.EntityLib:test-plugin [runServer]">
|
||||
<component name="RunManager" selected="Gradle.EntityLib [dependencies]">
|
||||
<configuration name="EntityLib [dependencies]" type="GradleRunConfiguration" factoryName="Gradle" temporary="true">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="dependencies" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<RunAsTest>false</RunAsTest>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="EntityLib:test-plugin [runServer]" type="GradleRunConfiguration" factoryName="Gradle" temporary="true">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
|
@ -183,6 +236,7 @@
|
|||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Gradle.EntityLib [dependencies]" />
|
||||
<item itemvalue="Gradle.EntityLib:test-plugin [runServer]" />
|
||||
<item itemvalue="Gradle.PE-EntityMeta [compileTestJava]" />
|
||||
<item itemvalue="Gradle.EntityLib:test-plugin [shadowJar]" />
|
||||
|
@ -232,7 +286,8 @@
|
|||
<workItem from="1705984769972" duration="76000" />
|
||||
<workItem from="1706183895216" duration="664000" />
|
||||
<workItem from="1706187926445" duration="4339000" />
|
||||
<workItem from="1706248178234" duration="1973000" />
|
||||
<workItem from="1706248178234" duration="17096000" />
|
||||
<workItem from="1706284605696" duration="11691000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
|
|
@ -12,11 +12,13 @@ import java.net.URL;
|
|||
|
||||
public final class APISettings {
|
||||
|
||||
private final PacketEventsAPI<?> packetEvents;
|
||||
private boolean debugMode = false;
|
||||
private boolean checkForUpdates = false;
|
||||
private boolean tickTickables = false;
|
||||
private PacketEventsAPI<?> packetEvents;
|
||||
private boolean platformLogger = false;
|
||||
private boolean useAsyncEvents = false;
|
||||
private boolean defaultCommands = false;
|
||||
|
||||
public APISettings(PacketEventsAPI<?> packetEvents) {
|
||||
this.packetEvents = packetEvents;
|
||||
|
@ -42,16 +44,6 @@ public final class APISettings {
|
|||
return this;
|
||||
}
|
||||
|
||||
public @NotNull APISettings usePlatformLogger(boolean platformLogger) {
|
||||
this.platformLogger = platformLogger;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NotNull APISettings debugMode(boolean debugMode) {
|
||||
this.debugMode = debugMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NotNull APISettings checkForUpdates() {
|
||||
this.checkForUpdates = true;
|
||||
return this;
|
||||
|
@ -67,16 +59,20 @@ public final class APISettings {
|
|||
return this;
|
||||
}
|
||||
|
||||
public @NotNull APISettings checkForUpdates(boolean checkForUpdates) {
|
||||
this.checkForUpdates = checkForUpdates;
|
||||
public @NotNull APISettings registerDefaultCommands() {
|
||||
this.defaultCommands = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NotNull APISettings tickTickables(boolean tickTickables) {
|
||||
this.tickTickables = tickTickables;
|
||||
public @NotNull APISettings useAsyncEvents() {
|
||||
this.useAsyncEvents = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean shouldRegisterDefaultCommands() {
|
||||
return defaultCommands;
|
||||
}
|
||||
|
||||
public boolean isDebugMode() {
|
||||
return debugMode;
|
||||
}
|
||||
|
@ -97,4 +93,8 @@ public final class APISettings {
|
|||
return platformLogger;
|
||||
}
|
||||
|
||||
public boolean shouldUseAsyncEvents() {
|
||||
return useAsyncEvents;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
23
api/src/main/java/me/tofaa/entitylib/EntityIdProvider.java
Normal file
23
api/src/main/java/me/tofaa/entitylib/EntityIdProvider.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
package me.tofaa.entitylib;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public interface EntityIdProvider {
|
||||
|
||||
int provide(@NotNull UUID entityUUID, @NotNull EntityType entityType);
|
||||
|
||||
class DefaultEntityIdProvider implements EntityIdProvider {
|
||||
|
||||
private final AtomicInteger integer = new AtomicInteger();
|
||||
|
||||
@Override
|
||||
public int provide(@NotNull UUID entityUUID, @NotNull EntityType entityType) {
|
||||
return integer.incrementAndGet();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +1,12 @@
|
|||
package me.tofaa.entitylib;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public final class EntityLib {
|
||||
|
||||
private EntityLib() {}
|
||||
|
||||
private static String version = "1.2.0-SNAPSHOT";
|
||||
private static Platform platform;
|
||||
private static EntityLibAPI api;
|
||||
|
||||
|
@ -12,6 +14,20 @@ public final class EntityLib {
|
|||
EntityLib.platform = platform;
|
||||
platform.setupApi(settings);
|
||||
api = platform.getAPI();
|
||||
if (api.getSettings().shouldCheckForUpdate()) {
|
||||
try {
|
||||
if (api.getSettings().isDebugMode()) {
|
||||
platform.getLogger().log(Level.CONFIG, "Checking for updates...");
|
||||
}
|
||||
if (api.getSettings().requiresUpdate()) {
|
||||
platform.getLogger().log(Level.WARNING, "You are using an outdated version of EntityLib. Please take a look at the Github releases page.");
|
||||
}
|
||||
|
||||
}
|
||||
catch (IOException e) {
|
||||
platform.getLogger().log(Level.WARNING, e, () -> "EntityLib failed to check for updates.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static EntityLibAPI<?, ?> getApi() {
|
||||
|
@ -23,6 +39,6 @@ public final class EntityLib {
|
|||
}
|
||||
|
||||
public static String getVersion() {
|
||||
return version;
|
||||
return "1.2.0-SNAPSHOT";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import me.tofaa.entitylib.tick.TickContainer;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Represents the API for EntityLib.
|
||||
|
@ -14,21 +15,28 @@ import java.util.Collection;
|
|||
*/
|
||||
public interface EntityLibAPI<W, T> {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return The {@link PacketEventsAPI} that EntityLib uses.
|
||||
*/
|
||||
PacketEventsAPI<?> getPacketEvents();
|
||||
|
||||
void onLoad();
|
||||
|
||||
void onEnable();
|
||||
|
||||
@NotNull APISettings getSettings();
|
||||
|
||||
/**
|
||||
* Creates a wrapped world for the platform specific world.
|
||||
* @param world The platform specific world handle.
|
||||
* @return A wrapped world.
|
||||
*/
|
||||
@NotNull WorldWrapper<W> wrapWorld(W world);
|
||||
|
||||
/**
|
||||
* If a platform supports ticking
|
||||
* this method should be responsible for setting up the {@link me.tofaa.entitylib.tick.TickContainer}'s.
|
||||
* @return The {@link APISettings} for the API.
|
||||
*/
|
||||
void setupTickingContainers();
|
||||
|
||||
@NotNull APISettings getSettings();
|
||||
|
||||
/**
|
||||
* @return An unmodifiable collection of TickContainers.
|
||||
|
|
21
api/src/main/java/me/tofaa/entitylib/EntityUuidProvider.java
Normal file
21
api/src/main/java/me/tofaa/entitylib/EntityUuidProvider.java
Normal file
|
@ -0,0 +1,21 @@
|
|||
package me.tofaa.entitylib;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface EntityUuidProvider {
|
||||
|
||||
@NotNull UUID provide(EntityType entityType);
|
||||
|
||||
|
||||
class DefaultEntityUuidProvider implements EntityUuidProvider {
|
||||
|
||||
@Override
|
||||
public @NotNull UUID provide(EntityType entityType) {
|
||||
return UUID.randomUUID();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package me.tofaa.entitylib;
|
||||
|
||||
import me.tofaa.entitylib.event.EntityLibEvent;
|
||||
import me.tofaa.entitylib.event.EventBus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
@ -12,6 +13,30 @@ import java.util.logging.Logger;
|
|||
*/
|
||||
public interface Platform<P> {
|
||||
|
||||
/**
|
||||
* Gets the entityId integer provider. This can be provided by a platform if needed.
|
||||
* @return the entityId integer provider.
|
||||
*/
|
||||
@NotNull EntityIdProvider getEntityIdProvider();
|
||||
|
||||
/**
|
||||
* Gets the UUID provider for entities. This can be provided by a platform if needed.
|
||||
* @return the UUID provider for entities.
|
||||
*/
|
||||
@NotNull EntityUuidProvider getEntityUuidProvider();
|
||||
|
||||
/**
|
||||
* Sets the entityId integer provider. This can be provided by a platform if needed.
|
||||
* @param provider the entityId integer provider.
|
||||
*/
|
||||
void setEntityIdProvider(@NotNull EntityIdProvider provider);
|
||||
|
||||
/**
|
||||
* Sets the UUID provider for entities. This can be provided by a platform if needed.
|
||||
* @param provider
|
||||
*/
|
||||
void setEntityUuidProvider(@NotNull EntityUuidProvider provider);
|
||||
|
||||
|
||||
/**
|
||||
* @return the logger EntityLib uses internally.
|
||||
|
@ -19,18 +44,11 @@ public interface Platform<P> {
|
|||
@NotNull Logger getLogger();
|
||||
|
||||
/**
|
||||
* Sends an event to the platform. Platform implementations should handle the event accordingly.
|
||||
* @param event the event to send.
|
||||
* Gets the event bus for the platform.
|
||||
* WARNING: If you have {@link APISettings#shouldUseAsyncEvents()} set to true, cast this to {@link EventBus.Async} when handling cancelled events.
|
||||
* @return
|
||||
*/
|
||||
void sendEvent(EntityLibEvent event);
|
||||
|
||||
/**
|
||||
* Registers a listener for the given event class, the handle will be called when the event is sent.
|
||||
* @param eventClass the event class to listen for.
|
||||
* @param handle the handle to call when the event is sent.
|
||||
* @param <T> the event type.
|
||||
*/
|
||||
<T extends EntityLibEvent> void registerListener(Class<T> eventClass, Consumer<T> handle);
|
||||
@NotNull EventBus getEventBus();
|
||||
|
||||
/**
|
||||
* Sets up the API for the platform. This method should be called automatically by the platform. Don't call it yourself.
|
||||
|
|
|
@ -1,7 +1,15 @@
|
|||
package me.tofaa.entitylib;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
||||
import com.github.retrooper.packetevents.protocol.world.Dimension;
|
||||
import com.github.retrooper.packetevents.protocol.world.Location;
|
||||
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import me.tofaa.entitylib.wrapper.WrapperEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Represents a platform specific world.
|
||||
|
@ -11,9 +19,42 @@ import com.github.retrooper.packetevents.resources.ResourceLocation;
|
|||
*/
|
||||
public interface WorldWrapper<W> {
|
||||
|
||||
ResourceLocation getPacketEventsWorld();
|
||||
@NotNull <T extends WrapperEntity> T spawnEntity(@NotNull Class<T> wrapperClass, @NotNull EntityType entityType, @NotNull Location location);
|
||||
|
||||
@NotNull WrapperEntity spawnEntity(@NotNull EntityType entityType, @NotNull Location location);
|
||||
|
||||
@NotNull <T extends WrapperEntity> T spawnEntity(@NotNull T entity, @NotNull Location location);
|
||||
|
||||
@NotNull <T extends WrapperEntity> T cloneEntity(@NotNull Object platformEntity, @NotNull Location location);
|
||||
|
||||
@NotNull Collection<WrapperEntity> getEntities();
|
||||
|
||||
@Nullable WrapperEntity getEntity(int id);
|
||||
|
||||
@Nullable WrapperEntity getEntity(@NotNull UUID uuid);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the block at the specified coordinates. Depending on the platforms implementation, this method may be slow.
|
||||
* @param x The x coordinate.
|
||||
* @param y The y coordinate.
|
||||
* @param z The z coordinate.
|
||||
* @return The packetevents WrappedBlockState at the specified coordinates.
|
||||
*/
|
||||
WrappedBlockState getBlock(int x, int y, int z);
|
||||
|
||||
W getHandle();
|
||||
/**
|
||||
* @return the packetevents Dimension of the world.
|
||||
*/
|
||||
@NotNull Dimension getDimension();
|
||||
|
||||
/**
|
||||
* @return the world's UUID.
|
||||
*/
|
||||
@NotNull UUID getUuid();
|
||||
|
||||
/**
|
||||
* @return the platform specific World.
|
||||
*/
|
||||
@NotNull W getHandle();
|
||||
}
|
||||
|
|
|
@ -5,9 +5,4 @@ public interface EntityLibEvent {
|
|||
boolean isCancelled();
|
||||
|
||||
void setCancelled(boolean cancelled);
|
||||
|
||||
default boolean isAsync() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
61
api/src/main/java/me/tofaa/entitylib/event/EventBus.java
Normal file
61
api/src/main/java/me/tofaa/entitylib/event/EventBus.java
Normal file
|
@ -0,0 +1,61 @@
|
|||
package me.tofaa.entitylib.event;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* A basic EventBus for scheduling and handling {@link EntityLibEvent}
|
||||
*/
|
||||
public interface EventBus {
|
||||
|
||||
static @NotNull EventBus newBus(boolean async) {
|
||||
return async ? new EventBusAsync() : new EventBusSync();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a listener to the EventBus.
|
||||
* @param listener The listener object
|
||||
* @param <T> The type of {@link EntityLibEvent}
|
||||
*/
|
||||
<T extends EntityLibEvent> void addListener(@NotNull EventListener<T> listener);
|
||||
|
||||
/**
|
||||
* Adds a listener to the EventBus.
|
||||
* @param eventClass The events class
|
||||
* @param consumer The consumer for the event.
|
||||
* @param <T> The type of {@link EntityLibEvent}
|
||||
*/
|
||||
<T extends EntityLibEvent> void addListener(@NotNull Class<T> eventClass, @NotNull Consumer<T> consumer);
|
||||
|
||||
/**
|
||||
* Removes a listener from the EventBus.
|
||||
* @param listener the listener object.
|
||||
* @param <T> The type of {@link EntityLibEvent}
|
||||
*/
|
||||
<T extends EntityLibEvent> void removeListener(@NotNull EventListener<T> listener);
|
||||
|
||||
/**
|
||||
* Calls the event and processes all the attached {@link EventListener} for the event.
|
||||
* If your bus is async, rather than using this, use {@link Async#call(EntityLibEvent, Consumer)} to avoid any race conditions.
|
||||
* @param event the event object to process handlers for.
|
||||
* @return the same event object, but already modified.
|
||||
* @param <T> The type of {@link EntityLibEvent}
|
||||
*/
|
||||
<T extends EntityLibEvent> @NotNull T call(@NotNull T event);
|
||||
|
||||
|
||||
interface Async extends EventBus {
|
||||
|
||||
/**
|
||||
* A safer way to handle and process an event. Does exactly what {@link EventBus#call(EntityLibEvent)} does but allows you to attach a callback, rather than working with it yourself,
|
||||
* the callback is executed on the thread this is called, and not the main thread.
|
||||
* @param event the event object to process handlers for.
|
||||
* @param completionCallback the callback handled after the event is consumed async
|
||||
* @param <T> The type of {@link EntityLibEvent}
|
||||
*/
|
||||
<T extends EntityLibEvent> void call(@NotNull T event, @NotNull Consumer<T> completionCallback);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package me.tofaa.entitylib.event;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
final class EventBusAsync implements EventBus.Async {
|
||||
|
||||
private final Map listeners = new ConcurrentHashMap();
|
||||
private final ThreadPoolExecutor executor = new ThreadPoolExecutor(1, 4, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<>());
|
||||
|
||||
@Override
|
||||
public <T extends EntityLibEvent> void addListener(@NotNull EventListener<T> listener) {
|
||||
if (listeners.containsKey(listener.getEventClass())) {
|
||||
listeners.put(listener.getEventClass(), new HashSet<>());
|
||||
}
|
||||
((HashSet) listeners.get(listener.getEventClass())).add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends EntityLibEvent> void addListener(@NotNull Class<T> eventClass, @NotNull Consumer<T> consumer) {
|
||||
addListener(EventListener.generateListener(eventClass, consumer));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends EntityLibEvent> void removeListener(@NotNull EventListener<T> listener) {
|
||||
if (listeners.containsKey(listener.getEventClass())) {
|
||||
((HashSet) listeners.get(listener.getEventClass())).remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends EntityLibEvent> @NotNull T call(@NotNull T event) {
|
||||
executor.execute(() -> dispatchEvent(event));
|
||||
return event;
|
||||
}
|
||||
|
||||
|
||||
private <T extends EntityLibEvent> void dispatchEvent(T event) {
|
||||
if (!listeners.containsKey(event.getClass())) return;
|
||||
HashSet<EventListener<T>> consumers = (HashSet<EventListener<T>>) listeners.get(event.getClass());
|
||||
consumers.forEach(consumer -> consumer.handle(event));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <T extends EntityLibEvent> void call(@NotNull T event, @NotNull Consumer<T> completionCallback) {
|
||||
executor.execute(() -> {
|
||||
dispatchEvent(event);
|
||||
completionCallback.accept(event);
|
||||
});
|
||||
}
|
||||
}
|
43
api/src/main/java/me/tofaa/entitylib/event/EventBusSync.java
Normal file
43
api/src/main/java/me/tofaa/entitylib/event/EventBusSync.java
Normal file
|
@ -0,0 +1,43 @@
|
|||
package me.tofaa.entitylib.event;
|
||||
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
class EventBusSync implements EventBus {
|
||||
|
||||
private final Map listeners = new ConcurrentHashMap();
|
||||
|
||||
@Override
|
||||
public <T extends EntityLibEvent> void addListener(@NotNull EventListener<T> listener) {
|
||||
if (listeners.containsKey(listener.getEventClass())) {
|
||||
listeners.put(listener.getEventClass(), new HashSet<>());
|
||||
}
|
||||
((HashSet) listeners.get(listener.getEventClass())).add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends EntityLibEvent> void addListener(@NotNull Class<T> eventClass, @NotNull Consumer<T> consumer) {
|
||||
addListener(EventListener.generateListener(eventClass, consumer));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends EntityLibEvent> void removeListener(@NotNull EventListener<T> listener) {
|
||||
if (listeners.containsKey(listener.getEventClass())) {
|
||||
((HashSet) listeners.get(listener.getEventClass())).remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends EntityLibEvent> @NotNull T call(@NotNull T event) {
|
||||
if (!listeners.containsKey(event.getClass())) return event;
|
||||
HashSet<EventListener<T>> consumers = (HashSet<EventListener<T>>) listeners.get(event.getClass());
|
||||
consumers.forEach(consumer -> consumer.handle(event));
|
||||
return event;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package me.tofaa.entitylib.event;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface EventListener<E extends EntityLibEvent> {
|
||||
|
||||
@NotNull Class<E> getEventClass();
|
||||
|
||||
void handle(@NotNull E event);
|
||||
|
||||
public static <T extends EntityLibEvent> EventListener<T> generateListener(Class<T> eventClass, Consumer<T> consumer) {
|
||||
return new EventListener<T>() {
|
||||
@Override
|
||||
public @NotNull Class<T> getEventClass() {
|
||||
return eventClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(@NotNull T event) {
|
||||
consumer.accept(event);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package me.tofaa.entitylib.event;
|
||||
package me.tofaa.entitylib.event.types;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import me.tofaa.entitylib.event.EntityLibEvent;
|
||||
import me.tofaa.entitylib.meta.EntityMeta;
|
||||
|
||||
public final class UserReceiveMetaUpdateEvent implements EntityLibEvent {
|
|
@ -0,0 +1,38 @@
|
|||
package me.tofaa.entitylib.extras;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.world.Location;
|
||||
import com.github.retrooper.packetevents.util.Vector3d;
|
||||
|
||||
public final class CoordinateUtil {
|
||||
|
||||
private CoordinateUtil() {}
|
||||
|
||||
public static Location withDirection(Location location, Vector3d direction) {
|
||||
/*
|
||||
* Sin = Opp / Hyp
|
||||
* Cos = Adj / Hyp
|
||||
* Tan = Opp / Adj
|
||||
*
|
||||
* x = -Opp
|
||||
* z = Adj
|
||||
*/
|
||||
final double x = direction.getX();
|
||||
final double z = direction.getZ();
|
||||
if (x == 0 && z == 0) {
|
||||
float pitch = direction.getY() > 0 ? -90f : 90f;
|
||||
return new Location(location.getX(), location.getY(), location.getZ(), location.getYaw(), pitch);
|
||||
}
|
||||
final double theta = Math.atan2(-x, z);
|
||||
final double xz = Math.sqrt(square(x) + square(z));
|
||||
final double _2PI = 2 * Math.PI;
|
||||
|
||||
return new Location(location.getX(), location.getY(), location.getZ(),
|
||||
(float) Math.toDegrees((theta + _2PI) % _2PI),
|
||||
(float) Math.toDegrees(Math.atan(-direction.getY() / xz)));
|
||||
}
|
||||
|
||||
public static double square(double in) {
|
||||
return in * in;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package me.tofaa.entitylib.extras;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import me.tofaa.entitylib.EntityLib;
|
||||
|
||||
public final class VersionChecker {
|
||||
|
||||
private VersionChecker() {}
|
||||
|
||||
|
||||
public static void verifyVersion(ServerVersion version, String message) {
|
||||
if (!version.isNewerThanOrEquals(EntityLib.getApi().getPacketEvents().getServerManager().getVersion())) {
|
||||
throw new InvalidVersionException(message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -6,16 +6,46 @@ import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
|||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityMetadataProvider;
|
||||
import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose;
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityMetadata;
|
||||
import me.tofaa.entitylib.EntityLib;
|
||||
import me.tofaa.entitylib.extras.InvalidVersionException;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class EntityMeta implements EntityMetadataProvider {
|
||||
|
||||
private static final MetaConverterRegistry registry = new MetaConverterRegistry();
|
||||
private static final Map<Integer, EntityMeta> metaMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static @NotNull BiFunction<Integer, Metadata, EntityMeta> getConverter(EntityType entityType) {
|
||||
return registry.get(entityType);
|
||||
}
|
||||
|
||||
public static @NotNull Class<? extends EntityMeta> getMetaClass(EntityType entityType) {
|
||||
return registry.getMetaClass(entityType);
|
||||
}
|
||||
|
||||
public static @NotNull EntityMeta createMeta(int entityId, EntityType entityType) {
|
||||
Metadata metadata = new Metadata(entityId);
|
||||
BiFunction<Integer, Metadata, EntityMeta> converter = getConverter(entityType);
|
||||
EntityMeta entityMeta = converter.apply(entityId, metadata);
|
||||
metaMap.put(entityId, entityMeta);
|
||||
return entityMeta;
|
||||
}
|
||||
|
||||
public static @Nullable EntityMeta getMeta(int entityId) {
|
||||
return metaMap.get(entityId);
|
||||
}
|
||||
|
||||
public static final byte OFFSET = 0;
|
||||
public static final byte MAX_OFFSET = OFFSET + 8;
|
||||
|
||||
|
|
|
@ -0,0 +1,175 @@
|
|||
package me.tofaa.entitylib.meta;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
||||
import me.tofaa.entitylib.meta.EntityMeta;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.display.BlockDisplayMeta;
|
||||
import me.tofaa.entitylib.meta.display.ItemDisplayMeta;
|
||||
import me.tofaa.entitylib.meta.display.TextDisplayMeta;
|
||||
import me.tofaa.entitylib.meta.mobs.*;
|
||||
import me.tofaa.entitylib.meta.mobs.DonkeyMeta;
|
||||
import me.tofaa.entitylib.meta.mobs.cuboid.MagmaCubeMeta;
|
||||
import me.tofaa.entitylib.meta.mobs.cuboid.SlimeMeta;
|
||||
import me.tofaa.entitylib.meta.mobs.golem.IronGolemMeta;
|
||||
import me.tofaa.entitylib.meta.mobs.golem.ShulkerMeta;
|
||||
import me.tofaa.entitylib.meta.mobs.golem.SnowGolemMeta;
|
||||
import me.tofaa.entitylib.meta.mobs.horse.*;
|
||||
import me.tofaa.entitylib.meta.mobs.monster.*;
|
||||
import me.tofaa.entitylib.meta.mobs.monster.piglin.PiglinBruteMeta;
|
||||
import me.tofaa.entitylib.meta.mobs.monster.piglin.PiglinMeta;
|
||||
import me.tofaa.entitylib.meta.mobs.monster.raider.*;
|
||||
import me.tofaa.entitylib.meta.mobs.monster.skeleton.SkeletonMeta;
|
||||
import me.tofaa.entitylib.meta.mobs.monster.skeleton.StrayMeta;
|
||||
import me.tofaa.entitylib.meta.mobs.monster.skeleton.WitherSkeletonMeta;
|
||||
import me.tofaa.entitylib.meta.mobs.monster.zombie.*;
|
||||
import me.tofaa.entitylib.meta.mobs.passive.*;
|
||||
import me.tofaa.entitylib.meta.mobs.water.*;
|
||||
import me.tofaa.entitylib.meta.mobs.minecart.*;
|
||||
import me.tofaa.entitylib.meta.mobs.tameable.CatMeta;
|
||||
import me.tofaa.entitylib.meta.mobs.tameable.ParrotMeta;
|
||||
import me.tofaa.entitylib.meta.mobs.tameable.WolfMeta;
|
||||
import me.tofaa.entitylib.meta.mobs.villager.VillagerMeta;
|
||||
import me.tofaa.entitylib.meta.mobs.villager.WanderingTraderMeta;
|
||||
import me.tofaa.entitylib.meta.other.*;
|
||||
import me.tofaa.entitylib.meta.projectile.*;
|
||||
import me.tofaa.entitylib.meta.types.PlayerMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import static com.github.retrooper.packetevents.protocol.entity.type.EntityTypes.*;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final class MetaConverterRegistry {
|
||||
|
||||
private final Map<EntityType, BiFunction<Integer, Metadata, EntityMeta>> converters = new HashMap<>();
|
||||
private final Map<EntityType, Class<? extends EntityMeta>> metaClasses = new HashMap<>();
|
||||
|
||||
MetaConverterRegistry() {
|
||||
put(SNIFFER, SnifferMeta.class, SnifferMeta::new);
|
||||
put(INTERACTION, InteractionMeta.class, InteractionMeta::new);
|
||||
put(BLOCK_DISPLAY, BlockDisplayMeta.class, BlockDisplayMeta::new);
|
||||
put(ITEM_DISPLAY, ItemDisplayMeta.class, ItemDisplayMeta::new);
|
||||
put(TEXT_DISPLAY, TextDisplayMeta.class, TextDisplayMeta::new);
|
||||
put(AREA_EFFECT_CLOUD, AreaEffectCloudMeta.class, AreaEffectCloudMeta::new);
|
||||
put(ARMOR_STAND, ArmorStandMeta.class, ArmorStandMeta::new);
|
||||
put(BOAT, BoatMeta.class, BoatMeta::new);
|
||||
put(DRAGON_FIREBALL, DragonFireballMeta.class, DragonFireballMeta::new);
|
||||
put(END_CRYSTAL, EndCrystalMeta.class, EndCrystalMeta::new);
|
||||
put(ENDER_DRAGON, EnderDragonMeta.class, EnderDragonMeta::new);
|
||||
put(EVOKER_FANGS, EvokerFangsMeta.class, EvokerFangsMeta::new);
|
||||
put(FALLING_BLOCK, FallingBlockMeta.class, FallingBlockMeta::new);
|
||||
put(FIREWORK_ROCKET, FireworkRocketMeta.class, FireworkRocketMeta::new);
|
||||
put(FISHING_BOBBER, FishingHookMeta.class, FishingHookMeta::new);
|
||||
put(GLOW_ITEM_FRAME, GlowItemFrameMeta.class, GlowItemFrameMeta::new);
|
||||
put(ITEM_FRAME, ItemFrameMeta.class, ItemFrameMeta::new);
|
||||
put(LEASH_KNOT, LeashKnotMeta.class, LeashKnotMeta::new);
|
||||
put(LIGHTNING_BOLT, LightningBoltMeta.class, LightningBoltMeta::new);
|
||||
put(LLAMA_SPIT, LlamaSpitMeta.class, LlamaSpitMeta::new);
|
||||
put(MARKER, MarkerMeta.class, MarkerMeta::new);
|
||||
put(PAINTING, PaintingMeta.class, PaintingMeta::new);
|
||||
put(PRIMED_TNT, PrimedTntMeta.class, PrimedTntMeta::new);
|
||||
put(WITHER_SKULL, WitherSkullMeta.class, WitherSkullMeta::new);
|
||||
put(ZOGLIN, ZoglinMeta.class, ZoglinMeta::new);
|
||||
put(WITHER, WitherMeta.class, WitherMeta::new);
|
||||
put(VEX, VexMeta.class, VexMeta::new);
|
||||
put(SPIDER, SpiderMeta.class, SpiderMeta::new);
|
||||
put(SILVERFISH, SilverfishMeta.class, SilverfishMeta::new);
|
||||
put(GUARDIAN, GuardianMeta.class, GuardianMeta::new);
|
||||
put(GIANT, GiantMeta.class, GiantMeta::new);
|
||||
put(ENDERMITE, EndermiteMeta.class, EndermiteMeta::new);
|
||||
put(ENDERMITE, EndermiteMeta.class, EndermiteMeta::new);
|
||||
put(ELDER_GUARDIAN, ElderGuardianMeta.class, ElderGuardianMeta::new);
|
||||
put(CREEPER, CreeperMeta.class, CreeperMeta::new);
|
||||
put(CAVE_SPIDER, CaveSpiderMeta.class, CaveSpiderMeta::new);
|
||||
put(BLAZE, BlazeMeta.class, BlazeMeta::new);
|
||||
put(PIGLIN, PiglinMeta.class, PiglinMeta::new);
|
||||
put(PIGLIN_BRUTE, PiglinBruteMeta.class, PiglinBruteMeta::new);
|
||||
put(EVOKER, EvokerMeta.class, EvokerMeta::new);
|
||||
put(ILLUSIONER, IllusionerMeta.class, IllusionerMeta::new);
|
||||
put(PILLAGER, PillagerMeta.class, PillagerMeta::new);
|
||||
put(RAVAGER, RavagerMeta.class, RavagerMeta::new);
|
||||
put(VINDICATOR, VindicatorMeta.class, VindicatorMeta::new);
|
||||
put(WITCH, WitchMeta.class, WitchMeta::new);
|
||||
put(SKELETON, SkeletonMeta.class, SkeletonMeta::new);
|
||||
put(STRAY, StrayMeta.class, StrayMeta::new);
|
||||
put(WITHER_SKELETON, WitherSkeletonMeta.class, WitherSkeletonMeta::new);
|
||||
put(DROWNED, DrownedMeta.class, DrownedMeta::new);
|
||||
put(HUSK, HuskMeta.class, HuskMeta::new);
|
||||
put(ZOMBIE, ZombieMeta.class, ZombieMeta::new);
|
||||
put(ZOMBIE_VILLAGER, ZombieVillagerMeta.class, ZombieVillagerMeta::new);
|
||||
put(ZOMBIFIED_PIGLIN, ZombifiedPiglinMeta.class, ZombifiedPiglinMeta::new);
|
||||
put(AXOLOTL, AxolotlMeta.class, AxolotlMeta::new);
|
||||
put(COD, CodMeta.class, CodMeta::new);
|
||||
put(DOLPHIN, DolphinMeta.class, DolphinMeta::new);
|
||||
put(GLOW_SQUID, GlowSquidMeta.class, GlowSquidMeta::new);
|
||||
put(PUFFERFISH, PufferFishMeta.class, PufferFishMeta::new);
|
||||
put(SALMON, SalmonMeta.class, SalmonMeta::new);
|
||||
put(TROPICAL_FISH, TropicalFishMeta.class, TropicalFishMeta::new);
|
||||
put(ARROW, ArrowMeta.class, ArrowMeta::new);
|
||||
put(VILLAGER, VillagerMeta.class, VillagerMeta::new);
|
||||
put(WANDERING_TRADER, WanderingTraderMeta.class, WanderingTraderMeta::new);
|
||||
put(CHEST_MINECART, ChestMinecartMeta.class, ChestMinecartMeta::new);
|
||||
put(COMMAND_BLOCK_MINECART, CommandBlockMinecartMeta.class, CommandBlockMinecartMeta::new);
|
||||
put(COMMAND_BLOCK_MINECART, CommandBlockMinecartMeta.class, CommandBlockMinecartMeta::new);
|
||||
put(FURNACE_MINECART, FurnaceMinecartMeta.class, FurnaceMinecartMeta::new);
|
||||
put(HOPPER_MINECART, FurnaceMinecartMeta.class, FurnaceMinecartMeta::new);
|
||||
put(SPAWNER_MINECART, SpawnerMinecartMeta.class, SpawnerMinecartMeta::new);
|
||||
put(TNT_MINECART, TntMinecartMeta.class, TntMinecartMeta::new);
|
||||
put(PLAYER, PlayerMeta.class, PlayerMeta::new);
|
||||
put(THROWN_EXP_BOTTLE, ThrownExpBottleMeta.class, ThrownExpBottleMeta::new);
|
||||
put(EGG, ThrownEggMeta.class, ThrownEggMeta::new);
|
||||
put(TRIDENT, ThrownTridentMeta.class, ThrownTridentMeta::new);
|
||||
put(POTION, ThrownTridentMeta.class, ThrownTridentMeta::new);
|
||||
put(SMALL_FIREBALL, SmallFireballMeta.class, SmallFireballMeta::new);
|
||||
put(PIG, PigMeta.class, PigMeta::new);
|
||||
put(COW, CowMeta.class, CowMeta::new);
|
||||
put(CHICKEN, ChickenMeta.class, ChickenMeta::new);
|
||||
put(BEE, BeeMeta.class, BeeMeta::new);
|
||||
put(TURTLE, TurtleMeta.class, TurtleMeta::new);
|
||||
put(DONKEY, DonkeyMeta.class, DonkeyMeta::new);
|
||||
put(SHEEP, SheepMeta.class, SheepMeta::new);
|
||||
put(RABBIT, RabbitMeta.class, RabbitMeta::new);
|
||||
put(POLAR_BEAR, PolarBearMeta.class, PolarBearMeta::new);
|
||||
put(OCELOT, OcelotMeta.class, OcelotMeta::new );
|
||||
put(PANDA, PandaMeta.class, PandaMeta::new);
|
||||
put(STRIDER, StriderMeta.class, StriderMeta::new);
|
||||
put(FOX, FoxMeta.class, FoxMeta::new);
|
||||
put(FROG, FrogMeta.class, FrogMeta::new);
|
||||
put(GOAT, GoatMeta.class, GoatMeta::new);
|
||||
put(HOGLIN, HoglinMeta.class, HoglinMeta::new);
|
||||
put(CAT, CatMeta.class, CatMeta::new);
|
||||
put(PARROT, ParrotMeta.class, ParrotMeta::new);
|
||||
put(WOLF, WolfMeta.class, WolfMeta::new);
|
||||
put(DONKEY, DonkeyMeta.class, DonkeyMeta::new);
|
||||
put(HORSE, HorseMeta.class, HorseMeta::new);
|
||||
put(LLAMA, LlamaMeta.class, LlamaMeta::new);
|
||||
put(MULE, MuleMeta.class, MuleMeta::new);
|
||||
put(SKELETON_HORSE, SkeletonHorseMeta.class, SkeletonHorseMeta::new);
|
||||
put(ZOMBIE_HORSE, ZombieHorseMeta.class, ZombieHorseMeta::new);
|
||||
put(SLIME, SlimeMeta.class, SlimeMeta::new);
|
||||
put(MAGMA_CUBE, MagmaCubeMeta.class, MagmaCubeMeta::new);
|
||||
put(SHULKER_BULLET, ShulkerBulletMeta.class, ShulkerBulletMeta::new);
|
||||
put(TRADER_LLAMA, TraderLlamaMeta.class, TraderLlamaMeta::new);
|
||||
put(BAT, BatMeta.class, BatMeta::new);
|
||||
put(IRON_GOLEM, IronGolemMeta.class, IronGolemMeta::new);
|
||||
put(SHULKER, ShulkerMeta.class, ShulkerMeta::new);
|
||||
put(SNOW_GOLEM, SnowGolemMeta.class, SnowGolemMeta::new);
|
||||
}
|
||||
|
||||
private void put(EntityType entityType, Class<? extends EntityMeta> metaClass, BiFunction<Integer, Metadata, EntityMeta> function) {
|
||||
converters.put(entityType, function);
|
||||
metaClasses.put(entityType, metaClass);
|
||||
}
|
||||
|
||||
public Class<? extends EntityMeta> getMetaClass(EntityType entityType) {
|
||||
return metaClasses.getOrDefault(entityType, EntityMeta.class);
|
||||
}
|
||||
|
||||
public @NotNull BiFunction<Integer, Metadata, EntityMeta> get(EntityType entityType) {
|
||||
return converters.getOrDefault(entityType, EntityMeta::new);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package me.tofaa.entitylib.meta;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
|
||||
public @interface UsedVersion {
|
||||
|
||||
ServerVersion[] value();
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package me.tofaa.entitylib.meta;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.manager.server.VersionComparison;
|
||||
import me.tofaa.entitylib.EntityLib;
|
||||
|
||||
public final class VersionCompatCheck {
|
||||
|
||||
private VersionCompatCheck() {}
|
||||
|
||||
static boolean isVersion(ServerVersion version) {
|
||||
return version.is(VersionComparison.EQUALS, EntityLib.getApi().getPacketEvents().getServerManager().getVersion());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,255 @@
|
|||
package me.tofaa.entitylib.meta.display;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.manager.server.VersionComparison;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.util.Quaternion4f;
|
||||
import com.github.retrooper.packetevents.util.Vector3f;
|
||||
import me.tofaa.entitylib.meta.EntityMeta;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public abstract class AbstractDisplayMeta extends EntityMeta {
|
||||
|
||||
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET;
|
||||
static {
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.NEWER_THAN_OR_EQUALS)) {
|
||||
MAX_OFFSET = OFFSET + 15;
|
||||
}
|
||||
else {
|
||||
MAX_OFFSET = OFFSET + 14;
|
||||
}
|
||||
}
|
||||
|
||||
public AbstractDisplayMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
isVersionNewer(ServerVersion.V_1_19_3);
|
||||
}
|
||||
|
||||
public int getInterpolationDelay() {
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
}
|
||||
|
||||
public void setInterpolationDelay(int value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
public int getTransformationInterpolationDuration() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 1), 0);
|
||||
}
|
||||
|
||||
public void setTransformationInterpolationDuration(int value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
public int getPositionRotationInterpolationDuration() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 2), 0);
|
||||
}
|
||||
|
||||
public void setPositionRotationInterpolationDuration(int value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
public Vector3f getTranslation() {
|
||||
byte offset = offset(OFFSET, 3);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 2);
|
||||
}
|
||||
return super.metadata.getIndex(offset, Vector3f.zero());
|
||||
}
|
||||
|
||||
public void setTranslation(Vector3f value) {
|
||||
byte offset = offset(OFFSET, 3);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 2);
|
||||
}
|
||||
super.metadata.setIndex(offset, EntityDataTypes.VECTOR3F, value);
|
||||
}
|
||||
|
||||
public Vector3f getScale() {
|
||||
byte offset = offset(OFFSET, 4);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 3);
|
||||
}
|
||||
return super.metadata.getIndex(offset, new Vector3f(1.0f, 1.0f, 1.0f));
|
||||
}
|
||||
|
||||
public void setScale(Vector3f value) {
|
||||
byte offset = offset(OFFSET, 4);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 3);
|
||||
}
|
||||
super.metadata.setIndex(offset, EntityDataTypes.VECTOR3F, value);
|
||||
}
|
||||
|
||||
public Quaternion4f getLeftRotation() {
|
||||
byte offset = offset(OFFSET, 5);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 4);
|
||||
}
|
||||
return super.metadata.getIndex(offset, new Quaternion4f(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
}
|
||||
|
||||
public void setLeftRotation(Quaternion4f value) {
|
||||
byte offset = offset(OFFSET, 5);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 4);
|
||||
}
|
||||
super.metadata.setIndex(offset, EntityDataTypes.QUATERNION, value);
|
||||
}
|
||||
|
||||
public Quaternion4f getRightRotation() {
|
||||
byte offset = offset(OFFSET, 6);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 5);
|
||||
}
|
||||
return super.metadata.getIndex(offset, new Quaternion4f(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
}
|
||||
|
||||
public void setRightRotation(Quaternion4f value) {
|
||||
byte offset = offset(OFFSET, 6);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 5);
|
||||
}
|
||||
super.metadata.setIndex(offset, EntityDataTypes.QUATERNION, value);
|
||||
}
|
||||
|
||||
public BillboardConstraints getBillboardConstraints() {
|
||||
byte offset = offset(OFFSET, 7);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 6);
|
||||
}
|
||||
return BillboardConstraints.VALUES[super.metadata.getIndex(offset, (byte) 0)];
|
||||
}
|
||||
|
||||
public void setBillboardConstraints(BillboardConstraints value) {
|
||||
byte offset = offset(OFFSET, 7);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 6);
|
||||
}
|
||||
super.metadata.setIndex(offset, EntityDataTypes.BYTE, (byte) value.ordinal());
|
||||
}
|
||||
|
||||
//(blockLight << 4 | skyLight << 20)
|
||||
public int getBrightnessOverride() {
|
||||
byte offset = offset(OFFSET, 8);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 7);
|
||||
}
|
||||
return super.metadata.getIndex(offset, -1);
|
||||
}
|
||||
|
||||
public void setBrightnessOverride(int value) {
|
||||
byte offset = offset(OFFSET, 8);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 7);
|
||||
}
|
||||
super.metadata.setIndex(offset, EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
public float getViewRange() {
|
||||
byte offset = offset(OFFSET, 9);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 8);
|
||||
}
|
||||
return super.metadata.getIndex(offset, 1.0f);
|
||||
}
|
||||
|
||||
public void setViewRange(float value) {
|
||||
byte offset = offset(OFFSET, 9);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 8);
|
||||
}
|
||||
super.metadata.setIndex(offset, EntityDataTypes.FLOAT, value);
|
||||
}
|
||||
|
||||
public float getShadowRadius() {
|
||||
byte offset = offset(OFFSET, 10);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 9);
|
||||
}
|
||||
return super.metadata.getIndex(offset, 0.0f);
|
||||
}
|
||||
|
||||
public void setShadowRadius(float value) {
|
||||
byte offset = offset(OFFSET, 10);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 9);
|
||||
}
|
||||
super.metadata.setIndex(offset, EntityDataTypes.FLOAT, value);
|
||||
}
|
||||
|
||||
public float getShadowStrength() {
|
||||
byte offset = offset(OFFSET, 11);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 10);
|
||||
}
|
||||
return super.metadata.getIndex(offset, 1.0f);
|
||||
}
|
||||
|
||||
public void setShadowStrength(float value) {
|
||||
byte offset = offset(OFFSET, 11);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 10);
|
||||
}
|
||||
super.metadata.setIndex(offset, EntityDataTypes.FLOAT, value);
|
||||
}
|
||||
|
||||
public float getWidth() {
|
||||
byte offset = offset(OFFSET, 12);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 11);
|
||||
}
|
||||
return super.metadata.getIndex(offset, 0.0f);
|
||||
}
|
||||
|
||||
public void setWidth(float value) {
|
||||
byte offset = offset(OFFSET, 12);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 11);
|
||||
}
|
||||
super.metadata.setIndex(offset, EntityDataTypes.FLOAT, value);
|
||||
}
|
||||
|
||||
public float getHeight() {
|
||||
byte offset = offset(OFFSET, 13);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 12);
|
||||
}
|
||||
return super.metadata.getIndex(offset, 0.0f);
|
||||
}
|
||||
|
||||
public void setHeight(float value) {
|
||||
byte offset = offset(OFFSET, 13);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 12);
|
||||
}
|
||||
super.metadata.setIndex(offset, EntityDataTypes.FLOAT, value);
|
||||
}
|
||||
|
||||
public int getGlowColorOverride() {
|
||||
byte offset = offset(OFFSET, 14);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 13);
|
||||
}
|
||||
return super.metadata.getIndex(offset, -1);
|
||||
}
|
||||
|
||||
public void setGlowColorOverride(int value) {
|
||||
byte offset = offset(OFFSET, 14);
|
||||
if (isVersion(ServerVersion.V_1_20_2, VersionComparison.OLDER_THAN)) {
|
||||
offset = offset(OFFSET, 13);
|
||||
}
|
||||
super.metadata.setIndex(offset, EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
public enum BillboardConstraints {
|
||||
FIXED,
|
||||
VERTICAL,
|
||||
HORIZONTAL,
|
||||
CENTER;
|
||||
|
||||
private static final BillboardConstraints[] VALUES = values();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package me.tofaa.entitylib.meta.display;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class BlockDisplayMeta extends AbstractDisplayMeta {
|
||||
|
||||
public static final byte OFFSET = AbstractDisplayMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = offset(OFFSET, 1);
|
||||
|
||||
public BlockDisplayMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public int getBlockId() {
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
}
|
||||
|
||||
public void setBlockId(int blockId) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, blockId);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package me.tofaa.entitylib.meta.display;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class ItemDisplayMeta extends AbstractDisplayMeta {
|
||||
|
||||
public static final byte OFFSET = AbstractDisplayMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = offset(OFFSET, 1);
|
||||
|
||||
public ItemDisplayMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return super.metadata.getIndex(OFFSET, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
public void setItem(ItemStack itemStack) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.ITEMSTACK, itemStack);
|
||||
}
|
||||
|
||||
public DisplayType getDisplayType() {
|
||||
return DisplayType.VALUES[super.metadata.getIndex(offset(OFFSET, 1), 0)];
|
||||
}
|
||||
|
||||
public void setDisplayType(DisplayType displayType) {
|
||||
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BYTE, (byte) displayType.ordinal());
|
||||
}
|
||||
|
||||
public enum DisplayType {
|
||||
NONE,
|
||||
THIRD_PERSON_LEFT_HAND,
|
||||
THIRD_PERSON_RIGHT_HAND,
|
||||
FIRST_PERSON_LEFT_HAND,
|
||||
FIRST_PERSON_RIGHT_HAND,
|
||||
HEAD,
|
||||
GUI,
|
||||
GROUND,
|
||||
FIXED;
|
||||
|
||||
private static final DisplayType[] VALUES = values();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
package me.tofaa.entitylib.meta.display;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public class TextDisplayMeta extends AbstractDisplayMeta {
|
||||
|
||||
public static final byte OFFSET = AbstractDisplayMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = offset(OFFSET, 5);
|
||||
|
||||
private static final byte SHADOW = 1;
|
||||
private static final byte SEE_THROUGH = 2;
|
||||
private static final byte USE_DEFAULT_BACKGROUND = 4;
|
||||
private static final byte ALIGN_LEFT = 8;
|
||||
private static final byte ALIGN_RIGHT = 16;
|
||||
|
||||
public TextDisplayMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
|
||||
public Component getText() {
|
||||
return metadata.getIndex(OFFSET, Component.empty());
|
||||
}
|
||||
|
||||
public void setText(Component component) {
|
||||
metadata.setIndex(OFFSET, EntityDataTypes.ADV_COMPONENT, component);
|
||||
}
|
||||
|
||||
public int getLineWidth() {
|
||||
return metadata.getIndex(offset(OFFSET, 1), 200);
|
||||
}
|
||||
|
||||
public void setLineWidth(int value) {
|
||||
metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
public int getBackgroundColor() {
|
||||
return metadata.getIndex(offset(OFFSET, 2), 0);
|
||||
}
|
||||
|
||||
public void setBackgroundColor(int value) {
|
||||
metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
public byte getTextOpacity() {
|
||||
return metadata.getIndex(offset(OFFSET, 3), (byte) -1);
|
||||
}
|
||||
|
||||
public void setTextOpacity(byte value) {
|
||||
metadata.setIndex(offset(OFFSET, 3), EntityDataTypes.BYTE, value);
|
||||
}
|
||||
|
||||
public boolean isShadow() {
|
||||
return getMaskBit(offset(OFFSET, 4), SHADOW);
|
||||
}
|
||||
|
||||
public void setShadow(boolean value) {
|
||||
setMaskBit(offset(OFFSET, 4), SHADOW, value);
|
||||
}
|
||||
|
||||
public boolean isSeeThrough() {
|
||||
return getMaskBit(offset(OFFSET, 4), SEE_THROUGH);
|
||||
}
|
||||
|
||||
public void setSeeThrough(boolean value) {
|
||||
setMaskBit(offset(OFFSET, 4), SEE_THROUGH, value);
|
||||
}
|
||||
|
||||
public boolean isUseDefaultBackground() {
|
||||
return getMaskBit(offset(OFFSET, 4), USE_DEFAULT_BACKGROUND);
|
||||
}
|
||||
|
||||
public void setUseDefaultBackground(boolean value) {
|
||||
setMaskBit(offset(OFFSET, 4), USE_DEFAULT_BACKGROUND, value);
|
||||
}
|
||||
|
||||
public boolean isAlignLeft() {
|
||||
return getMaskBit(offset(OFFSET, 4), ALIGN_LEFT);
|
||||
}
|
||||
|
||||
public void setAlignLeft(boolean value) {
|
||||
setMaskBit(OFFSET + 4, ALIGN_LEFT, value);
|
||||
}
|
||||
|
||||
public boolean isAlignRight() {
|
||||
return getMaskBit(offset(OFFSET, 4), ALIGN_RIGHT);
|
||||
}
|
||||
|
||||
public void setAlignRight(boolean value) {
|
||||
setMaskBit(offset(OFFSET, 4), ALIGN_RIGHT, value);
|
||||
}
|
||||
}
|
26
api/src/main/java/me/tofaa/entitylib/meta/mobs/BatMeta.java
Normal file
26
api/src/main/java/me/tofaa/entitylib/meta/mobs/BatMeta.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
package me.tofaa.entitylib.meta.mobs;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
public class BatMeta extends MobMeta {
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
private final static byte IS_HANGING_BIT = 0x01;
|
||||
|
||||
public BatMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isHanging() {
|
||||
return getMaskBit(OFFSET, IS_HANGING_BIT);
|
||||
}
|
||||
|
||||
public void setHanging(boolean value) {
|
||||
setMaskBit(OFFSET, IS_HANGING_BIT, value);
|
||||
}
|
||||
|
||||
|
||||
}
|
52
api/src/main/java/me/tofaa/entitylib/meta/mobs/BeeMeta.java
Normal file
52
api/src/main/java/me/tofaa/entitylib/meta/mobs/BeeMeta.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
package me.tofaa.entitylib.meta.mobs;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
|
||||
public class BeeMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
private final static byte ANGRY_BIT = 0x02;
|
||||
private final static byte HAS_STUNG_BIT = 0x04;
|
||||
private final static byte HAS_NECTAR_BIT = 0x08;
|
||||
|
||||
public BeeMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isAngry() {
|
||||
return getMaskBit(OFFSET, ANGRY_BIT);
|
||||
}
|
||||
|
||||
public void setAngry(boolean value) {
|
||||
setMaskBit(OFFSET, ANGRY_BIT, value);
|
||||
}
|
||||
|
||||
public boolean hasStung() {
|
||||
return getMaskBit(OFFSET, HAS_STUNG_BIT);
|
||||
}
|
||||
|
||||
public void setHasStung(boolean value) {
|
||||
setMaskBit(OFFSET, HAS_STUNG_BIT, value);
|
||||
}
|
||||
|
||||
public boolean hasNectar() {
|
||||
return getMaskBit(OFFSET, HAS_NECTAR_BIT);
|
||||
}
|
||||
|
||||
public void setHasNectar(boolean value) {
|
||||
setMaskBit(OFFSET, HAS_NECTAR_BIT, value);
|
||||
}
|
||||
|
||||
public int getAngerTicks() {
|
||||
return super.metadata.getIndex(offset(OFFSET,1), 0);
|
||||
}
|
||||
|
||||
public void setAngerTicks(int value) {
|
||||
super.metadata.setIndex(offset(OFFSET,1), EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package me.tofaa.entitylib.meta.mobs;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
|
||||
public class DonkeyMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public DonkeyMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
119
api/src/main/java/me/tofaa/entitylib/meta/mobs/FoxMeta.java
Normal file
119
api/src/main/java/me/tofaa/entitylib/meta/mobs/FoxMeta.java
Normal file
|
@ -0,0 +1,119 @@
|
|||
package me.tofaa.entitylib.meta.mobs;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FoxMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET+ 4;
|
||||
|
||||
private final static byte SITTING_BIT = 0x01;
|
||||
private final static byte CROUCHING_BIT = 0x04;
|
||||
private final static byte INTERESTED_BIT = 0x08;
|
||||
private final static byte POUNCING_BIT = 0x10;
|
||||
private final static byte SLEEPING_BIT = 0x20;
|
||||
private final static byte FACEPLANTED_BIT = 0x40;
|
||||
private final static byte DEFENDING_BIT = (byte) 0x80;
|
||||
|
||||
|
||||
public FoxMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Type getType() {
|
||||
return Type.VALUES[super.metadata.getIndex(OFFSET, 0)];
|
||||
}
|
||||
|
||||
public void setType(@NotNull Type type) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, type.ordinal());
|
||||
}
|
||||
|
||||
public boolean isSitting() {
|
||||
return getMaskBit(offset(OFFSET, 1), SITTING_BIT);
|
||||
}
|
||||
|
||||
public void setSitting(boolean value) {
|
||||
setMaskBit(offset(OFFSET, 1), SITTING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isFoxSneaking() {
|
||||
return getMaskBit(offset(OFFSET, 1), CROUCHING_BIT);
|
||||
}
|
||||
|
||||
public void setFoxSneaking(boolean value) {
|
||||
setMaskBit(offset(OFFSET, 1), CROUCHING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isInterested() {
|
||||
return getMaskBit(offset(OFFSET, 1), INTERESTED_BIT);
|
||||
}
|
||||
|
||||
public void setInterested(boolean value) {
|
||||
setMaskBit(offset(OFFSET, 1), INTERESTED_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isPouncing() {
|
||||
return getMaskBit(offset(OFFSET, 1), POUNCING_BIT);
|
||||
}
|
||||
|
||||
public void setPouncing(boolean value) {
|
||||
setMaskBit(offset(OFFSET, 1), POUNCING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isSleeping() {
|
||||
return getMaskBit(offset(OFFSET, 1), SLEEPING_BIT);
|
||||
}
|
||||
|
||||
public void setSleeping(boolean value) {
|
||||
setMaskBit(offset(OFFSET, 1), SLEEPING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isFaceplanted() {
|
||||
return getMaskBit(offset(OFFSET, 1), FACEPLANTED_BIT);
|
||||
}
|
||||
|
||||
public void setFaceplanted(boolean value) {
|
||||
setMaskBit(offset(OFFSET, 1), FACEPLANTED_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isDefending() {
|
||||
return getMaskBit(offset(OFFSET, 1), DEFENDING_BIT);
|
||||
}
|
||||
|
||||
public void setDefending(boolean value) {
|
||||
setMaskBit(offset(OFFSET, 1), DEFENDING_BIT, value);
|
||||
}
|
||||
|
||||
public Optional<UUID> getFirstUUID() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 2), Optional.empty());
|
||||
}
|
||||
|
||||
public void setFirstUUID(@Nullable UUID value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.OPTIONAL_UUID, Optional.of(value));
|
||||
}
|
||||
|
||||
public Optional<UUID> getSecondUUID() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 3), Optional.empty());
|
||||
}
|
||||
|
||||
public void setSecondUUID(@Nullable UUID value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 3), EntityDataTypes.OPTIONAL_UUID, Optional.of(value));
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
RED,
|
||||
SNOW;
|
||||
|
||||
private final static Type[] VALUES = values();
|
||||
}
|
||||
|
||||
|
||||
}
|
46
api/src/main/java/me/tofaa/entitylib/meta/mobs/FrogMeta.java
Normal file
46
api/src/main/java/me/tofaa/entitylib/meta/mobs/FrogMeta.java
Normal file
|
@ -0,0 +1,46 @@
|
|||
package me.tofaa.entitylib.meta.mobs;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class FrogMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
|
||||
public FrogMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
|
||||
public @NotNull Variant getVariant() {
|
||||
return super.metadata.getIndex(OFFSET, Variant.TEMPERATE);
|
||||
}
|
||||
|
||||
public void setVariant(@NotNull Variant value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.FROG_VARIANT, value.ordinal());
|
||||
}
|
||||
|
||||
public Optional<Integer> getTongueTarget() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 1), Optional.empty());
|
||||
}
|
||||
|
||||
public void setTongueTarget(int value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.OPTIONAL_INT, Optional.of(value));
|
||||
}
|
||||
|
||||
|
||||
public enum Variant {
|
||||
TEMPERATE,
|
||||
WARM,
|
||||
COLD;
|
||||
|
||||
private final static FrogMeta.Variant[] VALUES = values();
|
||||
}
|
||||
|
||||
}
|
25
api/src/main/java/me/tofaa/entitylib/meta/mobs/GoatMeta.java
Normal file
25
api/src/main/java/me/tofaa/entitylib/meta/mobs/GoatMeta.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
package me.tofaa.entitylib.meta.mobs;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
|
||||
public class GoatMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
|
||||
public GoatMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isScreaming() {
|
||||
return metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setScreaming(boolean screaming) {
|
||||
metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, screaming);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package me.tofaa.entitylib.meta.mobs;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
|
||||
public class HoglinMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public HoglinMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
|
||||
public boolean isImmuneToZombification() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setImmuneToZombification(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package me.tofaa.entitylib.meta.mobs;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
|
||||
public class OcelotMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public OcelotMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isTrusting() {
|
||||
isVersionNewer(ServerVersion.V_1_14);
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setTrusting(boolean value) {
|
||||
isVersionNewer(ServerVersion.V_1_14);
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
}
|
109
api/src/main/java/me/tofaa/entitylib/meta/mobs/PandaMeta.java
Normal file
109
api/src/main/java/me/tofaa/entitylib/meta/mobs/PandaMeta.java
Normal file
|
@ -0,0 +1,109 @@
|
|||
package me.tofaa.entitylib.meta.mobs;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PandaMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 6;
|
||||
|
||||
private final static byte SNEEZING_BIT = 0x02;
|
||||
private final static byte ROLLING_BIT = 0x04;
|
||||
private final static byte SITTING_BIT = 0x08;
|
||||
private final static byte ON_BACK_BIT = 0x10;
|
||||
|
||||
public PandaMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public int getBreedTimer() {
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
}
|
||||
|
||||
public void setBreedTimer(int value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
public int getSneezeTimer() {
|
||||
return super.metadata.getIndex(offset(OFFSET,1), 0);
|
||||
}
|
||||
|
||||
public void setSneezeTimer(int value) {
|
||||
super.metadata.setIndex(offset(OFFSET,1), EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
public int getEatTimer() {
|
||||
return super.metadata.getIndex(offset(OFFSET,2), 0);
|
||||
}
|
||||
|
||||
public void setEatTimer(int value) {
|
||||
super.metadata.setIndex(offset(OFFSET,2), EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Gene getMainGene() {
|
||||
return Gene.VALUES[super.metadata.getIndex(offset(OFFSET,3), (byte) 0)];
|
||||
}
|
||||
|
||||
public void setMainGene(@NotNull Gene value) {
|
||||
super.metadata.setIndex(offset(OFFSET,3), EntityDataTypes.BYTE, (byte) value.ordinal());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Gene getHiddenGene() {
|
||||
return Gene.VALUES[super.metadata.getIndex(offset(OFFSET,4), (byte) 0)];
|
||||
}
|
||||
|
||||
public void setHiddenGene(@NotNull Gene value) {
|
||||
super.metadata.setIndex(offset(OFFSET,4), EntityDataTypes.BYTE, (byte) value.ordinal());
|
||||
}
|
||||
|
||||
public boolean isSneezing() {
|
||||
return getMaskBit(offset(OFFSET,5), SNEEZING_BIT);
|
||||
}
|
||||
|
||||
public void setSneezing(boolean value) {
|
||||
setMaskBit(offset(OFFSET,5), SNEEZING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isRolling() {
|
||||
return getMaskBit(offset(OFFSET,5), ROLLING_BIT);
|
||||
}
|
||||
|
||||
public void setRolling(boolean value) {
|
||||
setMaskBit(offset(OFFSET,5), ROLLING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isSitting() {
|
||||
return getMaskBit(offset(OFFSET,5), SITTING_BIT);
|
||||
}
|
||||
|
||||
public void setSitting(boolean value) {
|
||||
setMaskBit(offset(OFFSET,5), SITTING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isOnBack() {
|
||||
return getMaskBit(offset(OFFSET,5), ON_BACK_BIT);
|
||||
}
|
||||
|
||||
public void setOnBack(boolean value) {
|
||||
setMaskBit(offset(OFFSET,5), ON_BACK_BIT, value);
|
||||
}
|
||||
|
||||
public enum Gene {
|
||||
NORMAL,
|
||||
AGGRESSIVE,
|
||||
LAZY,
|
||||
WORRIED,
|
||||
PLAYFUL,
|
||||
WEAK,
|
||||
BROWN;
|
||||
|
||||
private final static Gene[] VALUES = values();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package me.tofaa.entitylib.meta.mobs;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
|
||||
public class PolarBearMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public PolarBearMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isStandingUp() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setStandingUp(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package me.tofaa.entitylib.meta.mobs;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.protocol.entity.sniffer.SnifferState;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
|
||||
public class SnifferMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public SnifferMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public SnifferState getState() {
|
||||
return metadata.getIndex(OFFSET, SnifferState.IDLING);
|
||||
}
|
||||
|
||||
public void setState(SnifferState state) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.SNIFFER_STATE, state);
|
||||
}
|
||||
|
||||
public int getDropSeedAtTick() {
|
||||
return metadata.getIndex(offset(OFFSET, 1), 0);
|
||||
}
|
||||
|
||||
public void setDropSeedAtTick(int tick) {
|
||||
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.INT, tick);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package me.tofaa.entitylib.meta.mobs;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
|
||||
public class StriderMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
public StriderMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
|
||||
public int getTimeToBoost() {
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
}
|
||||
|
||||
public void setTimeToBoost(int value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
public boolean isShaking() {
|
||||
return super.metadata.getIndex(offset(OFFSET,1), false);
|
||||
}
|
||||
|
||||
public void setShaking(boolean value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public boolean isHasSaddle() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 2), false);
|
||||
}
|
||||
|
||||
public void setHasSaddle(boolean value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package me.tofaa.entitylib.meta.mobs.cuboid;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class MagmaCubeMeta extends SlimeMeta {
|
||||
|
||||
public static final byte OFFSET = SlimeMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public MagmaCubeMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package me.tofaa.entitylib.meta.mobs.cuboid;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
public class SlimeMeta extends MobMeta {
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public SlimeMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
}
|
||||
|
||||
public void setSize(int value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package me.tofaa.entitylib.meta.mobs.golem;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
public class IronGolemMeta extends MobMeta {
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final static byte PLAYER_CREATED_BIT = 0x01;
|
||||
|
||||
public IronGolemMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isPlayerCreated() {
|
||||
return getMaskBit(OFFSET, PLAYER_CREATED_BIT);
|
||||
}
|
||||
|
||||
public void setPlayerCreated(boolean value) {
|
||||
setMaskBit(OFFSET, PLAYER_CREATED_BIT, value);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package me.tofaa.entitylib.meta.mobs.golem;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.protocol.world.Direction;
|
||||
import com.github.retrooper.packetevents.util.Vector3i;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class ShulkerMeta extends MobMeta {
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
|
||||
public ShulkerMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public Direction getAttachFace() {
|
||||
return super.metadata.getIndex(OFFSET, Direction.DOWN);
|
||||
}
|
||||
|
||||
public void setAttachFace(Direction value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value.ordinal());
|
||||
}
|
||||
|
||||
public Optional<Vector3i> getAttachmentPosition() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 1), Optional.empty());
|
||||
}
|
||||
|
||||
public void setAttachmentPosition(Vector3i value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.OPTIONAL_BLOCK_POSITION, Optional.of(value));
|
||||
}
|
||||
|
||||
public byte getShieldHeight() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 2), (byte) 0);
|
||||
}
|
||||
|
||||
public void setShieldHeight(byte value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BYTE, value);
|
||||
}
|
||||
|
||||
public byte getColor() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 3), (byte) 10);
|
||||
}
|
||||
|
||||
public void setColor(byte value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 3), EntityDataTypes.BYTE, value);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package me.tofaa.entitylib.meta.mobs.golem;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
public class SnowGolemMeta extends MobMeta {
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public SnowGolemMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isHasPumpkinHat() {
|
||||
return super.metadata.getIndex(OFFSET, (byte) 0x10) == (byte) 0x10;
|
||||
}
|
||||
|
||||
public void setHasPumpkinHat(boolean value) {
|
||||
byte var = value ? (byte) 0x10 : (byte) 0x00;
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.BYTE, var);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package me.tofaa.entitylib.meta.mobs.horse;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class BaseHorseMeta extends MobMeta {
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
private final static byte TAMED_BIT = 0x02;
|
||||
private final static byte SADDLED_BIT = 0x04;
|
||||
private final static byte HAS_BRED_BIT = 0x08;
|
||||
private final static byte EATING_BIT = 0x10;
|
||||
private final static byte REARING_BIT = 0x20;
|
||||
private final static byte MOUTH_OPEN_BIT = 0x40;
|
||||
|
||||
protected BaseHorseMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isTamed() {
|
||||
return getMaskBit(OFFSET, TAMED_BIT);
|
||||
}
|
||||
|
||||
public void setTamed(boolean value) {
|
||||
setMaskBit(OFFSET, TAMED_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isSaddled() {
|
||||
return getMaskBit(OFFSET, SADDLED_BIT);
|
||||
}
|
||||
|
||||
public void setSaddled(boolean value) {
|
||||
setMaskBit(OFFSET, SADDLED_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isHasBred() {
|
||||
return getMaskBit(OFFSET, HAS_BRED_BIT);
|
||||
}
|
||||
|
||||
public void setHasBred(boolean value) {
|
||||
setMaskBit(OFFSET, HAS_BRED_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isEating() {
|
||||
return getMaskBit(OFFSET, EATING_BIT);
|
||||
}
|
||||
|
||||
public void setEating(boolean value) {
|
||||
setMaskBit(OFFSET, EATING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isRearing() {
|
||||
return getMaskBit(OFFSET, REARING_BIT);
|
||||
}
|
||||
|
||||
public void setRearing(boolean value) {
|
||||
setMaskBit(OFFSET, REARING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isMouthOpen() {
|
||||
return getMaskBit(OFFSET, MOUTH_OPEN_BIT);
|
||||
}
|
||||
|
||||
public void setMouthOpen(boolean value) {
|
||||
setMaskBit(OFFSET, MOUTH_OPEN_BIT, value);
|
||||
}
|
||||
|
||||
public Optional<UUID> getOwner() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 1), Optional.empty());
|
||||
}
|
||||
|
||||
public void setOwner(UUID value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.OPTIONAL_UUID, Optional.of(value));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package me.tofaa.entitylib.meta.mobs.horse;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class ChestedHorseMeta extends BaseHorseMeta {
|
||||
|
||||
public static final byte OFFSET = BaseHorseMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public ChestedHorseMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isHasChest() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setHasChest(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package me.tofaa.entitylib.meta.mobs.horse;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
public class DonkeyMeta extends ChestedHorseMeta{
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public DonkeyMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package me.tofaa.entitylib.meta.mobs.horse;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HorseMeta extends BaseHorseMeta {
|
||||
|
||||
public static final byte OFFSET = BaseHorseMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public HorseMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public Variant getVariant() {
|
||||
return getVariantFromID(super.metadata.getIndex(OFFSET, 0));
|
||||
}
|
||||
|
||||
public void setVariant(Variant variant) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, getVariantID(variant.marking, variant.color));
|
||||
}
|
||||
|
||||
public static int getVariantID(@NotNull Marking marking, @NotNull Color color) {
|
||||
return (marking.ordinal() << 8) + color.ordinal();
|
||||
}
|
||||
|
||||
public static Variant getVariantFromID(int variantID) {
|
||||
return new Variant(
|
||||
Marking.VALUES[variantID >> 8],
|
||||
Color.VALUES[variantID & 0xFF]
|
||||
);
|
||||
}
|
||||
|
||||
public static class Variant {
|
||||
|
||||
private Marking marking;
|
||||
private Color color;
|
||||
|
||||
public Variant(@NotNull Marking marking, @NotNull Color color) {
|
||||
this.marking = marking;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Marking getMarking() {
|
||||
return this.marking;
|
||||
}
|
||||
|
||||
public void setMarking(@NotNull Marking marking) {
|
||||
this.marking = marking;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Color getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public void setColor(@NotNull Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum Marking {
|
||||
NONE,
|
||||
WHITE,
|
||||
WHITE_FIELD,
|
||||
WHITE_DOTS,
|
||||
BLACK_DOTS;
|
||||
|
||||
private final static Marking[] VALUES = values();
|
||||
}
|
||||
|
||||
public enum Color {
|
||||
WHITE,
|
||||
CREAMY,
|
||||
CHESTNUT,
|
||||
BROWN,
|
||||
BLACK,
|
||||
GRAY,
|
||||
DARK_BROWN;
|
||||
|
||||
private final static Color[] VALUES = values();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package me.tofaa.entitylib.meta.mobs.horse;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class LlamaMeta extends ChestedHorseMeta{
|
||||
|
||||
public static final byte OFFSET = ChestedHorseMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
public LlamaMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public int getStrength() {
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
}
|
||||
|
||||
public void setStrength(int value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
public int getCarpetColor() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 1), -1);
|
||||
}
|
||||
|
||||
public void setCarpetColor(int value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
public Variant getVariant() {
|
||||
return Variant.VALUES[super.metadata.getIndex(offset(OFFSET, 2), 0)];
|
||||
}
|
||||
|
||||
public void setVariant(Variant value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.INT, value.ordinal());
|
||||
}
|
||||
|
||||
public enum Variant {
|
||||
CREAMY,
|
||||
WHITE,
|
||||
BROWN,
|
||||
GRAY;
|
||||
|
||||
private final static Variant[] VALUES = values();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package me.tofaa.entitylib.meta.mobs.horse;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class MuleMeta extends ChestedHorseMeta{
|
||||
|
||||
public static final byte OFFSET = ChestedHorseMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public MuleMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package me.tofaa.entitylib.meta.mobs.horse;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class SkeletonHorseMeta extends BaseHorseMeta {
|
||||
|
||||
public static final byte OFFSET = BaseHorseMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public SkeletonHorseMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package me.tofaa.entitylib.meta.mobs.horse;
|
||||
|
||||
import me.tofaa.entitylib.meta.EntityMeta;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class TraderLlamaMeta extends EntityMeta {
|
||||
|
||||
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public TraderLlamaMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package me.tofaa.entitylib.meta.mobs.horse;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class ZombieHorseMeta extends BaseHorseMeta {
|
||||
|
||||
public static final byte OFFSET = BaseHorseMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public ZombieHorseMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package me.tofaa.entitylib.meta.mobs.minecart;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.EntityMeta;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.ObjectData;
|
||||
|
||||
public abstract class BaseMinecartMeta extends EntityMeta implements ObjectData {
|
||||
|
||||
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 6;
|
||||
|
||||
protected BaseMinecartMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public int getShakingPower() {
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
}
|
||||
|
||||
public void setShakingPower(int value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
public int getShakingDirection() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 1), 1);
|
||||
}
|
||||
|
||||
public void setShakingDirection(int value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
public float getShakingMultiplier() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 2), 0F);
|
||||
}
|
||||
|
||||
public void setShakingMultiplier(float value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.FLOAT, value);
|
||||
}
|
||||
|
||||
public int getCustomBlockIdAndDamage() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 3), 0);
|
||||
}
|
||||
|
||||
public void setCustomBlockIdAndDamage(int value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 3), EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
// in 16th of a block
|
||||
public int getCustomBlockYPosition() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 4), 6);
|
||||
}
|
||||
|
||||
public void setCustomBlockYPosition(int value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 4), EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresVelocityPacketAtSpawn() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package me.tofaa.entitylib.meta.mobs.minecart;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class ChestMinecartMeta extends BaseMinecartMeta{
|
||||
|
||||
public static final byte OFFSET = BaseMinecartMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
|
||||
public ChestMinecartMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getObjectData() {
|
||||
return 1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package me.tofaa.entitylib.meta.mobs.minecart;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CommandBlockMinecartMeta extends BaseMinecartMeta{
|
||||
|
||||
public static final byte OFFSET = BaseMinecartMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
public CommandBlockMinecartMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public @NotNull String getCommand() {
|
||||
return super.metadata.getIndex(OFFSET, "");
|
||||
}
|
||||
|
||||
public void setCommand(@NotNull String value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.STRING, value);
|
||||
}
|
||||
|
||||
public @NotNull Component getLastOutput() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 1), Component.empty());
|
||||
}
|
||||
|
||||
public void setLastOutput(@NotNull Component value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.COMPONENT, GsonComponentSerializer.gson().serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getObjectData() {
|
||||
return 6;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package me.tofaa.entitylib.meta.mobs.minecart;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class FurnaceMinecartMeta extends BaseMinecartMeta {
|
||||
|
||||
public static final byte OFFSET = BaseMinecartMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public FurnaceMinecartMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isHasFuel() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setHasFuel(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getObjectData() {
|
||||
return 2; }
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package me.tofaa.entitylib.meta.mobs.minecart;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class HopperMinecartMeta extends BaseMinecartMeta {
|
||||
|
||||
public static final byte OFFSET = BaseMinecartMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public HopperMinecartMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getObjectData() {
|
||||
return 5;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package me.tofaa.entitylib.meta.mobs.minecart;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class MinecartMeta extends BaseMinecartMeta {
|
||||
|
||||
public static final byte OFFSET = BaseMinecartMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public MinecartMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getObjectData() {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package me.tofaa.entitylib.meta.mobs.minecart;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class SpawnerMinecartMeta extends BaseMinecartMeta {
|
||||
|
||||
public static final byte OFFSET = BaseMinecartMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public SpawnerMinecartMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getObjectData() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package me.tofaa.entitylib.meta.mobs.minecart;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class TntMinecartMeta extends BaseMinecartMeta{
|
||||
|
||||
public static final byte OFFSET = BaseMinecartMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public TntMinecartMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getObjectData() {
|
||||
return 3;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
public class BlazeMeta extends MobMeta {
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final static byte ON_FIRE_BIT = 0x01;
|
||||
|
||||
public BlazeMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isOnFire() {
|
||||
return getMaskBit(OFFSET, ON_FIRE_BIT);
|
||||
}
|
||||
|
||||
public void setOnFire(boolean value) {
|
||||
setMaskBit(OFFSET, ON_FIRE_BIT, value);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class CaveSpiderMeta extends SpiderMeta{
|
||||
|
||||
public static final byte OFFSET = SpiderMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public CaveSpiderMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CreeperMeta extends MobMeta {
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
public CreeperMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public State getState() {
|
||||
int id = super.metadata.getIndex(OFFSET, -1);
|
||||
return id == -1 ? State.IDLE : State.FUSE;
|
||||
}
|
||||
|
||||
public void setState(@NotNull State value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value == State.IDLE ? -1 : 1);
|
||||
}
|
||||
|
||||
public boolean isCharged() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 1), false);
|
||||
}
|
||||
|
||||
public void setCharged(boolean value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public boolean isIgnited() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 2), false);
|
||||
}
|
||||
|
||||
public void setIgnited(boolean value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public enum State {
|
||||
IDLE,
|
||||
FUSE
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class ElderGuardianMeta extends GuardianMeta{
|
||||
|
||||
public static final byte OFFSET = GuardianMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public ElderGuardianMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class EndermanMeta extends MobMeta {
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
public EndermanMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public Integer getCarriedBlockID() {
|
||||
return super.metadata.getIndex(OFFSET, null);
|
||||
}
|
||||
|
||||
public void setCarriedBlockID(@Nullable Integer value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.OPTIONAL_INT, Optional.ofNullable(value));
|
||||
}
|
||||
|
||||
public boolean isScreaming() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 1), false);
|
||||
}
|
||||
|
||||
public void setScreaming(boolean value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public boolean isStaring() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 2), false);
|
||||
}
|
||||
|
||||
public void setStaring(boolean value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
public class EndermiteMeta extends MobMeta {
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public EndermiteMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
public class GhastMeta extends MobMeta {
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public GhastMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
|
||||
public boolean isAttacking() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setAttacking(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
public class GiantMeta extends MobMeta {
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public GiantMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
public class GuardianMeta extends MobMeta {
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
private int target = -1;
|
||||
|
||||
public GuardianMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isRetractingSpikes() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setRetractingSpikes(boolean retractingSpikes) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, retractingSpikes);
|
||||
}
|
||||
|
||||
public int getTarget() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
public void setTarget(int target) {
|
||||
this.target = target;
|
||||
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.INT, target == -1 ? 0 : target);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
public class PhantomMeta extends MobMeta {
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public PhantomMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
}
|
||||
|
||||
public void setSize(int value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
public class SilverfishMeta extends MobMeta {
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
|
||||
public SilverfishMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
public class SpiderMeta extends MobMeta {
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final static byte CLIMBING_BIT = 0x01;
|
||||
|
||||
|
||||
public SpiderMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isClimbing() {
|
||||
return getMaskBit(OFFSET, CLIMBING_BIT);
|
||||
}
|
||||
|
||||
public void setClimbing(boolean value) {
|
||||
setMaskBit(OFFSET, CLIMBING_BIT, value);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
public class VexMeta extends MobMeta {
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final static byte ATTACKING_BIT = 0x01;
|
||||
|
||||
public VexMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isAttacking() {
|
||||
return getMaskBit(OFFSET, ATTACKING_BIT);
|
||||
}
|
||||
|
||||
public void setAttacking(boolean value) {
|
||||
setMaskBit(OFFSET, ATTACKING_BIT, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
public class WitherMeta extends MobMeta {
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 4;
|
||||
|
||||
private int centerHead = -1;
|
||||
private int leftHead = -1;
|
||||
private int rightHead = -1;
|
||||
|
||||
public WitherMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public void setCenterHead(int centerHead) {
|
||||
this.centerHead = centerHead;
|
||||
super.metadata.setIndex(offset(OFFSET,0), EntityDataTypes.INT, centerHead == -1 ? 0 : centerHead);
|
||||
}
|
||||
|
||||
public void setLeftHead(int leftHead) {
|
||||
this.leftHead = leftHead;
|
||||
super.metadata.setIndex(offset(OFFSET,1), EntityDataTypes.INT, leftHead == -1 ? 0 : leftHead);
|
||||
}
|
||||
|
||||
public void setRightHead(int rightHead) {
|
||||
this.rightHead = rightHead;
|
||||
super.metadata.setIndex(offset(OFFSET,2), EntityDataTypes.INT, rightHead == -1 ? 0 : rightHead);
|
||||
}
|
||||
|
||||
public int getCenterHead() {
|
||||
return centerHead;
|
||||
}
|
||||
|
||||
public int getLeftHead() {
|
||||
return leftHead;
|
||||
}
|
||||
|
||||
public int getRightHead() {
|
||||
return rightHead;
|
||||
}
|
||||
|
||||
public int getInvulnerableTime() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 3), 0);
|
||||
}
|
||||
|
||||
public void setInvulnerableTime(int value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 3), EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
public class ZoglinMeta extends MobMeta {
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public ZoglinMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
|
||||
public boolean isBaby() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setBaby(boolean value) {
|
||||
if (isBaby() == value) {
|
||||
return;
|
||||
}
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster.piglin;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
public abstract class BasePiglinMeta extends MobMeta {
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
protected BasePiglinMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isImmuneToZombification() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setImmuneToZombification(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster.piglin;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class PiglinBruteMeta extends BasePiglinMeta{
|
||||
|
||||
public static final byte OFFSET = BasePiglinMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public PiglinBruteMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster.piglin;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class PiglinMeta extends BasePiglinMeta{
|
||||
|
||||
public static final byte OFFSET = BasePiglinMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
public PiglinMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isBaby() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setBaby(boolean value) {
|
||||
if (isBaby() == value) {
|
||||
return;
|
||||
}
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public boolean isChargingCrossbow() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 1), false);
|
||||
}
|
||||
|
||||
public void setChargingCrossbow(boolean value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public boolean isDancing() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 2), false);
|
||||
}
|
||||
|
||||
public void setDancing(boolean value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster.raider;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class EvokerMeta extends SpellcasterIllagerMeta {
|
||||
|
||||
public static final byte OFFSET = SpellcasterIllagerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public EvokerMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster.raider;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class IllusionerMeta extends SpellcasterIllagerMeta {
|
||||
|
||||
public static final byte OFFSET = SpellcasterIllagerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public IllusionerMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster.raider;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class PillagerMeta extends RaiderMeta{
|
||||
|
||||
public static final byte OFFSET = RaiderMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
|
||||
public PillagerMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster.raider;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
public class RaiderMeta extends MobMeta {
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public RaiderMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isCelebrating() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setCelebrating(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster.raider;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class RavagerMeta extends RaiderMeta {
|
||||
|
||||
public static final byte OFFSET = RaiderMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
|
||||
public RavagerMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster.raider;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class SpellcasterIllagerMeta extends RaiderMeta{
|
||||
|
||||
public static final byte OFFSET = RaiderMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public SpellcasterIllagerMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster.raider;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class VindicatorMeta extends RaiderMeta{
|
||||
|
||||
public static final byte OFFSET = RaiderMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public VindicatorMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster.raider;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class WitchMeta extends RaiderMeta {
|
||||
|
||||
public static final byte OFFSET = RaiderMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public WitchMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isDrinkingPotion() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setDrinkingPotion(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster.skeleton;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
public class SkeletonMeta extends MobMeta {
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public SkeletonMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster.skeleton;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class StrayMeta extends SkeletonMeta{
|
||||
|
||||
|
||||
public StrayMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster.skeleton;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class WitherSkeletonMeta extends SkeletonMeta {
|
||||
public static final byte OFFSET = SkeletonMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public WitherSkeletonMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster.zombie;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class DrownedMeta extends ZombieMeta {
|
||||
|
||||
public static final byte OFFSET = ZombieMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
public DrownedMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster.zombie;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class HuskMeta extends ZombieMeta {
|
||||
|
||||
public static final byte OFFSET = ZombieMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public HuskMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster.zombie;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.MobMeta;
|
||||
|
||||
public class ZombieMeta extends MobMeta {
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
public ZombieMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isBaby() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setBaby(boolean value) {
|
||||
if (isBaby() == value) {
|
||||
return;
|
||||
}
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public boolean isBecomingDrowned() {
|
||||
return super.metadata.getIndex(offset(OFFSET, 2), false);
|
||||
}
|
||||
|
||||
public void setBecomingDrowned(boolean value) {
|
||||
super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster.zombie;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.protocol.entity.villager.VillagerData;
|
||||
import com.github.retrooper.packetevents.protocol.entity.villager.profession.VillagerProfessions;
|
||||
import com.github.retrooper.packetevents.protocol.entity.villager.type.VillagerTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.mobs.villager.VillagerMeta;
|
||||
|
||||
public class ZombieVillagerMeta extends ZombieMeta {
|
||||
|
||||
public static final byte OFFSET = ZombieMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
public ZombieVillagerMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isConverting() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setConverting(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public VillagerData getVillagerData() {
|
||||
int[] data = super.metadata.getIndex(offset(OFFSET, 1), null);
|
||||
if (data == null) {
|
||||
return new VillagerData(VillagerTypes.PLAINS, VillagerProfessions.NONE, VillagerMeta.Level.NOVICE.ordinal());
|
||||
}
|
||||
return new VillagerData(VillagerMeta.TYPES[data[0]], VillagerMeta.PROFESSIONS[data[1]], VillagerMeta.Level.VALUES[data[2] - 1].ordinal());
|
||||
}
|
||||
|
||||
public void setVillagerData(VillagerData data) {
|
||||
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.VILLAGER_DATA, new VillagerData(
|
||||
data.getType().getId(),
|
||||
data.getProfession().getId(),
|
||||
data.getLevel() + 1
|
||||
));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package me.tofaa.entitylib.meta.mobs.monster.zombie;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class ZombifiedPiglinMeta extends ZombieMeta {
|
||||
|
||||
public static final byte OFFSET = ZombieMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public ZombifiedPiglinMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package me.tofaa.entitylib.meta.mobs.passive;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
|
||||
public class ChickenMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public ChickenMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package me.tofaa.entitylib.meta.mobs.passive;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
|
||||
public class CowMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public CowMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package me.tofaa.entitylib.meta.mobs.passive;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class MooshroomMeta extends CowMeta{
|
||||
|
||||
public static final byte OFFSET = CowMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public MooshroomMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Variant getVariant() {
|
||||
return Variant.valueOf(super.metadata.getIndex(OFFSET, "red").toUpperCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
public void setVariant(@NotNull Variant value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.STRING, value.name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
public enum Variant {
|
||||
RED,
|
||||
BROWN
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package me.tofaa.entitylib.meta.mobs.passive;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
|
||||
public class PigMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
public PigMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean hasSaddle() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setHasSaddle(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public int getTimeToBoost() {
|
||||
isVersionNewer(ServerVersion.V_1_16);
|
||||
return super.metadata.getIndex(offset(OFFSET,1), 0);
|
||||
}
|
||||
|
||||
public void setTimeToBoost(int value) {
|
||||
isVersionNewer(ServerVersion.V_1_16);
|
||||
super.metadata.setIndex(offset(OFFSET,1), EntityDataTypes.INT, value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package me.tofaa.entitylib.meta.mobs.passive;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class RabbitMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
|
||||
public RabbitMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public @NotNull Type getType() {
|
||||
int id = super.metadata.getIndex(OFFSET, 0);
|
||||
if (id == 99) {
|
||||
return Type.KILLER_BUNNY;
|
||||
}
|
||||
return Type.VALUES[id];
|
||||
}
|
||||
|
||||
public void setType(@NotNull Type value) {
|
||||
int id = value == Type.KILLER_BUNNY ? 99 : value.ordinal();
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, id);
|
||||
}
|
||||
|
||||
|
||||
public enum Type {
|
||||
BROWN,
|
||||
WHITE,
|
||||
BLACK,
|
||||
BLACK_AND_WHITE,
|
||||
GOLD,
|
||||
SALT_AND_PEPPER,
|
||||
KILLER_BUNNY;
|
||||
|
||||
private final static Type[] VALUES = values();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package me.tofaa.entitylib.meta.mobs.passive;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
|
||||
public class SheepMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
|
||||
private final static byte COLOR_BITS = 0x0F;
|
||||
private final static byte SHEARED_BIT = 0x10;
|
||||
|
||||
public SheepMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return getMask(OFFSET) & COLOR_BITS;
|
||||
}
|
||||
|
||||
public void setColor(byte color) {
|
||||
byte before = getMask(OFFSET);
|
||||
byte mask = before;
|
||||
mask &= ~COLOR_BITS;
|
||||
mask |= (color & COLOR_BITS);
|
||||
if (mask != before) {
|
||||
setMask(OFFSET, mask);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSheared() {
|
||||
return getMaskBit(OFFSET, SHEARED_BIT);
|
||||
}
|
||||
|
||||
public void setSheared(boolean value) {
|
||||
setMaskBit(OFFSET, SHEARED_BIT, value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package me.tofaa.entitylib.meta.mobs.passive;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.util.Vector3i;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
|
||||
public class TurtleMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 6;
|
||||
|
||||
public TurtleMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
|
||||
public Vector3i getHomePosition() {
|
||||
return super.metadata.getIndex(OFFSET, Vector3i.zero());
|
||||
}
|
||||
|
||||
public void setBlockPosition(Vector3i value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.BLOCK_POSITION, value);
|
||||
}
|
||||
|
||||
public boolean hasEgg() {
|
||||
return super.metadata.getIndex(offset(OFFSET,1), false);
|
||||
}
|
||||
|
||||
public void setHasEgg(boolean value) {
|
||||
super.metadata.setIndex(offset(OFFSET,1), EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public boolean isLayingEgg() {
|
||||
return super.metadata.getIndex(offset(OFFSET,2), false);
|
||||
}
|
||||
|
||||
public void setLayingEgg(boolean value) {
|
||||
super.metadata.setIndex(offset(OFFSET,2), EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public Vector3i getTravelPosition() {
|
||||
return super.metadata.getIndex(offset(OFFSET,3), Vector3i.zero());
|
||||
}
|
||||
|
||||
public void setTravelPosition(Vector3i value) {
|
||||
super.metadata.setIndex(offset(OFFSET,3), EntityDataTypes.BLOCK_POSITION, value);
|
||||
}
|
||||
|
||||
public boolean isGoingHome() {
|
||||
return super.metadata.getIndex(offset(OFFSET,4), false);
|
||||
}
|
||||
|
||||
public void setGoingHome(boolean value) {
|
||||
super.metadata.setIndex(offset(OFFSET,4), EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public boolean isTravelling() {
|
||||
return super.metadata.getIndex(offset(OFFSET,5), false);
|
||||
}
|
||||
|
||||
public void setTravelling(boolean value) {
|
||||
super.metadata.setIndex(offset(OFFSET,4), EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue