Search in sources :

Example 1 with EntityBunnyMount

use of de.sanandrew.mods.claysoldiers.entity.mount.EntityBunnyMount in project ClaySoldiersMod by SanAndreasP.

the class ItemBunnyDoll method onItemUse.

@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int blockX, int blockY, int blockZ, int side, float offX, float offY, float offZ) {
    if (world.isRemote) {
        return true;
    } else {
        Block block = world.getBlock(blockX, blockY, blockZ);
        double entityOffY = 0.0D;
        int maxSpawns = stack.stackSize;
        if (player.isSneaking()) {
            maxSpawns = 1;
        }
        if (side == 1 && block.getRenderType() == 11) {
            entityOffY = 0.5D;
        }
        blockX += Facing.offsetsXForSide[side];
        blockY += Facing.offsetsYForSide[side];
        blockZ += Facing.offsetsZForSide[side];
        for (int i = 0; i < maxSpawns; i++) {
            EntityBunnyMount dan = spawnBunny(world, EnumBunnyType.getTypeFromItem(stack), blockX + 0.5D, blockY + entityOffY, blockZ + 0.5D);
            if (dan != null) {
                if (stack.hasDisplayName()) {
                    dan.setCustomNameTag(stack.getDisplayName());
                }
                if (!player.capabilities.isCreativeMode) {
                    dan.dollItem = stack.splitStack(1);
                }
            }
        }
        return true;
    }
}
Also used : Block(net.minecraft.block.Block) EntityBunnyMount(de.sanandrew.mods.claysoldiers.entity.mount.EntityBunnyMount)

Example 2 with EntityBunnyMount

use of de.sanandrew.mods.claysoldiers.entity.mount.EntityBunnyMount in project ClaySoldiersMod by SanAndreasP.

the class ItemBunnyDoll method spawnBunny.

/**
 * Spawns the bunny specified by the type in the location specified by the last three parameters.
 *
 * @param world the World the entity will spawn in
 * @param type  the type the bunny will be
 */
public static EntityBunnyMount spawnBunny(World world, EnumBunnyType type, double x, double y, double z) {
    EntityBunnyMount jordan = new EntityBunnyMount(world, type);
    jordan.setLocationAndAngles(x, y, z, MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360.0F), 0.0F);
    jordan.rotationYawHead = jordan.rotationYaw;
    jordan.renderYawOffset = jordan.rotationYaw;
    world.spawnEntityInWorld(jordan);
    jordan.playSound("step.gravel", 1.0F, 1.0F);
    return jordan;
}
Also used : EntityBunnyMount(de.sanandrew.mods.claysoldiers.entity.mount.EntityBunnyMount)

Example 3 with EntityBunnyMount

use of de.sanandrew.mods.claysoldiers.entity.mount.EntityBunnyMount in project ClaySoldiersMod by SanAndreasP.

the class BehaviorDollDispenseItem method doDispense.

private static void doDispense(World world, ItemStack stack, EnumFacing facing, IPosition position) {
    double x = position.getX();
    double y = position.getY() - (facing == EnumFacing.UP ? 0.0D : 0.3D);
    double z = position.getZ();
    if (stack.getItem() == RegistryItems.dollSoldier) {
        EntityClayMan spencer = ItemClayManDoll.spawnClayMan(world, ItemClayManDoll.getTeam(stack).getTeamName(), x, y, z);
        spencer.dollItem = stack;
    } else if (stack.getItem() == RegistryItems.dollHorseMount) {
        EntityHorseMount spencer = ItemHorseDoll.spawnHorse(world, ItemHorseDoll.getType(stack), ItemHorseDoll.isPegasus(stack), x, y, z);
        spencer.dollItem = stack;
    } else if (stack.getItem() == RegistryItems.dollTurtleMount) {
        EntityTurtleMount spencer = ItemTurtleDoll.spawnTurtle(world, ItemTurtleDoll.getType(stack), x, y, z);
        spencer.dollItem = stack;
    } else if (stack.getItem() == RegistryItems.dollGeckoMount) {
        EntityGeckoMount spencer = ItemGeckoDoll.spawnGecko(world, ItemGeckoDoll.getType(stack), x, y, z);
        spencer.dollItem = stack;
    } else if (stack.getItem() == RegistryItems.dollBunnyMount) {
        EntityBunnyMount spencer = ItemBunnyDoll.spawnBunny(world, ItemBunnyDoll.getType(stack), x, y, z);
        spencer.dollItem = stack;
    }
}
Also used : EntityHorseMount(de.sanandrew.mods.claysoldiers.entity.mount.EntityHorseMount) EntityTurtleMount(de.sanandrew.mods.claysoldiers.entity.mount.EntityTurtleMount) EntityClayMan(de.sanandrew.mods.claysoldiers.entity.EntityClayMan) EntityGeckoMount(de.sanandrew.mods.claysoldiers.entity.mount.EntityGeckoMount) EntityBunnyMount(de.sanandrew.mods.claysoldiers.entity.mount.EntityBunnyMount)

Aggregations

EntityBunnyMount (de.sanandrew.mods.claysoldiers.entity.mount.EntityBunnyMount)3 EntityClayMan (de.sanandrew.mods.claysoldiers.entity.EntityClayMan)1 EntityGeckoMount (de.sanandrew.mods.claysoldiers.entity.mount.EntityGeckoMount)1 EntityHorseMount (de.sanandrew.mods.claysoldiers.entity.mount.EntityHorseMount)1 EntityTurtleMount (de.sanandrew.mods.claysoldiers.entity.mount.EntityTurtleMount)1 Block (net.minecraft.block.Block)1