本文整理汇总了Java中cn.nukkit.entity.data.IntEntityData类的典型用法代码示例。如果您正苦于以下问题:Java IntEntityData类的具体用法?Java IntEntityData怎么用?Java IntEntityData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IntEntityData类属于cn.nukkit.entity.data包,在下文中一共展示了IntEntityData类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setDisplayBlock
import cn.nukkit.entity.data.IntEntityData; //导入依赖的package包/类
/**
* Set the minecart display block!
*
* @param block The block that will changed. Set {@code null} for BlockAir
* @return {@code true} if the block is normal block
*/
@API(usage = Usage.MAINTAINED, definition = Definition.UNIVERSAL)
public boolean setDisplayBlock(Block block) {
if (block != null) {
if (block.isNormalBlock()) {
blockInside = block;
int display = blockInside.getId()
| blockInside.getDamage() << 16;
setDataProperty(new ByteEntityData(DATA_MINECART_HAS_DISPLAY, 1));
setDataProperty(new IntEntityData(DATA_MINECART_DISPLAY_BLOCK, display));
setDisplayBlockOffset(6);
}
} else {
// Set block to air (default).
blockInside = null;
setDataProperty(new ByteEntityData(DATA_MINECART_HAS_DISPLAY, 0));
setDataProperty(new IntEntityData(DATA_MINECART_DISPLAY_BLOCK, 0));
setDisplayBlockOffset(0);
}
return true;
}
示例2: initEntity
import cn.nukkit.entity.data.IntEntityData; //导入依赖的package包/类
@Override
protected void initEntity() {
super.initEntity();
if (namedTag != null) {
if (namedTag.contains("TileID")) {
blockId = namedTag.getInt("TileID");
} else if (namedTag.contains("Tile")) {
blockId = namedTag.getInt("Tile");
namedTag.putInt("TileID", blockId);
}
if (namedTag.contains("Data")) {
damage = namedTag.getByte("Data");
}
}
if (blockId == 0) {
close();
return;
}
setDataProperty(new IntEntityData(DATA_VARIANT, this.getBlock() | this.getDamage() << 8));
}
示例3: setDisplayBlock
import cn.nukkit.entity.data.IntEntityData; //导入依赖的package包/类
/**
* Set the minecart display block!
*
* @param block The block that will changed. Set {@code null} for BlockAir
* @return {@code true} if the block is normal block
*/
public boolean setDisplayBlock(Block block) {
if (block != null) {
if (block.isNormalBlock()) {
blockInside = block;
int display = blockInside.getId()
| blockInside.getDamage() << 16;
setDataProperty(new ByteEntityData(DATA_MINECART_HAS_DISPLAY, 1));
setDataProperty(new IntEntityData(DATA_MINECART_DISPLAY_BLOCK, display));
setDisplayBlockOffset(6);
}
} else {
// Set block to air (default).
blockInside = null;
setDataProperty(new ByteEntityData(DATA_MINECART_HAS_DISPLAY, 0));
setDataProperty(new IntEntityData(DATA_MINECART_DISPLAY_BLOCK, 0));
setDisplayBlockOffset(0);
}
return true;
}
示例4: initEntity
import cn.nukkit.entity.data.IntEntityData; //导入依赖的package包/类
@Override
protected void initEntity() {
super.initEntity();
if (namedTag != null) {
if (namedTag.contains("TileID")) {
blockId = namedTag.getInt("TileID");
} else if (namedTag.contains("Tile")) {
blockId = namedTag.getInt("Tile");
namedTag.putInt("TileID", blockId);
}
if (namedTag.contains("Data")) {
damage = namedTag.getByte("Data");
}
}
if (blockId == 0) {
close();
return;
}
setDataProperty(new IntEntityData(DATA_BLOCK_INFO, this.getBlock() | this.getDamage() << 8));
}
示例5: initEntity
import cn.nukkit.entity.data.IntEntityData; //导入依赖的package包/类
protected void initEntity() {
super.initEntity();
if (namedTag.contains("Fuse")) {
fuse = namedTag.getByte("Fuse");
} else {
fuse = 80;
}
this.setDataFlag(DATA_FLAGS, DATA_FLAG_IGNITED, true);
this.setDataProperty(new IntEntityData(DATA_FUSE_LENGTH, fuse));
this.level.addSound(new TNTPrimeSound(this));
}
示例6: initEntity
import cn.nukkit.entity.data.IntEntityData; //导入依赖的package包/类
protected void initEntity() {
super.initEntity();
if (namedTag.contains("Fuse")) {
fuse = namedTag.getByte("Fuse");
} else {
fuse = 80;
}
this.setDataFlag(DATA_FLAGS, DATA_FLAG_IGNITED, true);
this.setDataProperty(new IntEntityData(DATA_FUSE_LENGTH, fuse));
}
示例7: recalculateEffectColor
import cn.nukkit.entity.data.IntEntityData; //导入依赖的package包/类
protected void recalculateEffectColor() {
int[] color = new int[3];
int count = 0;
boolean ambient = true;
for (Effect effect : this.effects.values()) {
if (effect.isVisible()) {
int[] c = effect.getColor();
color[0] += c[0] * (effect.getAmplifier() + 1);
color[1] += c[1] * (effect.getAmplifier() + 1);
color[2] += c[2] * (effect.getAmplifier() + 1);
count += effect.getAmplifier() + 1;
if (!effect.isAmbient()) {
ambient = false;
}
}
}
if (count > 0) {
int r = (color[0] / count) & 0xff;
int g = (color[1] / count) & 0xff;
int b = (color[2] / count) & 0xff;
this.setDataProperty(new IntEntityData(Entity.DATA_POTION_COLOR, (r << 16) + (g << 8) + b));
this.setDataProperty(new ByteEntityData(Entity.DATA_POTION_AMBIENT, ambient ? 1 : 0));
} else {
this.setDataProperty(new IntEntityData(Entity.DATA_POTION_COLOR, 0));
this.setDataProperty(new ByteEntityData(Entity.DATA_POTION_AMBIENT, 0));
}
}
示例8: initEntity
import cn.nukkit.entity.data.IntEntityData; //导入依赖的package包/类
protected void initEntity() {
super.initEntity();
if (namedTag.contains("Fuse")) {
fuse = namedTag.getByte("Fuse");
} else {
fuse = 80;
}
this.setDataFlag(DATA_FLAGS, DATA_FLAG_IGNITED, true);
this.setDataProperty(new IntEntityData(DATA_FUSE_LENGTH, fuse));
}
示例9: setRollingAmplitude
import cn.nukkit.entity.data.IntEntityData; //导入依赖的package包/类
public void setRollingAmplitude(int time) {
this.setDataProperty(new IntEntityData(DATA_HURT_TIME, time));
}
示例10: setRollingDirection
import cn.nukkit.entity.data.IntEntityData; //导入依赖的package包/类
public void setRollingDirection(int direction) {
this.setDataProperty(new IntEntityData(DATA_HURT_DIRECTION, direction));
}
示例11: setDamage
import cn.nukkit.entity.data.IntEntityData; //导入依赖的package包/类
public void setDamage(int damage) {
this.setDataProperty(new IntEntityData(DATA_HEALTH, damage));
}
示例12: writeMetadata
import cn.nukkit.entity.data.IntEntityData; //导入依赖的package包/类
public static byte[] writeMetadata(EntityMetadata metadata) {
BinaryStream stream = new BinaryStream();
Map<Integer, EntityData> map = metadata.getMap();
stream.putUnsignedVarInt(map.size());
for (int id : map.keySet()) {
EntityData d = map.get(id);
stream.putUnsignedVarInt(id);
stream.putUnsignedVarInt(d.getType());
switch (d.getType()) {
case Entity.DATA_TYPE_BYTE:
stream.putByte(((ByteEntityData) d).getData().byteValue());
break;
case Entity.DATA_TYPE_SHORT:
stream.putLShort(((ShortEntityData) d).getData());
break;
case Entity.DATA_TYPE_INT:
stream.putVarInt(((IntEntityData) d).getData());
break;
case Entity.DATA_TYPE_FLOAT:
stream.putLFloat(((FloatEntityData) d).getData());
break;
case Entity.DATA_TYPE_STRING:
String s = ((StringEntityData) d).getData();
stream.putUnsignedVarInt(s.getBytes(StandardCharsets.UTF_8).length);
stream.put(s.getBytes(StandardCharsets.UTF_8));
break;
case Entity.DATA_TYPE_SLOT:
SlotEntityData slot = (SlotEntityData) d;
stream.putLShort(slot.blockId);
stream.putByte((byte) slot.meta);
stream.putLShort(slot.count);
break;
case Entity.DATA_TYPE_POS:
IntPositionEntityData pos = (IntPositionEntityData) d;
stream.putVarInt(pos.x);
stream.putByte((byte) pos.y);
stream.putVarInt(pos.z);
break;
case Entity.DATA_TYPE_LONG:
stream.putVarLong(((LongEntityData) d).getData());
break;
case Entity.DATA_TYPE_VECTOR3F:
Vector3fEntityData v3data = (Vector3fEntityData) d;
stream.putLFloat(v3data.x);
stream.putLFloat(v3data.y);
stream.putLFloat(v3data.z);
break;
}
}
return stream.getBuffer();
}
示例13: setHurtTime
import cn.nukkit.entity.data.IntEntityData; //导入依赖的package包/类
public void setHurtTime(int time) {
this.setDataProperty(new IntEntityData(EntityVehicle.DATA_HURT_TIME, time));
}
示例14: setHurtDirection
import cn.nukkit.entity.data.IntEntityData; //导入依赖的package包/类
public void setHurtDirection(int direction) {
this.setDataProperty(new IntEntityData(EntityVehicle.DATA_HURT_DIRECTION, direction));
}