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

The following examples show how to use net.minecraft.entity.Entity#setDead() . 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: NoDesyncModule.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Listener
public void receivePacket(EventReceivePacket event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {
        if (event.getPacket() instanceof SPacketSoundEffect) {
            final SPacketSoundEffect packet = (SPacketSoundEffect) event.getPacket();
            if (packet.getCategory() == SoundCategory.BLOCKS && packet.getSound() == SoundEvents.ENTITY_GENERIC_EXPLODE) {
                for (Entity e : Minecraft.getMinecraft().world.loadedEntityList) {
                    if (e != null && e instanceof EntityEnderCrystal) {
                        if (e.getDistance(packet.getX(), packet.getY(), packet.getZ()) <= 6.0f) {
                            e.setDead();
                        }
                    }
                }
            }
        }
    }
}
 
Example 2
Source File: ScoopBehaviour.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Method(modid = GTValues.MODID_FR)
private boolean processButterflyCatch(ItemStack itemStack, EntityPlayer player, Entity entity) {
    if (entity instanceof IEntityButterfly) {
        if (player.world.isRemote) {
            return true;
        }
        if (player.capabilities.isCreativeMode || GTUtility.doDamageItem(itemStack, this.cost, false)) {
            IEntityButterfly butterfly = (IEntityButterfly) entity;
            IAlleleButterflySpecies species = butterfly.getButterfly().getGenome().getPrimary();
            species.getRoot().getBreedingTracker(entity.world, player.getGameProfile()).registerCatch(butterfly.getButterfly());
            player.world.spawnEntity(new EntityItem(player.world, entity.posX, entity.posY, entity.posZ,
                species.getRoot().getMemberStack(butterfly.getButterfly().copy(), EnumFlutterType.BUTTERFLY)));
            entity.setDead();
        }
        return true;
    }
    return false;
}
 
Example 3
Source File: ContainerLifecycleCommands.java    From mobycraft with Apache License 2.0 6 votes vote down vote up
public void killChaosMonkeys() {
	World world = sender.getEntityWorld();
	int numberOfMonkeys = 0;
	for (Entity entity : world.getLoadedEntityList()) {
		if (entity instanceof EntityChaosMonkey) {
			entity.setDead();
			numberOfMonkeys++;
		}
	}

	if (numberOfMonkeys == 0) {
		sendErrorMessage("There are no Chaos Monkeys in this world!");
	} else if (numberOfMonkeys == 1) {
		sendConfirmMessage("Killed 1 Chaos Monkey.");
	} else {
		sendConfirmMessage("Killed " + numberOfMonkeys + " Chaos Monkeys.");
	}
}
 
Example 4
Source File: ProtectionManager.java    From MyTown2 with The Unlicense 6 votes vote down vote up
public static boolean checkExist(Entity entity, boolean spawn) {
    if(entity instanceof EntityLiving) {
        if (Config.instance.mobTravelInTowns.get() && !spawn) {
            return false;
        }
        if(!getFlagValueAtLocation(FlagType.ENTITIES, entity.dimension, (int) Math.floor(entity.posX), (int) Math.floor(entity.posY), (int) Math.floor(entity.posZ))) {
            entity.isDead = true;
            entity.setDead();
            return true;
        }
    }

    for(SegmentEntity segment : segmentsTrackedEntity.get(entity.getClass())) {
        if(!segment.shouldExist(entity)) {
            entity.isDead = true;
            entity.setDead();
            return true;
        }
    }

    return false;
}
 
Example 5
Source File: MoCEntityElephant.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
private void destroyPlatforms()
{
    int j = 0;
    List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(3D, 3D, 3D));
    for (int i = 0; i < list.size(); i++)
    {
        Entity entity1 = (Entity) list.get(i);
        if ((entity1 instanceof MoCEntityPlatform))
        {
            entity1.setDead();
            j++;
        }
    }
    if (j != 0)
    {
        //System.out.println("destroyed " + j + " platforms");
    }

}
 
Example 6
Source File: TileEntityPassengerChair.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
public void onBlockBroken(IBlockState state) {
    if (chairEntityUUID != null) {
        // Kill the chair entity.
        Entity chairEntity = ((WorldServer) getWorld()).getEntityFromUuid(chairEntityUUID);
        if (chairEntity != null) {
            chairEntity.setDead();
        }
    }
}
 
