fix broken protocol values
This commit is contained in:
parent
6c56f28a7c
commit
ae21d85740
13 changed files with 241 additions and 27 deletions
|
@ -5,19 +5,17 @@
|
|||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="9d5d9b6f-43c8-41a4-bb42-a66ffc96c9b0" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/code-gen/src/main/java/me/tofaa/entitylib/codegen/MetaOffset.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/code-gen/src/main/java/me/tofaa/entitylib/codegen/TypeHolder.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/code-gen/src/main/resources/offset-calculator.json" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/extras/Color.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/extras/DyeColor.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/extras/Rotation.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/EntityUuidProvider.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/EntityUuidProvider.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/CompatibilityIndex.java" beforeDir="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$/code-gen/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/code-gen/build.gradle" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/code-gen/src/main/java/me/tofaa/entitylib/codegen/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/code-gen/src/main/java/me/tofaa/entitylib/codegen/Main.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/code-gen/src/main/java/me/tofaa/entitylib/codegen/MetaClass.java" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/code-gen/src/main/java/me/tofaa/entitylib/codegen/MetaMethod.java" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/code-gen/src/main/java/me/tofaa/entitylib/codegen/MetadataClass.java" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/code-gen/src/main/resources/EntityMeta.json" beforeDir="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$/api/src/main/java/me/tofaa/entitylib/meta/mobs/tameable/CatMeta.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/mobs/tameable/CatMeta.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntityCreature.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntityCreature.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/ai/AIGroup.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/ai/AIGroup.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/common/src/main/java/me/tofaa/entitylib/common/AbstractWorldWrapper.java" beforeDir="false" afterPath="$PROJECT_DIR$/common/src/main/java/me/tofaa/entitylib/common/AbstractWorldWrapper.java" 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/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" />
|
||||
|
@ -48,6 +46,24 @@
|
|||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
||||
<item name="EntityLib" type="f1a62948:ProjectNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
||||
<item name="EntityLib" type="f1a62948:ProjectNode" />
|
||||
<item name="test-plugin" type="2d1252cf:ModuleNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
||||
<item name="EntityLib" type="f1a62948:ProjectNode" />
|
||||
<item name="test-plugin" type="2d1252cf:ModuleNode" />
|
||||
<item name="Tasks" type="e4a08cd1:TasksNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
|
||||
<item name="EntityLib" type="f1a62948:ProjectNode" />
|
||||
<item name="test-plugin" type="2d1252cf:ModuleNode" />
|
||||
<item name="Tasks" type="e4a08cd1:TasksNode" />
|
||||
<item name="run paper" type="c8890929:TasksNode$1" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</tree_state>
|
||||
|
@ -97,7 +113,7 @@
|
|||
"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",
|
||||
"last_opened_file_path": "D:/Github/EntityLib/api/src/main/java/me/tofaa/entitylib/extras",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
|
@ -112,11 +128,12 @@
|
|||
}</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<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" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunManager" selected="Application.Main">
|
||||
<component name="RunManager" selected="Gradle.EntityLib:test-plugin [runServer]">
|
||||
<configuration name="Main" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
|
||||
<option name="MAIN_CLASS_NAME" value="me.tofaa.entitylib.codegen.Main" />
|
||||
<module name="EntityLib.code-gen.main" />
|
||||
|
@ -220,9 +237,9 @@
|
|||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Gradle.EntityLib:test-plugin [runServer]" />
|
||||
<item itemvalue="Application.Main" />
|
||||
<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]" />
|
||||
</list>
|
||||
|
@ -280,7 +297,8 @@
|
|||
<workItem from="1706601592145" duration="1670000" />
|
||||
<workItem from="1706614921404" duration="10508000" />
|
||||
<workItem from="1706696719616" duration="4783000" />
|
||||
<workItem from="1706784821835" duration="5673000" />
|
||||
<workItem from="1706784821835" duration="7882000" />
|
||||
<workItem from="1706858181164" duration="925000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
|
|
@ -3,6 +3,7 @@ package me.tofaa.entitylib;
|
|||
import com.github.retrooper.packetevents.PacketEventsAPI;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.jetbrains.annotations.Blocking;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -24,6 +25,7 @@ public final class APIConfig {
|
|||
this.packetEvents = packetEvents;
|
||||
}
|
||||
|
||||
@Blocking
|
||||
public boolean requiresUpdate() throws IOException {
|
||||
if (!checkForUpdates) return false;
|
||||
String urlString = "https://api.github.com/repos/Tofaa2/EntityLib/releases/latest";
|
||||
|
|
|
@ -6,6 +6,11 @@ import org.jetbrains.annotations.NotNull;
|
|||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* Represents a int provider that gives an id for each entity created. When using EntityLib with platform specific entities (Such as bukkit entities), make sure the id's do not
|
||||
* conflict with the platform's entity id's.
|
||||
* {@link DefaultEntityIdProvider} is a default implementation of this interface.
|
||||
*/
|
||||
public interface EntityIdProvider {
|
||||
|
||||
int provide(@NotNull UUID entityUUID, @NotNull EntityType entityType);
|
||||
|
|
55
api/src/main/java/me/tofaa/entitylib/extras/Color.java
Normal file
55
api/src/main/java/me/tofaa/entitylib/extras/Color.java
Normal file
|
@ -0,0 +1,55 @@
|
|||
package me.tofaa.entitylib.extras;
|
||||
|
||||
import net.kyori.adventure.util.RGBLike;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Range;
|
||||
|
||||
public final class Color implements RGBLike {
|
||||
|
||||
private static final int BIT_MASK = 0xFF;
|
||||
|
||||
private final int red, green, blue;
|
||||
|
||||
public Color(@Range(from = 0L, to = 255L) int red, @Range(from = 0L, to = 255L) int green, @Range(from = 0L, to = 255L) int blue) {
|
||||
this.red = red;
|
||||
this.green = green;
|
||||
this.blue = blue;
|
||||
}
|
||||
|
||||
public Color(int rgb) {
|
||||
this((rgb >> 16) & BIT_MASK, (rgb >> 8) & BIT_MASK, rgb & BIT_MASK);
|
||||
}
|
||||
|
||||
public @NotNull Color withRed(@Range(from = 0L, to = 255L) int red) {
|
||||
return new Color(red, green, blue);
|
||||
}
|
||||
|
||||
public @NotNull Color withGreen(@Range(from = 0L, to = 255L) int green) {
|
||||
return new Color(red, green, blue);
|
||||
}
|
||||
|
||||
public @NotNull Color withBlue(@Range(from = 0L, to = 255L) int blue) {
|
||||
return new Color(red, green, blue);
|
||||
}
|
||||
|
||||
public int asRGB() {
|
||||
int rgb = red;
|
||||
rgb = (rgb << 8) + green;
|
||||
return (rgb << 8) + blue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Range(from = 0L, to = 255L) int red() {
|
||||
return red;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Range(from = 0L, to = 255L) int green() {
|
||||
return green;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Range(from = 0L, to = 255L) int blue() {
|
||||
return blue;
|
||||
}
|
||||
}
|
85
api/src/main/java/me/tofaa/entitylib/extras/DyeColor.java
Normal file
85
api/src/main/java/me/tofaa/entitylib/extras/DyeColor.java
Normal file
|
@ -0,0 +1,85 @@
|
|||
package me.tofaa.entitylib.extras;
|
||||
|
||||
import net.kyori.adventure.util.RGBLike;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public enum DyeColor implements RGBLike {
|
||||
WHITE(new Color(0xf9fffe), new Color(0xffffff), new Color(0xf0f0f0), 8),
|
||||
|
||||
ORANGE(new Color(0xf9801d), new Color(0xff681f), new Color(0xeb8844), 15),
|
||||
|
||||
MAGENTA(new Color(0xc74ebd), new Color(0xff00ff), new Color(0xc354cd), 16),
|
||||
|
||||
LIGHT_BLUE(new Color(0x3ab3da), new Color(0x9ac0cd), new Color(0x6689d3), 17),
|
||||
|
||||
YELLOW(new Color(0xfed83d), new Color(0xffff00), new Color(0xdecf2a), 18),
|
||||
|
||||
LIME(new Color(0x80c71f), new Color(0xbfff00), new Color(0x41cd34), 19),
|
||||
|
||||
PINK(new Color(0xf38baa), new Color(0xff69b4), new Color(0xd88198), 20),
|
||||
|
||||
GRAY(new Color(0x474f52), new Color(0x808080), new Color(0x434343), 21),
|
||||
|
||||
LIGHT_GRAY(new Color(0x9d9d97), new Color(0xd3d3d3), new Color(0xababab), 22),
|
||||
|
||||
CYAN(new Color(0x169c9c), new Color(0xffff), new Color(0x287697), 23),
|
||||
|
||||
PURPLE(new Color(0x8932b8), new Color(0xa020f0), new Color(0x7b2fbe), 24),
|
||||
|
||||
BLUE(new Color(0x3c44aa), new Color(0xff), new Color(0x253192), 25),
|
||||
|
||||
BROWN(new Color(0x835432), new Color(0x8b4513), new Color(0x51301a), 26),
|
||||
|
||||
GREEN(new Color(0x5e7c16), new Color(0xff00), new Color(0x3b511a), 27),
|
||||
|
||||
RED(new Color(0xb02e26), new Color(0xff0000), new Color(0xb3312c), 28),
|
||||
|
||||
BLACK(new Color(0x1d1d21), new Color(0x0), new Color(0x1e1b1b), 29);
|
||||
|
||||
private final Color textureDiffuseColor;
|
||||
|
||||
private final Color textColor;
|
||||
|
||||
private final Color fireworkColor;
|
||||
|
||||
private final int mapColorId;
|
||||
|
||||
DyeColor(@NotNull Color textureDiffuseColor, @NotNull Color textColor,
|
||||
@NotNull Color fireworkColor, int mapColorId) {
|
||||
this.textureDiffuseColor = textureDiffuseColor;
|
||||
this.textColor = textColor;
|
||||
this.fireworkColor = fireworkColor;
|
||||
this.mapColorId = mapColorId;
|
||||
}
|
||||
|
||||
public @NotNull Color color() {
|
||||
return this.textureDiffuseColor;
|
||||
}
|
||||
|
||||
public @NotNull Color textColor() {
|
||||
return this.textColor;
|
||||
}
|
||||
|
||||
public @NotNull Color fireworkColor() {
|
||||
return this.fireworkColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int red() {
|
||||
return this.textureDiffuseColor.red();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int green() {
|
||||
return this.textureDiffuseColor.green();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int blue() {
|
||||
return this.textureDiffuseColor.blue();
|
||||
}
|
||||
|
||||
public int mapColorId() {
|
||||
return this.mapColorId;
|
||||
}
|
||||
}
|
38
api/src/main/java/me/tofaa/entitylib/extras/Rotation.java
Normal file
38
api/src/main/java/me/tofaa/entitylib/extras/Rotation.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package me.tofaa.entitylib.extras;
|
||||
|
||||
public enum Rotation {
|
||||
|
||||
/**
|
||||
* No rotation
|
||||
*/
|
||||
NONE,
|
||||
/**
|
||||
* Rotated clockwise by 45 degrees
|
||||
*/
|
||||
CLOCKWISE_45,
|
||||
/**
|
||||
* Rotated clockwise by 90 degrees
|
||||
*/
|
||||
CLOCKWISE,
|
||||
/**
|
||||
* Rotated clockwise by 135 degrees
|
||||
*/
|
||||
CLOCKWISE_135,
|
||||
/**
|
||||
* Flipped upside-down, a 180-degree rotation
|
||||
*/
|
||||
FLIPPED,
|
||||
/**
|
||||
* Flipped upside-down + 45-degree rotation
|
||||
*/
|
||||
FLIPPED_45,
|
||||
/**
|
||||
* Rotated counter-clockwise by 90 degrees
|
||||
*/
|
||||
COUNTER_CLOCKWISE,
|
||||
/**
|
||||
* Rotated counter-clockwise by 45 degrees
|
||||
*/
|
||||
COUNTER_CLOCKWISE_45;
|
||||
|
||||
}
|
|
@ -1,11 +1,10 @@
|
|||
package me.tofaa.entitylib.meta.mobs.tameable;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
|
||||
import me.tofaa.entitylib.extras.DyeColor;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.TameableMeta;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CatMeta extends TameableMeta {
|
||||
|
|
|
@ -9,11 +9,11 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Represents a storage/container for {@link Tickable}s.
|
||||
* Represents a storage/container for {@link Tickable}s. This class is extendable in case you want to provide custom logic and/or methods.
|
||||
* @param <T> The type of {@link Tickable} to store.
|
||||
* @param <H> If a platform enforces a specific method of ticking, this type represents the handler for that method.
|
||||
*/
|
||||
public abstract class TickContainer<T extends Tickable, H> {
|
||||
public class TickContainer<T extends Tickable, H> {
|
||||
|
||||
private final Set<T> tickables = new HashSet<>();
|
||||
private H handle;
|
||||
|
|
|
@ -32,7 +32,7 @@ public class WrapperEntityCreature extends WrapperLivingEntity {
|
|||
@Override
|
||||
public void tick(long time) {
|
||||
super.tick(time);
|
||||
aiGroups.forEach(aiGroup -> aiGroup.update(time));
|
||||
aiGroups.forEach(aiGroup -> aiGroup.tick(time));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,6 +11,7 @@ public class AIGroup implements Tickable {
|
|||
|
||||
private final List<GoalSelector> goalSelectors = new GoalSelectorList(this);
|
||||
private GoalSelector currentGoalSelector;
|
||||
private boolean ticking = true;
|
||||
|
||||
public @NotNull Collection<GoalSelector> getGoalSelectors() {
|
||||
return goalSelectors;
|
||||
|
@ -36,6 +37,16 @@ public class AIGroup implements Tickable {
|
|||
currentGoalSelector = goalSelector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTicking() {
|
||||
return ticking;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTicking(boolean ticking) {
|
||||
this.ticking = ticking;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(long time) {
|
||||
GoalSelector currentGoalSelector = getCurrentGoal();
|
||||
|
|
|
@ -31,7 +31,7 @@ public abstract class AbstractWorldWrapper<W> implements WorldWrapper<W> {
|
|||
this.handle = handle;
|
||||
this.dimension = dimension;
|
||||
this.entities = new ConcurrentHashMap<>();
|
||||
this.entitiesById = Collections.emptyMap();
|
||||
this.entitiesById = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,6 +32,6 @@ dependencies {
|
|||
|
||||
tasks {
|
||||
runServer {
|
||||
minecraftVersion("1.19.4")
|
||||
minecraftVersion("1.20.4")
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package me.tofaa.testentitylib;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
|
||||
import io.github.retrooper.packetevents.util.SpigotConversionUtil;
|
||||
import me.tofaa.entitylib.APIConfig;
|
||||
|
@ -43,15 +42,17 @@ public class TestEntityLibPlugin extends JavaPlugin implements Listener {
|
|||
@EventHandler
|
||||
public void onCrouch(PlayerToggleSneakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (e != null) {
|
||||
e.remove();
|
||||
e = null;
|
||||
if (e == null) {
|
||||
world = api.wrapWorld(player.getWorld());
|
||||
e = world.spawnEntity(EntityTypes.CHICKEN, SpigotConversionUtil.fromBukkitLocation(player.getLocation()));
|
||||
}
|
||||
world = api.wrapWorld(player.getWorld());
|
||||
e = world.spawnEntity(EntityTypes.CHICKEN, SpigotConversionUtil.fromBukkitLocation(player.getLocation()));
|
||||
ChickenMeta meta = (ChickenMeta) e.getEntityMeta();
|
||||
meta.setBaby(!meta.isBaby());
|
||||
meta.setHasGlowingEffect(!meta.hasGlowingEffect());
|
||||
|
||||
e.addViewer(player.getUniqueId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue