Java Code Examples for net.minecraft.entity.item.EntityItem#cannotPickup()
The following examples show how to use
net.minecraft.entity.item.EntityItem#cannotPickup() .
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: MetaTileEntityItemCollector.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
protected void moveItemsInEffectRange() { List<EntityItem> itemsInRange = getWorld().getEntitiesWithinAABB(EntityItem.class, areaBoundingBox); for (EntityItem entityItem : itemsInRange) { double distanceX = (areaCenterPos.getX() + 0.5) - entityItem.posX; double distanceZ = (areaCenterPos.getZ() + 0.5) - entityItem.posZ; double distance = MathHelper.sqrt(distanceX * distanceX + distanceZ * distanceZ); if(!itemFilter.testItemStack(entityItem.getItem())) { continue; } if (distance >= 0.7) { if(!entityItem.cannotPickup()) { double directionX = distanceX / distance; double directionZ = distanceZ / distance; entityItem.motionX = directionX * MOTION_MULTIPLIER * getTier(); entityItem.motionZ = directionZ * MOTION_MULTIPLIER * getTier(); entityItem.velocityChanged = true; entityItem.setPickupDelay(1); } } else { ItemStack itemStack = entityItem.getItem(); ItemStack remainder = ItemHandlerHelper.insertItemStacked(exportItems, itemStack, false); if (remainder.isEmpty()) { entityItem.setDead(); } else if (itemStack.getCount() > remainder.getCount()) { entityItem.setItem(remainder); } } } if (getTimer() % 5 == 0) { pushItemsIntoNearbyHandlers(getFrontFacing()); } }
Example 2
Source File: MagnetModeHandler.java From NotEnoughItems with MIT License | 4 votes |
@SubscribeEvent @SideOnly (Side.CLIENT) public void clientTickEvent(TickEvent.ClientTickEvent event) { if (event.phase == Phase.END || Minecraft.getMinecraft().world == null) { return; } if (!NEIClientConfig.isMagnetModeEnabled()) { return; } EntityPlayer player = Minecraft.getMinecraft().player; Iterator<EntityItem> iterator = clientMagnetItems.iterator(); while (iterator.hasNext()) { EntityItem item = iterator.next(); if (item.cannotPickup()) { continue; } if (item.isDead) { iterator.remove(); } if (item.getEntityData().getBoolean("PreventRemoteMovement")) { continue; } if (!NEIClientUtils.canItemFitInInventory(player, item.getItem())) { continue; } double dx = player.posX - item.posX; double dy = player.posY + player.getEyeHeight() - item.posY; double dz = player.posZ - item.posZ; double absxz = Math.sqrt(dx * dx + dz * dz); double absy = Math.abs(dy); if (absxz > DISTANCE_XZ || absy > DISTANCE_Y) { continue; } if (absxz > 1) { dx /= absxz; dz /= absxz; } if (absy > 1) { dy /= absy; } double vx = item.motionX + SPEED_XZ * dx; double vy = item.motionY + SPEED_Y * dy; double vz = item.motionZ + SPEED_XZ * dz; double absvxz = Math.sqrt(vx * vx + vz * vz); double absvy = Math.abs(vy); double rationspeedxz = absvxz / MAX_SPEED_XZ; if (rationspeedxz > 1) { vx /= rationspeedxz; vz /= rationspeedxz; } double rationspeedy = absvy / MAX_SPEED_Y; if (rationspeedy > 1) { vy /= rationspeedy; } if (absvxz < 0.2 && absxz < 0.2) { item.setDead(); } item.setVelocity(vx, vy, vz); } }
Example 3
Source File: ServerHandler.java From NotEnoughItems with MIT License | 4 votes |
private void updateMagneticPlayer(EntityPlayerMP player, PlayerSave save) { if (!save.isActionEnabled("magnet") || player.isDead) return; float distancexz = 16; float distancey = 8; double maxspeedxz = 0.5; double maxspeedy = 0.5; double speedxz = 0.05; double speedy = 0.07; List<EntityItem> items = player.worldObj.getEntitiesWithinAABB(EntityItem.class, player.getEntityBoundingBox().expand(distancexz, distancey, distancexz)); for (EntityItem item : items) { if (item.cannotPickup()) continue; if (!NEIServerUtils.canItemFitInInventory(player, item.getEntityItem())) continue; if (save.magneticItems.add(item)) NEISPH.sendAddMagneticItemTo(player, item); double dx = player.posX - item.posX; double dy = player.posY + player.getEyeHeight() - item.posY; double dz = player.posZ - item.posZ; double absxz = Math.sqrt(dx * dx + dz * dz); double absy = Math.abs(dy); if (absxz > distancexz) continue; if (absxz < 1) item.onCollideWithPlayer(player); if (absxz > 1) { dx /= absxz; dz /= absxz; } if (absy > 1) dy /= absy; double vx = item.motionX + speedxz * dx; double vy = item.motionY + speedy * dy; double vz = item.motionZ + speedxz * dz; double absvxz = Math.sqrt(vx * vx + vz * vz); double absvy = Math.abs(vy); double rationspeedxz = absvxz / maxspeedxz; if (rationspeedxz > 1) { vx /= rationspeedxz; vz /= rationspeedxz; } double rationspeedy = absvy / maxspeedy; if (absvy > 1) vy /= rationspeedy; item.motionX = vx; item.motionY = vy; item.motionZ = vz; } }
Example 4
Source File: ClientHandler.java From NotEnoughItems with MIT License | 4 votes |
private void updateMagnetMode(World world, EntityPlayerSP player) { if (!NEIClientConfig.getMagnetMode()) return; float distancexz = 16; float distancey = 8; double maxspeedxz = 0.5; double maxspeedy = 0.5; double speedxz = 0.05; double speedy = 0.07; for (Iterator<EntityItem> iterator = SMPmagneticItems.iterator(); iterator.hasNext(); ) { EntityItem item = iterator.next(); if (item.cannotPickup()) continue; if (item.isDead) iterator.remove(); if (!NEIClientUtils.canItemFitInInventory(player, item.getEntityItem())) continue; double dx = player.posX - item.posX; double dy = player.posY + player.getEyeHeight() - item.posY; double dz = player.posZ - item.posZ; double absxz = Math.sqrt(dx * dx + dz * dz); double absy = Math.abs(dy); if (absxz > distancexz || absy > distancey) continue; if (absxz > 1) { dx /= absxz; dz /= absxz; } if (absy > 1) { dy /= absy; } double vx = item.motionX + speedxz * dx; double vy = item.motionY + speedy * dy; double vz = item.motionZ + speedxz * dz; double absvxz = Math.sqrt(vx * vx + vz * vz); double absvy = Math.abs(vy); double rationspeedxz = absvxz / maxspeedxz; if (rationspeedxz > 1) { vx /= rationspeedxz; vz /= rationspeedxz; } double rationspeedy = absvy / maxspeedy; if (rationspeedy > 1) vy /= rationspeedy; if (absvxz < 0.2 && absxz < 0.2) item.setDead(); item.setVelocity(vx, vy, vz); } }