feat(meta): add TntMeta class and register in MetaConverterRegistry

This commit is contained in:
Felipe Paschoal Bergamo 2025-07-20 02:53:31 -03:00
parent a4ce05886d
commit 7ea339a69e
2 changed files with 32 additions and 0 deletions

View file

@ -148,6 +148,7 @@ final class MetaConverterRegistry {
put(TEXT_DISPLAY, TextDisplayMeta.class, TextDisplayMeta::new);
put(THROWN_EXP_BOTTLE, ThrownExpBottleMeta.class, ThrownExpBottleMeta::new);
put(ENDER_PEARL, ThrownEnderPearlMeta.class, ThrownEnderPearlMeta::new);
put(TNT, TntMeta.class, TntMeta::new);
put(TNT_MINECART, TntMinecartMeta.class, TntMinecartMeta::new);
put(TRADER_LLAMA, TraderLlamaMeta.class, TraderLlamaMeta::new);
put(TRIDENT, ThrownTridentMeta.class, ThrownTridentMeta::new);

View file

@ -0,0 +1,31 @@
package me.tofaa.entitylib.meta.other;
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes;
import me.tofaa.entitylib.meta.EntityMeta;
import me.tofaa.entitylib.meta.Metadata;
public class TntMeta extends EntityMeta {
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
public static final byte MAX_OFFSET = OFFSET + 2;
public TntMeta(int entityId, Metadata metadata) {
super(entityId, metadata);
}
public int getFuseTime() {
return super.metadata.getIndex(OFFSET, 80);
}
public void setFuseTime(int value) {
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value);
}
public int getBlockData() {
return super.metadata.getIndex(offset(OFFSET, 1), StateTypes.TNT.createBlockState().getGlobalId());
}
public void setBlockData(int blockData) {
super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BLOCK_STATE, blockData);
}
}