Attributes
This commit is contained in:
parent
6e90d0d3e8
commit
dcdbe8575f
20 changed files with 302 additions and 74 deletions
|
@ -11,6 +11,7 @@
|
|||
<option value="$PROJECT_DIR$/api" />
|
||||
<option value="$PROJECT_DIR$/code-gen" />
|
||||
<option value="$PROJECT_DIR$/common" />
|
||||
<option value="$PROJECT_DIR$/model-engine-addon" />
|
||||
<option value="$PROJECT_DIR$/platforms" />
|
||||
<option value="$PROJECT_DIR$/platforms/spigot" />
|
||||
<option value="$PROJECT_DIR$/platforms/velocity" />
|
||||
|
|
|
@ -5,17 +5,23 @@
|
|||
</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/utils/GithubUpdater.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/storage/ByteEntitySerializer.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/storage/EntitySerializer.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/storage/EntityStorage.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/storage/FSEntityStorage.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/PerViewerEntity.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/model-engine-addon/build.gradle" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/model-engine-addon/src/main/java/me/tofaa/entitylib/modelengine/ELibBaseEntity.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/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.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$/api/src/main/java/me/tofaa/entitylib/APIConfig.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/APIConfig.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/build.gradle" 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/SpigotEntityLibPlatform.java" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibPlatform.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/platforms/velocity/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/velocity/build.gradle" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/platforms/velocity/src/main/java/me/tofaa/entitylib/velocity/VelocityEntityLibPlatform.java" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/velocity/src/main/java/me/tofaa/entitylib/velocity/VelocityEntityLibPlatform.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/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/meta/MetaOffsetConverter.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/MetaOffsetConverter.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/utils/GithubUpdater.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/utils/GithubUpdater.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntity.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntity.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/common/src/main/java/me/tofaa/entitylib/common/AbstractPlatform.java" beforeDir="false" afterPath="$PROJECT_DIR$/common/src/main/java/me/tofaa/entitylib/common/AbstractPlatform.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/settings.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/settings.gradle" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/testentitylib/TestEntityLibPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/testentitylib/TestEntityLibPlugin.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -84,46 +90,47 @@
|
|||
<option name="showExcludedFiles" value="false" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"Downloaded.Files.Path.Enabled": "false",
|
||||
"Gradle.Build EntityLib.executor": "Run",
|
||||
"Gradle.EntityLib [dependencies].executor": "Run",
|
||||
"Gradle.EntityLib [publish].executor": "Run",
|
||||
"Gradle.EntityLib:code-gen [:code-gen:Main.main()].executor": "Run",
|
||||
"Gradle.EntityLib:test-plugin [publish].executor": "Run",
|
||||
"Gradle.EntityLib:test-plugin [runServer].executor": "Run",
|
||||
"Gradle.EntityLib:test-plugin [shadowJar].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": "master",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"jdk.selected.JAVA_MODULE": "corretto-17",
|
||||
"kotlin-language-version-configured": "true",
|
||||
"last_opened_file_path": "//wsl.localhost/Ubuntu/home/tofaa/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": "Project",
|
||||
"project.structure.proportion": "0.15",
|
||||
"project.structure.side.proportion": "0.2",
|
||||
"settings.editor.selected.configurable": "preferences.editor",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"Downloaded.Files.Path.Enabled": "false",
|
||||
"Gradle.Build EntityLib.executor": "Run",
|
||||
"Gradle.EntityLib [dependencies].executor": "Run",
|
||||
"Gradle.EntityLib [publish].executor": "Run",
|
||||
"Gradle.EntityLib:code-gen [:code-gen:Main.main()].executor": "Run",
|
||||
"Gradle.EntityLib:test-plugin [publish].executor": "Run",
|
||||
"Gradle.EntityLib:test-plugin [runServer].executor": "Run",
|
||||
"Gradle.EntityLib:test-plugin [shadowJar].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": "master",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"jdk.selected.JAVA_MODULE": "corretto-17",
|
||||
"kotlin-language-version-configured": "true",
|
||||
"last_opened_file_path": "/home/tofaa/Github/EntityLib/model-engine-addon",
|
||||
"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.editor",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
},
|
||||
"keyToStringList": {
|
||||
"kotlin-gradle-user-dirs": [
|
||||
"/home/tofaa/.gradle"
|
||||
"keyToStringList": {
|
||||
"kotlin-gradle-user-dirs": [
|
||||
"/home/tofaa/.gradle"
|
||||
]
|
||||
}
|
||||
}]]></component>
|
||||
}</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="$PROJECT_DIR$/model-engine-addon" />
|
||||
<recent name="D:\Github\EntityLib\api\src\main\java\me\tofaa\entitylib\extras" />
|
||||
<recent name="D:\Github\EntityLib\api\src\main\java\me\tofaa\entitylib\meta" />
|
||||
<recent name="D:\Github\EntityLib\test-plugin" />
|
||||
|
@ -330,7 +337,12 @@
|
|||
<workItem from="1715627329632" duration="41000" />
|
||||
<workItem from="1715627440179" duration="1000" />
|
||||
<workItem from="1715634060575" duration="111000" />
|
||||
<workItem from="1715634183157" duration="1468000" />
|
||||
<workItem from="1715634183157" duration="2701000" />
|
||||
<workItem from="1715678868119" duration="29000" />
|
||||
<workItem from="1715759348557" duration="1699000" />
|
||||
<workItem from="1716022802329" duration="1089000" />
|
||||
<workItem from="1716206341414" duration="1609000" />
|
||||
<workItem from="1716212065238" duration="80000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
|
|
@ -18,11 +18,14 @@ public final class EntityLib {
|
|||
if (api.getSettings().shouldCheckForUpdate()) {
|
||||
try {
|
||||
if (api.getSettings().isDebugMode()) {
|
||||
platform.getLogger().log(Level.CONFIG, "Checking for updates...");
|
||||
platform.getLogger().log(Level.INFO, "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.");
|
||||
}
|
||||
else {
|
||||
platform.getLogger().log(Level.INFO, "No EntityLib updates found.");
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
platform.getLogger().log(Level.WARNING, e, () -> "EntityLib failed to check for updates.");
|
||||
|
@ -43,6 +46,6 @@ public final class EntityLib {
|
|||
}
|
||||
|
||||
public static String getVersion() {
|
||||
return "1.2.0-SNAPSHOT";
|
||||
return "2.1.2-SNAPSHOT";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,6 @@ public interface Platform<P> {
|
|||
|
||||
/**
|
||||
* Sets up the API for the platform. This method should be called automatically by the platform. Don't call it yourself.
|
||||
* @param settings
|
||||
*/
|
||||
void setupApi(@NotNull APIConfig settings);
|
||||
|
||||
|
@ -83,4 +82,10 @@ public interface Platform<P> {
|
|||
|
||||
@NotNull P getHandle();
|
||||
|
||||
default void logIfNeeded(String message) {
|
||||
if (getAPI().getSettings().isDebugMode()) {
|
||||
getLogger().info(message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,9 +9,7 @@ import org.jetbrains.annotations.ApiStatus;
|
|||
@ApiStatus.Internal
|
||||
@SuppressWarnings("unused")
|
||||
public final class MetaOffsetConverter {
|
||||
private MetaOffsetConverter() {
|
||||
|
||||
}
|
||||
private MetaOffsetConverter() {}
|
||||
|
||||
public static final class EntityMetaOffsets {
|
||||
public static byte airTicksOffset() {
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package me.tofaa.entitylib.storage;
|
||||
|
||||
import me.tofaa.entitylib.wrapper.WrapperEntity;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class ByteEntitySerializer implements EntitySerializer<ByteBuffer, ByteBuffer> {
|
||||
@Override
|
||||
public WrapperEntity read(ByteBuffer reader) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuffer writer, WrapperEntity wrapper) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package me.tofaa.entitylib.storage;
|
||||
|
||||
import me.tofaa.entitylib.wrapper.WrapperEntity;
|
||||
|
||||
/**
|
||||
* An interface that represents a way to serialize and deserialize {@link WrapperEntity} and its subclasses.
|
||||
* @param <R> the reader generic
|
||||
* @param <W> the writer generic
|
||||
*/
|
||||
public interface EntitySerializer<R, W> {
|
||||
|
||||
WrapperEntity read(R reader);
|
||||
|
||||
void write(W writer, WrapperEntity wrapper);
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package me.tofaa.entitylib.storage;
|
||||
|
||||
import me.tofaa.entitylib.wrapper.WrapperEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface EntityStorage {
|
||||
|
||||
|
||||
Collection<WrapperEntity> readAll();
|
||||
|
||||
void writeAll(Collection<WrapperEntity> entities);
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package me.tofaa.entitylib.storage;
|
||||
|
||||
import me.tofaa.entitylib.wrapper.WrapperEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class FSEntityStorage implements EntityStorage{
|
||||
@Override
|
||||
public Collection<WrapperEntity> readAll() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeAll(Collection<WrapperEntity> entities) {
|
||||
|
||||
}
|
||||
}
|
|
@ -23,15 +23,14 @@ public final class GithubUpdater {
|
|||
}
|
||||
|
||||
@Blocking
|
||||
public boolean isLatestVersion() {
|
||||
public boolean isLatestVersion() throws IOException {
|
||||
String latest = getLatestVersion();
|
||||
return latest != null && latest.equals(currentVersion);
|
||||
}
|
||||
|
||||
|
||||
@Blocking
|
||||
public String getLatestVersion() {
|
||||
try {
|
||||
public String getLatestVersion() throws IOException {
|
||||
URL url = new URL("https://api.github.com/repos/" + org + "/" + repo + "/releases/latest");
|
||||
URLConnection connection = url.openConnection();
|
||||
connection.addRequestProperty("User-Agent", "Mozilla/5.0");
|
||||
|
@ -45,10 +44,6 @@ public final class GithubUpdater {
|
|||
return json.get("name").getAsString();
|
||||
}
|
||||
throw new IOException("Could not find name attribute in github api fetch");
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getCurrentVersion() {
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package me.tofaa.entitylib.wrapper;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataType;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
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.User;
|
||||
import com.github.retrooper.packetevents.protocol.world.Location;
|
||||
|
@ -284,7 +280,7 @@ public class WrapperEntity implements Tickable, TrackedEntity {
|
|||
return entityMeta;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
public @NotNull UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
package me.tofaa.entitylib.wrapper;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.attribute.Attribute;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerUpdateAttributes;
|
||||
import org.w3c.dom.Attr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public final class WrapperEntityAttributes {
|
||||
|
||||
|
||||
public static final WrapperPlayServerUpdateAttributes.PropertyModifier.Operation ADDITION = WrapperPlayServerUpdateAttributes.PropertyModifier.Operation.ADDITION;
|
||||
public static final WrapperPlayServerUpdateAttributes.PropertyModifier.Operation MULTIPLY_BASE = WrapperPlayServerUpdateAttributes.PropertyModifier.Operation.MULTIPLY_BASE;
|
||||
public static final WrapperPlayServerUpdateAttributes.PropertyModifier.Operation MULTIPLY_TOTAL = WrapperPlayServerUpdateAttributes.PropertyModifier.Operation.MULTIPLY_TOTAL;
|
||||
|
||||
private final WrapperEntity entity;
|
||||
private final List<WrapperPlayServerUpdateAttributes.Property> properties;
|
||||
|
||||
public WrapperEntityAttributes(WrapperEntity entity) {
|
||||
this.entity = entity;
|
||||
this.properties = new CopyOnWriteArrayList<>();
|
||||
}
|
||||
|
||||
public void setAttribute(Attribute attribute, double value, List<WrapperPlayServerUpdateAttributes.PropertyModifier> modifiers) {
|
||||
this.properties.stream()
|
||||
.filter(property -> property.getAttribute() == attribute)
|
||||
.findFirst().ifPresent(properties::remove);
|
||||
this.properties.add(new WrapperPlayServerUpdateAttributes.Property(attribute, value, modifiers));
|
||||
refresh();
|
||||
}
|
||||
|
||||
public void setAttribute(Attribute attribute, double value, WrapperPlayServerUpdateAttributes.PropertyModifier modifier) {
|
||||
setAttribute(attribute, value, Collections.singletonList(modifier));
|
||||
}
|
||||
|
||||
public void setAttribute(Attribute attribute, double value) {
|
||||
setAttribute(attribute, value, Collections.emptyList());
|
||||
}
|
||||
|
||||
public List<WrapperPlayServerUpdateAttributes.Property> getProperties() {
|
||||
return new ArrayList<>(properties);
|
||||
}
|
||||
|
||||
public void forEach(Consumer<WrapperPlayServerUpdateAttributes.Property> action) {
|
||||
properties.forEach(action);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
properties.clear();
|
||||
refresh();
|
||||
}
|
||||
|
||||
public void removeAttribute(Attribute attribute, WrapperPlayServerUpdateAttributes.PropertyModifier modifier) {
|
||||
this.properties.stream()
|
||||
.filter(property -> property.getAttribute() == attribute)
|
||||
.findFirst().ifPresent(property -> {
|
||||
property.getModifiers().remove(modifier);
|
||||
if (property.getModifiers().isEmpty()) {
|
||||
properties.remove(property);
|
||||
}
|
||||
});
|
||||
refresh();
|
||||
}
|
||||
|
||||
public void removeAttribute(Attribute attribute) {
|
||||
this.properties.stream()
|
||||
.filter(property -> property.getAttribute() == attribute)
|
||||
.findFirst().ifPresent(properties::remove);
|
||||
refresh();
|
||||
}
|
||||
|
||||
|
||||
public void refresh() {
|
||||
entity.sendPacketToViewers(createPacket());
|
||||
}
|
||||
|
||||
public WrapperPlayServerUpdateAttributes createPacket() {
|
||||
return new WrapperPlayServerUpdateAttributes(entity.getEntityId(), properties);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package me.tofaa.entitylib.wrapper;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.attribute.Attribute;
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.player.HumanoidArm;
|
||||
|
@ -7,20 +8,23 @@ import com.github.retrooper.packetevents.protocol.potion.PotionType;
|
|||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityAnimation;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityEffect;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerTeams;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerUpdateAttributes;
|
||||
import me.tofaa.entitylib.meta.EntityMeta;
|
||||
import me.tofaa.entitylib.meta.types.LivingEntityMeta;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class WrapperLivingEntity extends WrapperEntity{
|
||||
|
||||
private final WrapperEntityEquipment equipment;
|
||||
|
||||
private final WrapperEntityAttributes attributes;
|
||||
|
||||
public WrapperLivingEntity(int entityId, UUID uuid, EntityType entityType, EntityMeta entityMeta) {
|
||||
super(entityId, uuid, entityType, entityMeta);
|
||||
this.equipment = new WrapperEntityEquipment(this);
|
||||
this.attributes = new WrapperEntityAttributes(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,6 +33,12 @@ public class WrapperLivingEntity extends WrapperEntity{
|
|||
equipment.refresh();
|
||||
}
|
||||
|
||||
public WrapperEntityAttributes getAttributes() {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds a potion effect to the entity.
|
||||
* EntityLib will not keep track of the potions you give or what you do with them,
|
||||
|
|
|
@ -79,4 +79,5 @@ public abstract class AbstractPlatform<P> implements Platform<P> {
|
|||
public P getHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
8
model-engine-addon/build.gradle
Normal file
8
model-engine-addon/build.gradle
Normal file
|
@ -0,0 +1,8 @@
|
|||
repositories {
|
||||
maven { url 'https://mvn.lumine.io/repository/maven-public/' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// compileOnly 'com.ticxo.modelengine:ModelEngine:R4.0.4'
|
||||
api(project(":api"))
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package me.tofaa.entitylib.modelengine;
|
||||
|
||||
public class ELibBaseEntity {
|
||||
|
||||
}
|
|
@ -11,6 +11,7 @@ include 'common'
|
|||
if (!Boolean.parseBoolean(System.getenv("JITPACK"))) {
|
||||
include 'code-gen'
|
||||
include 'test-plugin'
|
||||
include 'model-engine-addon'
|
||||
}
|
||||
include 'platforms:velocity'
|
||||
findProject(':platforms:velocity')?.name = 'velocity'
|
||||
|
|
|
@ -32,15 +32,14 @@ repositories {
|
|||
|
||||
dependencies {
|
||||
compileOnly('org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT')
|
||||
compileOnly('com.github.retrooper.packetevents:spigot:2.0.2')
|
||||
compileOnly('com.github.retrooper.packetevents:spigot:2.3.0')
|
||||
implementation(project(":platforms:spigot"))
|
||||
}
|
||||
|
||||
tasks {
|
||||
runServer {
|
||||
minecraftVersion("1.20.4")
|
||||
downloadPlugins {
|
||||
modrinth("packetevents", "2.2.1")
|
||||
}
|
||||
|
||||
runServer {
|
||||
minecraftVersion("1.20.4")
|
||||
downloadPlugins {
|
||||
modrinth("packetevents", "6Rjr7zyF")
|
||||
}
|
||||
}
|
|
@ -24,8 +24,6 @@ import java.util.UUID;
|
|||
|
||||
public class TestEntityLibPlugin extends JavaPlugin {
|
||||
|
||||
private SpigotEntityLibAPI api;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
|
@ -34,10 +32,10 @@ public class TestEntityLibPlugin extends JavaPlugin {
|
|||
.debugMode()
|
||||
.tickTickables()
|
||||
.trackPlatformEntities()
|
||||
.useBstats()
|
||||
.usePlatformLogger();
|
||||
|
||||
EntityLib.init(platform, settings);
|
||||
api = platform.getAPI();
|
||||
|
||||
CommandMap commandMap;
|
||||
try {
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package me.tofaa.testentitylib;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.attribute.Attributes;
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerUpdateAttributes;
|
||||
import me.tofaa.entitylib.EntityLib;
|
||||
import me.tofaa.entitylib.wrapper.WrapperLivingEntity;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.defaults.BukkitCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class TestMassivePigCommand extends BukkitCommand {
|
||||
|
||||
private WrapperLivingEntity pig;
|
||||
|
||||
public TestMassivePigCommand() {
|
||||
super("testmassivepig");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) {
|
||||
if (!(commandSender instanceof Player)) return false;
|
||||
Player player = (Player) commandSender;
|
||||
if (pig != null) {
|
||||
pig.remove();
|
||||
pig = null;
|
||||
player.sendMessage("Large pig removed");
|
||||
return true;
|
||||
}
|
||||
pig = EntityLib.getApi().createEntity(EntityTypes.PIG);
|
||||
pig.getAttributes().setAttribute(
|
||||
Attributes.GENERIC_SCALE,
|
||||
10,
|
||||
new WrapperPlayServerUpdateAttributes.PropertyModifier(
|
||||
UUID.randomUUID(),
|
||||
10,
|
||||
WrapperPlayServerUpdateAttributes.PropertyModifier.Operation.MULTIPLY_BASE
|
||||
)
|
||||
);
|
||||
player.sendMessage("Large pig spawned");
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue