Java Code Examples for net.minecraft.entity.Entity#isRiding()

The following examples show how to use net.minecraft.entity.Entity#isRiding() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockTofuPortal.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * Called When an Entity Collided with the Block
 */

@Override
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {

    if (!entityIn.isRiding() && !entityIn.isBeingRidden() && entityIn.isNonBoss()) {
        MinecraftServer server = worldIn.getMinecraftServer();
        if (server != null && entityIn.timeUntilPortal <= 0) {
            PlayerList playerList = server.getPlayerList();
            int i = entityIn.dimension == DimensionType.OVERWORLD.getId() ?
                    TofuMain.TOFU_DIMENSION.getId() : DimensionType.OVERWORLD.getId();
            TofuTeleporter teleporter = new TofuTeleporter(server.getWorld(i));
            entityIn.timeUntilPortal = 100;

            if (entityIn instanceof EntityPlayerMP) {
                playerList.transferPlayerToDimension((EntityPlayerMP) entityIn, i, teleporter);
            } else {
                int origin = entityIn.dimension;
                entityIn.dimension = i;
                worldIn.removeEntityDangerously(entityIn);
                entityIn.isDead = false;
                playerList.transferEntityToWorld(entityIn, origin, server.getWorld(origin), server.getWorld(i),
                        teleporter);

            }


        } else
            entityIn.timeUntilPortal = Math.max(entityIn.getPortalCooldown(), 100);
    }

}
 
Example 2
Source File: BlockPortal.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Called When an Entity Collided with the Block
 */
@Override
public void onEntityCollidedWithBlock(World worldObj, BlockPos pos, IBlockState state, Entity entityIn)
{
	/*if( !worldObj.isRemote)
	{
		if(worldObj.provider.getDimension() == 0)
		{
			entityIn.changeDimension(2);
		}
		else if(worldObj.provider.getDimension() == 2)
		{
			entityIn.changeDimension(0);
		}
	}*/

	if (!entityIn.isRiding() && !entityIn.isBeingRidden() && !worldObj.isRemote)
	{
		NBTTagCompound nbt = entityIn.getEntityData().getCompoundTag("TFC2");
		if(Timekeeper.getInstance().getTotalTicks() - nbt.getLong("lastPortalTime") < 1000)
			return;

		MinecraftServer minecraftserver = worldObj.getMinecraftServer();
		if(worldObj.provider.getDimension() == 0)
		{
			entityIn.changeDimension(2);

			nbt.setLong("lastPortalTime", Timekeeper.getInstance().getTotalTicks());
		}
		else if(worldObj.provider.getDimension() == 2)
		{
			entityIn.changeDimension(0);

			nbt.setLong("lastPortalTime", Timekeeper.getInstance().getTotalTicks());
		}
	}
}
 
Example 3
Source File: ItemMobHarness.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public boolean handleInteraction(ItemStack stack, EntityPlayer player, Entity entity)
{
    if (player.isSneaking() == false)
    {
        //EntityUtils.unmountFirstRider(entity);
        player.startRiding(entity, true);
        addAITask(entity, true);

        return true;
    }

    // Harness bound to something, mount the entity
    if (this.hasTarget(stack))
    {
        this.mountTarget(stack, player.getEntityWorld(), player, entity);
    }
    // Empty harness
    else
    {
        // Empty harness, player looking up and ridden by something: dismount the rider
        if (player.rotationPitch < -80.0f && player.isBeingRidden())
        {
            player.removePassengers();
        }
        // Empty harness, target is riding something: dismount target
        else if (entity.isRiding())
        {
            entity.dismountRidingEntity();
        }
        // Empty harness, target not riding anything, store/link target
        else
        {
            this.storeTarget(stack, entity);
        }
    }

    return true;
}
 
Example 4
Source File: BlockUnderworldTeleporter.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void onEntityCollision(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
	if(entityIn != null && !worldIn.isRemote && !entityIn.isRiding() && !entityIn.isBeingRidden() && entityIn.isNonBoss() && entityIn.getEntityBoundingBox().intersects(state.getBoundingBox(worldIn, pos).offset(pos))) {
		entityIn.changeDimension(ConfigValues.underworldID);
	}
}
 
Example 5
Source File: TileEntityAirCannon.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
private synchronized boolean fire(){
    Entity itemShot = getCloseEntityIfUpgraded();
    if(getPressure(ForgeDirection.UNKNOWN) >= PneumaticValues.MIN_PRESSURE_AIR_CANNON && (itemShot != null || inventory[0] != null)) {
        double[] velocity = getVelocityVector(heightAngle, rotationAngle, getForce());
        addAir((int)(-500 * getForce()), ForgeDirection.UNKNOWN);
        boolean shootingInventory = false;
        if(itemShot == null) {
            shootingInventory = true;
            itemShot = getPayloadEntity();

            if(itemShot instanceof EntityItem) {
                inventory[0] = null;
                if(getUpgrades(ItemMachineUpgrade.UPGRADE_BLOCK_TRACKER) > 0) {
                    trackedItems.add((EntityItem)itemShot);
                }
            } else {
                inventory[0].stackSize--;
                if(inventory[0].stackSize <= 0) inventory[0] = null;
            }
        } else if(itemShot instanceof EntityPlayer) {
            EntityPlayerMP entityplayermp = (EntityPlayerMP)itemShot;
            if(entityplayermp.playerNetServerHandler.func_147362_b().isChannelOpen()) {
                entityplayermp.setPositionAndUpdate(xCoord + 0.5D, yCoord + 1.8D, zCoord + 0.5D);
            }
        }

        if(itemShot.isRiding()) {
            itemShot.mountEntity((Entity)null);
        }

        itemShot.setPosition(xCoord + 0.5D, yCoord + 1.8D, zCoord + 0.5D);
        NetworkHandler.sendToAllAround(new PacketSetEntityMotion(itemShot, velocity[0], velocity[1], velocity[2]), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 64));

        if(itemShot instanceof EntityFireball) {
            velocity[0] *= 0.05D;
            velocity[1] *= 0.05D;
            velocity[2] *= 0.05D;
        }

        itemShot.motionX = velocity[0];
        itemShot.motionY = velocity[1];
        itemShot.motionZ = velocity[2];

        itemShot.onGround = false;
        itemShot.isCollided = false;
        itemShot.isCollidedHorizontally = false;
        itemShot.isCollidedVertically = false;
        if(itemShot instanceof EntityLivingBase) ((EntityLivingBase)itemShot).setJumping(true);

        if(shootingInventory && !worldObj.isRemote) worldObj.spawnEntityInWorld(itemShot);

        for(int i = 0; i < 10; i++) {
            double velX = velocity[0] * 0.4D + (rand.nextGaussian() - 0.5D) * 0.05D;
            double velY = velocity[1] * 0.4D + (rand.nextGaussian() - 0.5D) * 0.05D;
            double velZ = velocity[2] * 0.4D + (rand.nextGaussian() - 0.5D) * 0.05D;
            NetworkHandler.sendToAllAround(new PacketSpawnParticle("largesmoke", xCoord + 0.5D, yCoord + 0.7D, zCoord + 0.5D, velX, velY, velZ), worldObj);
        }
        NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.CANNON_SOUND, xCoord, yCoord, zCoord, 1.0F, rand.nextFloat() / 4F + 0.75F, true), worldObj);
        return true;
    } else {
        return false;
    }
}