Example 7
Source File: CauldronHooks.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public static boolean checkBoundingBoxSize(Entity entity, AxisAlignedBB aabb)
{
    if (entity instanceof EntityLivingBase && (!(entity instanceof IBossDisplayData) || !(entity instanceof IEntityMultiPart))
            && !(entity instanceof EntityPlayer))
    {
        int logSize = MinecraftServer.cauldronConfig.largeBoundingBoxLogSize.getValue();
        if (logSize <= 0 || !MinecraftServer.cauldronConfig.checkEntityBoundingBoxes.getValue()) return false;
        int x = MathHelper.floor_double(aabb.minX);
        int x1 = MathHelper.floor_double(aabb.maxX + 1.0D);
        int y = MathHelper.floor_double(aabb.minY);
        int y1 = MathHelper.floor_double(aabb.maxY + 1.0D);
        int z = MathHelper.floor_double(aabb.minZ);
        int z1 = MathHelper.floor_double(aabb.maxZ + 1.0D);

        int size = Math.abs(x1 - x) * Math.abs(y1 - y) * Math.abs(z1 - z);
        if (size > MinecraftServer.cauldronConfig.largeBoundingBoxLogSize.getValue())
        {
            logWarning("Entity being removed for bounding box restrictions");
            logWarning("BB Size: {0} > {1} avg edge: {2}", size, logSize, aabb.getAverageEdgeLength());
            logWarning("Motion: ({0}, {1}, {2})", entity.motionX, entity.motionY, entity.motionZ);
            logWarning("Calculated bounding box: {0}", aabb);
            logWarning("Entity bounding box: {0}", entity.getBoundingBox());
            logWarning("Entity: {0}", entity);
            NBTTagCompound tag = new NBTTagCompound();
            entity.writeToNBT(tag);
            logWarning("Entity NBT: {0}", tag);
            logStack();
            entity.setDead();
            return true;
        }
    }

    return false;
}
 
Example 8
Source File: TileSpaceElevator.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void deconstructMultiBlock(World world, BlockPos destroyedPos,
		boolean blockBroken, IBlockState state) {
	super.deconstructMultiBlock(world, destroyedPos, blockBroken, state);
	
	Entity e = getCapsuleOnLine();
	
	if(e != null)
		e.setDead();
}
 
Example 9
Source File: ItemChairWand.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
{
    if (player.getEntityWorld().isRemote == false && entity instanceof EntityChair)
    {
        entity.setDead();
        return true;
    }

    return super.onLeftClickEntity(stack, player, entity);
}
 
Example 10
Source File: ProtectionManager.java    From MyTown2 with The Unlicense 5 votes vote down vote up
public static void checkImpact(Entity entity, Resident owner, MovingObjectPosition mop, Event event) {
    for(SegmentEntity segment : segmentsEntity.get(entity.getClass())) {
        if(!segment.shouldImpact(entity, owner, mop)) {
            event.setCanceled(true);
            entity.isDead = true;
            entity.setDead();
        }
    }
}
 
Example 11
Source File: EntityFallenKnight.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
@Override
protected void despawnEntity() {
  Entity mount = getRidingEntity();
  super.despawnEntity();
  if(isDead && mount != null) {
    mount.setDead();
  }
}
 
