net.minecraft.world.World.removeEntity()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(292)

本文整理了Java中net.minecraft.world.World.removeEntity()方法的一些代码示例,展示了World.removeEntity()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。World.removeEntity()方法的具体详情如下:
包路径:net.minecraft.world.World
类名称:World
方法名:removeEntity

World.removeEntity介绍

暂无

代码示例

代码示例来源:origin: SleepyTrousers/EnderIO

  1. @Override
  2. public void removeEntity(@Nonnull Entity entityIn) {
  3. wrapped.removeEntity(entityIn);
  4. }

代码示例来源:origin: amadornes/MCMultiPart

  1. @Override
  2. public void removeEntity(Entity entityIn) {
  3. getActualWorld().removeEntity(entityIn);
  4. }

代码示例来源:origin: TeamWizardry/Wizardry

  1. @Override
  2. public void onUpdate() {
  3. super.onUpdate();
  4. if (world == null || infuserPos == null) return;
  5. TileEntity tile = world.getTileEntity(infuserPos);
  6. if (!(tile instanceof TileHaloInfuser)) {
  7. world.removeEntity(this);
  8. }
  9. }

代码示例来源:origin: TeamWizardry/Wizardry

  1. @Override
  2. public void finish(World world, BlockPos pos, List<EntityItem> items) {
  3. EntityItem item = items.stream().filter(entity -> entity.getItem().getItem() instanceof IExplodable).findFirst().orElse(null);
  4. if (item != null) {
  5. ((IExplodable) item.getItem().getItem()).explode(item);
  6. world.setBlockToAir(pos);
  7. world.removeEntity(item);
  8. world.playSound(null, item.posX, item.posY, item.posZ, ModSounds.GLASS_BREAK, SoundCategory.AMBIENT, 0.5F, (RandUtil.nextFloat() * 0.4F) + 0.8F);
  9. }
  10. }
  11. }

代码示例来源:origin: TeamWizardry/Wizardry

  1. @Override
  2. public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
  3. if (entity instanceof EntityFairy) {
  4. EntityFairy fairy = (EntityFairy) entity;
  5. ItemNBTHelper.setBoolean(stack, Constants.NBT.FAIRY_INSIDE, true);
  6. ItemNBTHelper.setInt(stack, Constants.NBT.FAIRY_COLOR, fairy.getColor().getRGB());
  7. ItemNBTHelper.setInt(stack, Constants.NBT.FAIRY_AGE, fairy.getAge());
  8. entity.world.removeEntity(entity);
  9. return true;
  10. }
  11. return false;
  12. }

代码示例来源:origin: CyclopsMC/EvilCraft

  1. private static void replaceEntity(EntityLiving old, EntityLiving neww, World world) {
  2. // TODO: A nice update effect?
  3. // Maybe something like this: https://github.com/iChun/Morph/blob/master/morph/client/model/ModelMorphAcquisition.java
  4. neww.copyLocationAndAnglesFrom(old);
  5. world.removeEntity(old);
  6. world.spawnEntity(neww);
  7. world.playEvent(null, 1016, old.getPosition(), 0);
  8. }

代码示例来源:origin: TeamWizardry/Wizardry

  1. public void refreshEntities() {
  2. entities.forEach(entityHaloInfusionItem -> world.removeEntity(entityHaloInfusionItem));
  3. entities.clear();
  4. int count = HaloInfusionItemRegistry.getItems().size();
  5. double radius = 3;
  6. for (int i = 0; i < count; i++) {
  7. float angle = (float) (i * Math.PI * 2.0 / count);
  8. double x = (pos.getX() + 0.5 + MathHelper.cos(angle) * radius);
  9. double z = (pos.getZ() + 0.5 + MathHelper.sin(angle) * radius);
  10. EntityHaloInfusionItem entity = new EntityHaloInfusionItem(world, HaloInfusionItemRegistry.EMPTY, getPos(), i);
  11. entity.setPosition(x, pos.getY() + 2, z);
  12. entity.forceSpawn = true;
  13. world.spawnEntity(entity);
  14. entities.add(entity);
  15. }
  16. }

代码示例来源:origin: ldtteam/minecolonies

  1. colony.getWorld().removeEntity(list.get(i));

代码示例来源:origin: TeamWizardry/Wizardry

  1. @Override
  2. public void onLivingUpdate() {
  3. super.onLivingUpdate();
  4. if (world.isRemote) return;
  5. if (isAIDisabled()) return;
  6. if (ticksExisted >= getDataManager().get(TIMER)) {
  7. world.removeEntity(this);
  8. }
  9. UUID uuid = null;
  10. if (getRevengeTarget() != null) uuid = getRevengeTarget().getUniqueID();
  11. if (uuid != null && getDataManager().get(OWNER).isPresent() && uuid.equals(getDataManager().get(OWNER).get())) {
  12. setRevengeTarget(null);
  13. }
  14. }

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

  1. private boolean consumeLivingEntity(EntityLivingBase entity, float strength) {
  2. try {
  3. mass = Math.addExact(mass, (long) Math.min(entity.getHealth(), strength));
  4. markDirty();
  5. } catch (ArithmeticException e) {
  6. return false;
  7. }
  8. if (entity.getHealth() <= strength && !(entity instanceof EntityPlayer)) {
  9. entity.setDead();
  10. world.removeEntity(entity);
  11. }
  12. DamageSource damageSource = new DamageSource("blackHole");
  13. entity.attackEntityFrom(damageSource, strength);
  14. return true;
  15. }

代码示例来源:origin: CyclopsMC/EvilCraft

  1. private void captureSpirit(VengeanceSpirit targetSpirit) {
  2. for (EntityPlayerMP player : targetSpirit.getEntanglingPlayers()) {
  3. Advancements.BOX_OF_ETERNAL_CLOSURE_CAPTURE.trigger(player, targetSpirit.getInnerEntity());
  4. }
  5. world.removeEntity(targetSpirit);
  6. this.playerId = targetSpirit.getPlayerId();
  7. this.playerName = targetSpirit.getPlayerName();
  8. setSpirit(targetSpirit);
  9. setTargetSpirit(null);
  10. close();
  11. }

代码示例来源:origin: CyclopsMC/EvilCraft

  1. this.world.removeEntity(this);

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

  1. private boolean consumeEntityItem(EntityItem entityItem) {
  2. ItemStack itemStack = entityItem.getItem();
  3. if (!itemStack.isEmpty()) {
  4. try {
  5. mass = Math.addExact(mass, (long) MatterHelper.getMatterAmountFromItem(itemStack) * (long) itemStack.getCount());
  6. markDirty();
  7. } catch (ArithmeticException e) {
  8. return false;
  9. }
  10. entityItem.setDead();
  11. world.removeEntity(entityItem);
  12. if (entityItem.getItem().getItem() instanceof MatterItem && MatterItem.getType(entityItem.getItem()) == MatterItem.MatterType.ANTIMATTER) {
  13. collapse();
  14. }
  15. return true;
  16. }
  17. return false;
  18. }

代码示例来源:origin: PrinceOfAmber/Cyclic

  1. /**
  2. * incoming: convert EXP to fluid
  3. */
  4. private void updateCollection() {
  5. //expand only goes ONE direction. so expand(3...) goes 3 in + x, but not both ways. for full boc centered at this..!! we go + and -
  6. AxisAlignedBB region = new AxisAlignedBB(this.getPos().up()).expand(RADIUS, VRADIUS, RADIUS).expand(-1 * RADIUS, -1 * VRADIUS, -1 * RADIUS);//expandXyz
  7. List<EntityXPOrb> orbs = getWorld().getEntitiesWithinAABB(EntityXPOrb.class, region);
  8. if (orbs != null) { //no timer just EAT
  9. for (EntityXPOrb orb : orbs) {
  10. if (orb.isDead || orb.delayBeforeCanPickup > 0) {
  11. continue;
  12. }
  13. this.tank.fill(new FluidStack(FluidRegistry.getFluid("xpjuice"), orb.getXpValue() * FLUID_PER_EXP), true);
  14. //we have no "set exp value" function so this is workaround to set value to zero
  15. orb.delayBeforeCanPickup = 9999;//set delay because it will be isDead=true for a little while until actually removed. prevent other mods getting dead orbs
  16. orb.xpValue = 0;
  17. getWorld().removeEntity(orb);//calls orb.setDead(); for me
  18. }
  19. }
  20. }

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

  1. private boolean consumeFallingBlock(EntityFallingBlock fallingBlock) {
  2. ItemStack itemStack = new ItemStack(fallingBlock.getBlock().getBlock(), 1, fallingBlock.getBlock().getBlock().damageDropped(fallingBlock.getBlock()));
  3. if (!itemStack.isEmpty()) {
  4. try {
  5. mass = Math.addExact(mass, (long) MatterHelper.getMatterAmountFromItem(itemStack) * (long) itemStack.getCount());
  6. markDirty();
  7. } catch (ArithmeticException e) {
  8. return false;
  9. }
  10. fallingBlock.setDead();
  11. world.removeEntity(fallingBlock);
  12. return true;
  13. }
  14. return false;
  15. }

