Java Code Examples for net.minecraft.entity.Entity#isBeingRidden()
The following examples show how to use
net.minecraft.entity.Entity#isBeingRidden() .
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: EntityUtils.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
/** * Check if the Entity <b>rider</b> is among the riders of the other Entity <b>target</b>. * This check is done recursively to all the riders of <b>target</b>. */ public static boolean isEntityRiddenBy(Entity target, Entity rider) { if (target == null || rider == null) { return false; } if (target.isBeingRidden()) { List<Entity> passengers = target.getPassengers(); for (Entity passenger : passengers) { if (passenger.equals(rider) || isEntityRiddenBy(passenger, rider)) { return true; } } } return false; }
Example 2
Source File: EntityUtils.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
private static void getAllEntitiesInStack(Entity entity, List<Entity> entities, boolean startFromBottom) { if (startFromBottom) { entity = getBottomEntity(entity); } entities.add(entity); if (entity.isBeingRidden()) { for (Entity passenger : entity.getPassengers()) { getAllEntitiesInStack(passenger, entities, false); } } }
Example 3
Source File: BlockTofuPortal.java From TofuCraftReload with MIT License | 5 votes |
/** * 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 4
Source File: EntityUtils.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
public static void spawnEntityAndPassengersInWorld(Entity entity, World world) { if (world.spawnEntity(entity) && entity.isBeingRidden()) { for (Entity passenger : entity.getPassengers()) { passenger.setPosition(entity.posX, entity.posY + entity.getMountedYOffset() + passenger.getYOffset(), entity.posZ); spawnEntityAndPassengersInWorld(passenger, world); } } }
Example 5
Source File: BlockPortal.java From TFC2 with GNU General Public License v3.0 | 5 votes |
/** * 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 6
Source File: EntityUtils.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
private static Entity findEntityFromStackByUUID(Entity entityInStack, UUID uuid, boolean startFromBottom) { // TODO useless check? if (entityInStack == null) { return null; } if (uuid.equals(entityInStack.getUniqueID())) { return entityInStack; } if (startFromBottom) { entityInStack = getBottomEntity(entityInStack); } if (entityInStack.isBeingRidden()) { List<Entity> passengers = entityInStack.getPassengers(); for (Entity passenger : passengers) { if (uuid.equals(passenger.getUniqueID())) { return passenger; } entityInStack = findEntityFromStackByUUID(passenger, uuid, false); if (entityInStack != null) { return entityInStack; } } } return null; }
Example 7
Source File: EntityUtils.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
/** * Gets the top-most riding entity. Note: Always gets the first rider (ie. get(0))! */ public static Entity getTopEntity(Entity entity) { while (entity.isBeingRidden()) { entity = entity.getPassengers().get(0); } return entity; }
Example 8
Source File: EntityUtils.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
private static boolean doesEntityStackHavePlayers(Entity entity, boolean startFromBottom) { if (entity instanceof EntityPlayer) { return true; } if (startFromBottom) { entity = getBottomEntity(entity); } if (entity.isBeingRidden()) { List<Entity> passengers = entity.getPassengers(); for (Entity passenger : passengers) { if (passenger instanceof EntityPlayer || doesEntityStackHavePlayers(passenger, false)) { return true; } } } return false; }
Example 9
Source File: EntityUtils.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
private static boolean doesEntityStackContainEntity(Entity entity, Entity entityInStack, boolean startFromBottom) { if (startFromBottom) { entityInStack = getBottomEntity(entityInStack); } if (entity == entityInStack) { return true; } if (entityInStack.isBeingRidden()) { List<Entity> passengers = entityInStack.getPassengers(); for (Entity passenger : passengers) { if (passenger == entity || doesEntityStackContainEntity(entity, passenger, false)) { return true; } } } return false; }
Example 10
Source File: EntityUtils.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
private static boolean doesEntityStackHaveBlacklistedEntities(Entity entity, boolean startFromBottom) { if (BlackLists.isEntityBlacklistedForTeleport(entity)) { return true; } if (startFromBottom) { entity = getBottomEntity(entity); } if (entity.isBeingRidden()) { List<Entity> passengers = entity.getPassengers(); for (Entity passenger : passengers) { if (BlackLists.isEntityBlacklistedForTeleport(passenger) || doesEntityStackHaveBlacklistedEntities(passenger, false)) { return true; } } } return false; }
Example 11
Source File: EntityUtils.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
public static boolean unmountFirstRider(Entity entity) { if (entity != null && entity.isBeingRidden()) { entity.getPassengers().get(0).dismountRidingEntity(); return true; } return false; }
Example 12
Source File: BlockUnderworldTeleporter.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
@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 13
Source File: TileEntityPassengerChair.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
public void tryToMountPlayerToChair(EntityPlayer player, Vec3d mountPos) { if (getWorld().isRemote) { throw new IllegalStateException( "tryToMountPlayerToChair is not designed to be called on client side!"); } boolean isChairEmpty; if (chairEntityUUID != null) { Entity chairEntity = ((WorldServer) getWorld()).getEntityFromUuid(chairEntityUUID); if (chairEntity != null) { if (chairEntity.isDead || chairEntity.isBeingRidden()) { // Dead entity, chair is empty. this.chairEntityUUID = null; markDirty(); isChairEmpty = true; } else { // Everything checks out, this chair is not empty. isChairEmpty = false; } } else { // Either null or not a chair entity (somehow?). Just consider this chair as empty this.chairEntityUUID = null; markDirty(); isChairEmpty = true; } } else { // No UUID for a chair entity, so this chair must be empty. isChairEmpty = true; } if (isChairEmpty) { // Chair is guaranteed empty. Optional<PhysicsObject> physicsObject = ValkyrienUtils .getPhysicsObject(getWorld(), getPos()); CoordinateSpaceType mountCoordType = physicsObject.isPresent() ? CoordinateSpaceType.SUBSPACE_COORDINATES : CoordinateSpaceType.GLOBAL_COORDINATES; EntityMountableChair entityMountable = new EntityMountableChair(getWorld(), mountPos, mountCoordType, getPos()); chairEntityUUID = entityMountable.getPersistentID(); markDirty(); getWorld().spawnEntity(entityMountable); player.startRiding(entityMountable); } }
Example 14
Source File: EntityEnderPearlReusable.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected void onImpact(RayTraceResult rayTraceResult) { Entity thrower = this.getThrower(); // Thrower not found, drop the item if applicable and bail out if (thrower == null) { if (this.getEntityWorld().isRemote == false && this.canPickUp) { this.dropAsItem(); } this.setDead(); return; } // Don't collide with the thrower or the entities in the 'stack' with the thrower if (this.getEntityWorld().isRemote == false && rayTraceResult.typeOfHit == RayTraceResult.Type.ENTITY) { if (EntityUtils.doesEntityStackContainEntity(rayTraceResult.entityHit, thrower)) { return; } if (rayTraceResult.entityHit instanceof EntityPlayerMP && ((EntityPlayerMP)rayTraceResult.entityHit).isSpectator()) { return; } if (rayTraceResult.entityHit instanceof EntityLivingBase) { rayTraceResult.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, thrower), 0.0f); } } // Don't collide with blocks without a collision box else if (rayTraceResult.typeOfHit == RayTraceResult.Type.BLOCK && rayTraceResult.getBlockPos() != null) { IBlockState state = this.getEntityWorld().getBlockState(rayTraceResult.getBlockPos()); AxisAlignedBB aabb = state.getCollisionBoundingBox(this.getEntityWorld(), rayTraceResult.getBlockPos()); if (aabb == Block.NULL_AABB) { return; } } // A regular pearl lands, teleport the thrower if (this.isElite == false) { // If the thrower is currently riding an elite pearl, unmount the pearl Entity bottom = thrower.getLowestRidingEntity(); if (bottom instanceof EntityEnderPearlReusable && bottom.isBeingRidden()) { bottom.removePassengers(); } if (this.getEntityWorld().isRemote == false) { TeleportEntity.teleportEntityWithProjectile(thrower, this, rayTraceResult, this.teleportDamage, true, true); } } // An Elite pearl lands, which is still being ridden by something (see above) else if (this.isBeingRidden()) { Entity entity = this.getPassengers().get(0); this.removePassengers(); if (this.getEntityWorld().isRemote == false) { TeleportEntity.teleportEntityWithProjectile(entity, this, rayTraceResult, this.teleportDamage, true, true); } } // Try to add the pearl straight back to the player's inventory if (this.getEntityWorld().isRemote == false && this.returnToPlayersInventory() == false) { this.dropAsItem(); } this.setDead(); }