Example 12
Source File: HackableCaveSpider.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onHackFinished(Entity entity, EntityPlayer player){
    entity.setDead();
    EntitySpider spider = new EntitySpider(entity.worldObj);
    spider.setPositionAndRotation(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
    spider.setHealth(((EntitySpider)entity).getHealth());
    spider.renderYawOffset = ((EntitySpider)entity).renderYawOffset;
    entity.worldObj.spawnEntityInWorld(spider);
}
 
Example 13
Source File: HackableCow.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onHackFinished(Entity entity, EntityPlayer player){
    if(!entity.worldObj.isRemote) {
        entity.setDead();
        EntityMooshroom entitycow = new EntityMooshroom(entity.worldObj);
        entitycow.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
        entitycow.setHealth(((EntityCow)entity).getHealth());
        entitycow.renderYawOffset = ((EntityCow)entity).renderYawOffset;
        entity.worldObj.spawnEntityInWorld(entitycow);
        entity.worldObj.spawnParticle("largeexplode", entity.posX, entity.posY + entity.height / 2.0F, entity.posZ, 0.0D, 0.0D, 0.0D);
    }
}
 
Example 14
Source File: HackableBat.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onHackFinished(Entity entity, EntityPlayer player){
    if(!entity.worldObj.isRemote) {
        entity.setDead();
        entity.worldObj.createExplosion(null, entity.posX, entity.posY, entity.posZ, 0, false);
    }
}
 
Example 15
Source File: TaskFillArea.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected void fillBoxDirect(IntBoundingBox box, boolean removeEntities)
{
    if (removeEntities)
    {
        AxisAlignedBB aabb = new AxisAlignedBB(box.minX, box.minY, box.minZ, box.maxX + 1, box.maxY + 1, box.maxZ + 1);
        List<Entity> entities = this.world.getEntitiesInAABBexcluding(this.mc.player, aabb, EntityUtils.NOT_PLAYER);

        for (Entity entity : entities)
        {
            if ((entity instanceof EntityPlayer) == false)
            {
                entity.setDead();
            }
        }
    }

    try
    {
        WorldUtils.setShouldPreventBlockUpdates(this.world, true);

        IBlockState barrier = Blocks.BARRIER.getDefaultState();
        BlockPos.MutableBlockPos posMutable = new BlockPos.MutableBlockPos();

        for (int z = box.minZ; z <= box.maxZ; ++z)
        {
            for (int x = box.minX; x <= box.maxX; ++x)
            {
                for (int y = box.maxY; y >= box.minY; --y)
                {
                    posMutable.setPos(x, y, z);
                    IBlockState oldState = this.world.getBlockState(posMutable).getActualState(this.world, posMutable);

                    if ((this.replaceState == null && oldState != this.fillState) || oldState == this.replaceState)
                    {
                        TileEntity te = this.world.getTileEntity(posMutable);

                        if (te instanceof IInventory)
                        {
                            ((IInventory) te).clear();
                            this.world.setBlockState(posMutable, barrier, 0x12);
                        }

                        this.world.setBlockState(posMutable, this.fillState, 0x12);
                    }
                }
            }
        }
    }
    finally
    {
        WorldUtils.setShouldPreventBlockUpdates(this.world, false);
    }
}
 
Example 16
Source File: ItemBuildersWand.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void deleteArea(ItemStack stack, World world, EntityPlayer player, BlockPos posStart, BlockPos posEnd, boolean removeEntities)
{
    if (posStart == null || posEnd == null)
    {
        return;
    }

    if (player.getDistanceSq(posStart) > 160 * 160)
    {
        player.sendStatusMessage(new TextComponentTranslation("enderutilities.chat.message.areatoofar"), true);
        return;
    }

    if (this.isAreaWithinSizeLimit(posStart.subtract(posEnd), stack, player) == false)
    {
        player.sendStatusMessage(new TextComponentTranslation("enderutilities.chat.message.areatoolarge"), true);
        return;
    }

    // Set all blocks to air
    for (BlockPos.MutableBlockPos posMutable : BlockPos.getAllInBoxMutable(posStart, posEnd))
    {
        if (world.isAirBlock(posMutable) == false)
        {
            BlockUtils.setBlockToAirWithoutSpillingContents(world, posMutable, 2);
        }
    }

    // Remove pending block updates from within the area
    BlockPos posMin = PositionUtils.getMinCorner(posStart, posEnd);
    BlockPos posMax = PositionUtils.getMaxCorner(posStart, posEnd).add(1, 1, 1);
    StructureBoundingBox sbb = StructureBoundingBox.createProper(posMin.getX(), posMin.getY(), posMin.getZ(), posMax.getX(), posMax.getY(), posMax.getZ());
    world.getPendingBlockUpdates(sbb, true); // The boolean parameter indicates whether the entries will be removed

    // Remove all entities within the area
    int count = 0;

    if (removeEntities)
    {
        int x1 = Math.min(posStart.getX(), posEnd.getX());
        int y1 = Math.min(posStart.getY(), posEnd.getY());
        int z1 = Math.min(posStart.getZ(), posEnd.getZ());
        int x2 = Math.max(posStart.getX(), posEnd.getX());
        int y2 = Math.max(posStart.getY(), posEnd.getY());
        int z2 = Math.max(posStart.getZ(), posEnd.getZ());

        AxisAlignedBB bb = new AxisAlignedBB(x1, y1, z1, x2 + 1, y2 + 1, z2 + 1);
        List<Entity> entities = world.getEntitiesWithinAABBExcludingEntity(null, bb);

        for (Entity entity : entities)
        {
            if ((entity instanceof EntityPlayer) == false || entity instanceof FakePlayer)
            {
                entity.setDead();
                count++;
            }
        }

        if (count > 0)
        {
            player.sendStatusMessage(new TextComponentTranslation("enderutilities.chat.message.killedentitieswithcount", count), true);
        }
    }
}