Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void onWorldTick(WorldTickEvent event) {
- if (event.side.isServer()) {
- World world = event.world;
- HashSet<Item> items = new HashSet<Item>();
- items.add(Items.bone);
- items.add(Items.book);
- items.add(Items.feather);
- ArrayList<EntityItem> foundEntityItems = new ArrayList<EntityItem>();
- if (!world.isRemote) {
- if (bookSpawnDelay > 0) bookSpawnDelay--;
- else {
- List<Entity> entitiesInWorld = world.loadedEntityList;
- for(Entity entityInWorld : entitiesInWorld) {
- if(entityInWorld instanceof EntityItem) {
- EntityItem entityItemInWorld = (EntityItem)entityInWorld;
- if(entityItemInWorld.getEntityItem().getItem() == Items.book) {
- items.remove(Items.book);
- AxisAlignedBB areaBound = new AxisAlignedBB(
- entityItemInWorld.posX - 3, entityItemInWorld.posY - 3, entityItemInWorld.posZ - 3,
- entityItemInWorld.posX + 3, entityItemInWorld.posY + 3, entityItemInWorld.posZ + 3
- );
- List<Entity> entitiesWithinBound = world.getEntitiesWithinAABBExcludingEntity(entityItemInWorld, areaBound);
- for(Item item : items) {
- for(Entity entityWithinBound : entitiesWithinBound) {
- if(entityWithinBound instanceof EntityItem) {
- EntityItem entityItemWithinBound = (EntityItem)entityWithinBound;
- if(entityItemWithinBound.getEntityItem().getItem() == item) {
- items.remove(item);
- foundEntityItems.add(entityItemWithinBound);
- if(items.isEmpty()) {
- for(EntityItem foundEntityItem : foundEntityItems) {
- ItemStack foundItemStack = foundEntityItem.getEntityItem();
- bookSpawnDelay += 20;
- foundItemStack.stackSize--;
- if (foundItemStack.stackSize == 0) {
- world.removeEntity(foundEntityItem);
- foundEntityItems.remove(foundEntityItem);
- }
- double x = entityItemInWorld.posX;
- double y = entityItemInWorld.posY;
- double z = entityItemInWorld.posZ;
- LogHelper.info("Items is empty!");
- if(foundEntityItems.isEmpty()) {
- LogHelper.info("Found Entity Items is empty!");
- WorldServer worldServer = (WorldServer) world;
- worldServer.spawnParticle(EnumParticleTypes.SMOKE_LARGE,
- false, x + 0.5D, y + 1.0D, z + 0.5D, 1, 0.0D,
- 0.0D, 0.0D, 0.0D, new int[0]);
- world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ARKCraftItems.info_book)));
- world.spawnEntityInWorld(new EntityItem(world, x, y, z,
- new ItemStack(ARKCraftItems.info_book)));
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement