net.minecraft.entity.item.ItemEntity Java Examples
The following examples show how to use
net.minecraft.entity.item.ItemEntity.
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: StringEventHandling.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 6 votes |
@SubscribeEvent public void entityDrops(LivingDropsEvent ev) { if (!ConfigManager.SERVER.dropStringFromSheep.get()) return; Entity entity = ev.getEntity(); if (!(entity instanceof SheepEntity)) return; Collection<ItemEntity> drops = ev.getDrops(); if (drops instanceof ImmutableList) { SurvivalistMod.LOGGER.warn("WARNING: Some mod is returning an ImmutableList, replacing drops will NOT be possible."); return; } if (rnd.nextFloat() < 0.25f) drops.add(new ItemEntity(entity.getEntityWorld(), entity.getPosX(), entity.getPosY(), entity.getPosZ(), new ItemStack(Items.STRING))); }
Example #2
Source File: ESP.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
public void onUpdate() { if (this.isToggled()) { for (Entity e: EntityUtils.getLoadedEntities()) { if (e instanceof PlayerEntity && e != mc.player && getSettings().get(0).toToggle().state) { EntityUtils.setGlowing(e, TextFormatting.RED, "players"); } if (e instanceof IMob && getSettings().get(1).toToggle().state) { EntityUtils.setGlowing(e, TextFormatting.DARK_BLUE, "mobs"); } if (EntityUtils.isAnimal(e) && getSettings().get(2).toToggle().state) { EntityUtils.setGlowing(e, TextFormatting.GREEN, "passive"); } if (e instanceof ItemEntity && getSettings().get(3).toToggle().state) { EntityUtils.setGlowing(e, TextFormatting.GOLD, "items"); } if (e instanceof EnderCrystalEntity && getSettings().get(4).toToggle().state) { EntityUtils.setGlowing(e, TextFormatting.LIGHT_PURPLE, "crystals"); } if ((e instanceof BoatEntity || e instanceof AbstractMinecartEntity) && getSettings().get(5).toToggle().state) { EntityUtils.setGlowing(e, TextFormatting.GRAY, "vehicles"); } } } }
Example #3
Source File: Tracers.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
public void onRender() { if (this.isToggled()) { final float thick = (float) getSettings().get(7).toSlider().getValue(); for (Entity e: EntityUtils.getLoadedEntities()) { Vec3d vec = e.getPositionVec(); Vec3d vec2 = new Vec3d(0, 0, 0.25).rotatePitch(-(float) Math.toRadians(mc.player.rotationPitch)) .rotateYaw(-(float) Math.toRadians(mc.player.rotationYaw)) .add(mc.player.getEyePosition(mc.getRenderPartialTicks())); if (e instanceof PlayerEntity && e != mc.player && getSettings().get(0).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f,0f,0f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f,0f,0f,thick); } if (e instanceof IMob && getSettings().get(1).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0f,0f,0f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0f,0f,0f,thick); } if (EntityUtils.isAnimal(e) && getSettings().get(2).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0f,1f,0f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0f,1f,0f,thick); } if (e instanceof ItemEntity && getSettings().get(3).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f,0.7f,0f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f,0.7f,0f,thick); } if (e instanceof EnderCrystalEntity && getSettings().get(4).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f, 0f, 1f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f, 0f, 1f,thick); } if ((e instanceof BoatEntity || e instanceof AbstractMinecartEntity) && getSettings().get(5).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0.5f, 0.5f, 0.5f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0.5f, 0.5f, 0.5f,thick); } } } }
Example #4
Source File: RenderBlockTileEntity.java From MiningGadgets with MIT License | 5 votes |
private void removeBlock() { if(world == null || world.isRemote) return; PlayerEntity player = world.getPlayerByUuid(playerUUID); if (player == null) return; int silk = 0; int fortune = 0; ItemStack tempTool = new ItemStack(ModItems.MININGGADGET.get()); // If silk is in the upgrades, apply it without a tier. if (UpgradeTools.containsActiveUpgradeFromList(gadgetUpgrades, Upgrade.SILK)) { tempTool.addEnchantment(Enchantments.SILK_TOUCH, 1); silk = 1; } // FORTUNE_1 is eval'd against the basename so this'll support all fortune upgrades if (UpgradeTools.containsActiveUpgradeFromList(gadgetUpgrades, Upgrade.FORTUNE_1)) { Optional<Upgrade> upgrade = UpgradeTools.getUpgradeFromList(gadgetUpgrades, Upgrade.FORTUNE_1); if (upgrade.isPresent()) { fortune = upgrade.get().getTier(); tempTool.addEnchantment(Enchantments.FORTUNE, fortune); } } List<ItemStack> drops = Block.getDrops(renderBlock, (ServerWorld) world, this.pos, null, player, tempTool); if ( blockAllowed ) { int exp = renderBlock.getExpDrop(world, pos, fortune, silk); boolean magnetMode = (UpgradeTools.containsActiveUpgradeFromList(gadgetUpgrades, Upgrade.MAGNET)); for (ItemStack drop : drops) { if (drop != null) { if (magnetMode) { int wasPickedUp = ForgeEventFactory.onItemPickup(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), drop), player); // 1 = someone allowed the event meaning it's handled, // -1 = someone blocked the event and thus we shouldn't drop it nor insert it // 0 = no body captured the event and we should handle it by hand. if( wasPickedUp == 0 ) { if (!player.addItemStackToInventory(drop)) Block.spawnAsEntity(world, pos, drop); } } else { Block.spawnAsEntity(world, pos, drop); } } } if (magnetMode) { if (exp > 0) player.giveExperiencePoints(exp); } else { if (exp > 0) renderBlock.getBlock().dropXpOnBlockBreak(world, pos, exp); } renderBlock.spawnAdditionalDrops(world, pos, tempTool); // Fixes silver fish basically... } world.removeTileEntity(this.pos); world.setBlockState(this.pos, Blocks.AIR.getDefaultState()); // Add to the break stats player.addStat(Stats.BLOCK_MINED.get(renderBlock.getBlock())); // Handle special cases if(SpecialBlockActions.getRegister().containsKey(renderBlock.getBlock())) SpecialBlockActions.getRegister().get(renderBlock.getBlock()).accept(world, pos, renderBlock); }
Example #5
Source File: ItemUtils.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
/** * Drops an item in the world at the given BlockPos * * @param world World to drop the item. * @param pos Location to drop item. * @param stack ItemStack to drop. * @param velocity The velocity to add. */ public static void dropItem(World world, BlockPos pos, @Nonnull ItemStack stack, double velocity) { double xVelocity = world.rand.nextFloat() * velocity + (1.0D - velocity) * 0.5D; double yVelocity = world.rand.nextFloat() * velocity + (1.0D - velocity) * 0.5D; double zVelocity = world.rand.nextFloat() * velocity + (1.0D - velocity) * 0.5D; ItemEntity entityItem = new ItemEntity(world, pos.getX() + xVelocity, pos.getY() + yVelocity, pos.getZ() + zVelocity, stack); entityItem.setPickupDelay(10); world.addEntity(entityItem); }
Example #6
Source File: ItemUtils.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
/** * Drops an item with basic default random velocity. */ public static void dropItem(ItemStack stack, World world, Vector3 dropLocation) { ItemEntity item = new ItemEntity(world, dropLocation.x, dropLocation.y, dropLocation.z, stack); item.setMotion(world.rand.nextGaussian() * 0.05, world.rand.nextGaussian() * 0.05 + 0.2F, world.rand.nextGaussian() * 0.05); world.addEntity(item); }
Example #7
Source File: ItemUtils.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 3 votes |
/** * Ejects an item with .3 velocity in the given direction. * * @param world World to spawn the item. * @param pos Location for item to spawn. * @param stack Stack to spawn. * @param dir Direction to shoot. */ public static void ejectItem(World world, BlockPos pos, @Nonnull ItemStack stack, Direction dir) { pos.offset(dir); ItemEntity entity = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, stack); entity.setMotion(new Vec3d(dir.getDirectionVec()).scale(0.3)); entity.setPickupDelay(10); world.addEntity(entity); }