Search in sources :

Example 1 with Living

use of net.minecraft.entity.Living in project StationAPI by ModificationStation.

the class ModdedPickaxe method useOnTile.

@Override
public boolean useOnTile(ItemInstance item, PlayerBase player, Level level, int x, int y, int z, int facing) {
    if (facing == Direction.UP.ordinal()) {
        if (!level.isClient) {
            Living entity = (Living) EntityRegistry.create("GPoor", level);
            entity.setPosition(x + 0.5, y + 1, z + 0.5);
            level.spawnEntity(entity);
            entity.onSpawnedFromSpawner();
        }
        item.cooldown = 20;
        return true;
    } else
        return false;
}
Also used : Living(net.minecraft.entity.Living)

Example 2 with Living

use of net.minecraft.entity.Living in project StationAPI by ModificationStation.

the class MobSpawnDataProvider method getSpawnData.

@Override
default AbstractPacket getSpawnData() {
    Living mob = (Living) this;
    Message message = new Message(of(MODID, "spawn_mob"));
    message.strings = new String[] { getHandlerIdentifier().toString() };
    message.ints = new int[] { mob.entityId, MathHelper.floor(mob.x * 32.0D), MathHelper.floor(mob.y * 32.0D), MathHelper.floor(mob.z * 32.0D) };
    byte[] rotations = new byte[] { (byte) ((int) (mob.yaw * 256.0F / 360.0F)), (byte) ((int) (mob.pitch * 256.0F / 360.0F)) };
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    mob.getDataTracker().write(new DataOutputStream(outputStream));
    byte[] data = outputStream.toByteArray();
    message.bytes = Bytes.concat(rotations, data);
    writeToMessage(message);
    return message;
}
Also used : Message(net.modificationstation.stationapi.api.packet.Message) Living(net.minecraft.entity.Living)

Aggregations

Living (net.minecraft.entity.Living)2 Message (net.modificationstation.stationapi.api.packet.Message)1