代码示例来源:origin: TeamWizardry/Wizardry

  1. /**
  2. * Called when the projectile entity hits another block or entity, or reaches the end of its path.
  3. *
  4. * @param data The {@link SpellData} attached to the spell.
  5. */
  6. protected void goBoom(SpellRing spellRing, SpellData data) {
  7. motionX = 0;
  8. motionY = 0;
  9. motionZ = 0;
  10. if (spellRing.getChildRing() != null)
  11. spellRing.getChildRing().runSpellRing(data);
  12. if (doesRender())
  13. PacketHandler.NETWORK.sendToAllAround(new PacketExplode(getPositionVector(), spellRing.getPrimaryColor(), spellRing.getSecondaryColor(), 0.3, 0.3, RandUtil.nextInt(30, 50), 10, 25, true),
  14. new NetworkRegistry.TargetPoint(world.provider.getDimension(), posX, posY, posZ, 512));
  15. setDead();
  16. world.removeEntity(this);
  17. }

代码示例来源:origin: TeamWizardry/Wizardry

  1. @Override
  2. public boolean processInitialInteract(EntityPlayer player, EnumHand hand) {
  3. TileEntity tile = world.getTileEntity(infuserPos);
  4. if (!(tile instanceof TileHaloInfuser)) {
  5. world.removeEntity(this);
  6. return false;
  7. }
  8. ItemStack heldItem = player.getHeldItem(hand);
  9. if (heldItem.isEmpty()) {
  10. ItemStack slotted = getHaloInfusionItem().getStack();
  11. if (!slotted.isEmpty()) {
  12. player.setHeldItem(hand, slotted);
  13. setHaloInfusionItem(HaloInfusionItemRegistry.EMPTY, false);
  14. return true;
  15. } else return true;
  16. }
  17. for (HaloInfusionItem haloInfusionItem : HaloInfusionItemRegistry.getItems()) {
  18. if (haloInfusionItem.getStack().isItemEqual(heldItem)) {
  19. setHaloInfusionItem(haloInfusionItem, false);
  20. // todo: remove from hand
  21. return true;
  22. }
  23. }
  24. return true;
  25. }

代码示例来源:origin: CyclopsMC/EvilCraft

  1. @Override
  2. public boolean attackEntityAsMob(Entity entity) {
  3. if(getBuildupDuration() > 0) return false; // Don't attack anything when still building up.
  4. this.setDead();
  5. this.world.removeEntity(this);
  6. if(entity instanceof EntityPlayer) {
  7. EntityPlayer player = (EntityPlayer) entity;
  8. if(Loader.isModLoaded(Reference.MOD_THAUMCRAFT)) {
  9. addWarp((EntityPlayer) entity);
  10. }
  11. if(!Configs.isEnabled(BurningGemStoneConfig.class)
  12. || BurningGemStone.damageForPlayer(player, isSwarm() ? getSwarmTier() : 0, false)) {
  13. entity.addVelocity(
  14. (double)(-MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F) * 0.01F),
  15. 0.025D,
  16. (double)(MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F) * 0.01F));
  17. entity.attackEntityFrom(DamageSource.causeMobDamage(this), 0.1F);
  18. return false;
  19. }
  20. }
  21. return super.attackEntityAsMob(entity);
  22. }

代码示例来源:origin: CoFH/CoFHCore

  1. public static List<ItemStack> breakBlock(World worldObj, EntityPlayer player, BlockPos pos, IBlockState state, int fortune, boolean doBreak, boolean silkTouch) {
  2. if (state.getBlockHardness(worldObj, pos) == -1) {
  3. return new LinkedList<>();
  4. }
  5. NonNullList<ItemStack> ret = NonNullList.create();
  6. if (silkTouch && state.getBlock().canSilkHarvest(worldObj, pos, state, player)) {
  7. ret.add(createStackedBlock(state));
  8. } else {
  9. state.getBlock().getDrops(ret, worldObj, pos, state, fortune);
  10. }
  11. if (!doBreak) {
  12. return ret;
  13. }
  14. worldObj.playEvent(2001, pos, Block.getStateId(state));
  15. worldObj.setBlockToAir(pos);
  16. List<EntityItem> result = worldObj.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos.getX() - 2, pos.getY() - 2, pos.getZ() - 2, pos.getX() + 3, pos.getY() + 3, pos.getZ() + 3));
  17. for (EntityItem entity : result) {
  18. if (entity.isDead || entity.getItem().getCount() <= 0) {
  19. continue;
  20. }
  21. ret.add(entity.getItem());
  22. entity.world.removeEntity(entity);
  23. }
  24. return ret;
  25. }

代码示例来源:origin: CyclopsMC/EvilCraft

  1. if(getRemainingLife() <= 0) {
  2. this.setDead();
  3. world.removeEntity(this);

相关文章

World类方法