Advertisement
Camellias_

Untitled

Aug 1st, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.61 KB | None | 0 0
  1.     @Override
  2.     public void update()
  3.     {
  4.         if(isCasting)
  5.         {
  6.             if(!isValidStructure()) stopCasting(true);
  7.            
  8.             //TODO Filling chunk
  9.             if(isFillingChunk)
  10.             {
  11.                 Chunk chunk = world.getChunk(pos);
  12.                
  13.                 for(int i = 0; i < 20; i++)
  14.                 {
  15.                     double posX = getPos().getX() + 0.5D;
  16.                     double posY = getPos().getY() + 1D;
  17.                     double posZ = getPos().getZ() + 0.5D;
  18.                     double motionX = ((world.rand.nextInt(8) - 4)) * 0.01D;
  19.                     double motionY = (world.rand.nextInt(3) + 3) * 0.1D;
  20.                     double motionZ = ((world.rand.nextInt(8) - 4)) * 0.01D;
  21.                    
  22.                     if(world.isRemote)
  23.                     {
  24.                         VoidEssenceParticle essence = new VoidEssenceParticle(world, posX, posY, posZ, motionX, motionY, motionZ);
  25.                         spawnParticle.addEffect(essence);
  26.                     }
  27.                 }
  28.                
  29.                 if(chunk.hasCapability(EssenceProvider.essenceCapability, null))
  30.                 {
  31.                     IEssence cap = chunk.getCapability(EssenceProvider.essenceCapability, null);
  32.                    
  33.                     if(cap.getEssence() < 1500 && voidEssence > 0)
  34.                     {
  35.                         voidEssence--;
  36.                         cap.setEssence(cap.getEssence() + 1);
  37.                     }
  38.                     else
  39.                     {
  40.                         isCasting = false;
  41.                         isFillingChunk = false;
  42.                     }
  43.                 }
  44.             }
  45.            
  46.             //TODO Crafting item/spell
  47.             if(isCraftingItem || isCraftingSpell)
  48.             {
  49.                 if(ticks <= voidEssence && ticks > 0)
  50.                 {
  51.                     ticks--;
  52.                     voidEssence--;
  53.                    
  54.                     Iterable<MutableBlockPos> blocksWithin = BlockPos.getAllInBoxMutable(pos.getX() - 3, pos.getY(), pos.getZ() - 3, pos.getX() + 3, pos.getY(), pos.getZ() + 3);
  55.                    
  56.                     for(MutableBlockPos allBlockPos : blocksWithin)
  57.                     {
  58.                         if(world.getTileEntity(allBlockPos) instanceof TileWhitewoodPedestal)
  59.                         {
  60.                             TileWhitewoodPedestal pedestal = (TileWhitewoodPedestal) world.getTileEntity(allBlockPos);
  61.                            
  62.                             double posX = (pedestal.getPos().getX() + 0.5D);
  63.                             double posY = pedestal.getPos().getY() + 1D;
  64.                             double posZ = (pedestal.getPos().getZ() + 0.5D);
  65.                             double motionX = ((pos.getX() + 0.5D) - posX) * 0.06D;
  66.                             double motionY = ((pos.getY() + 4D) - posY) * 0.06D;
  67.                             double motionZ = ((pos.getZ() + 0.5D) - posZ) * 0.06D;
  68.                            
  69.                             if(world.isRemote)
  70.                             {
  71.                                 VoidEssenceParticle essence = new VoidEssenceParticle(world, posX, posY, posZ, motionX, motionY, motionZ);
  72.                                 spawnParticle.addEffect(essence);
  73.                             }
  74.                         }
  75.                     }
  76.                 }
  77.                 else if(ticks == 0)
  78.                 {
  79.                     stopCasting(false);
  80.                 }
  81.             }
  82.            
  83.             //TODO Filling altar
  84.             if(isInputEssence)
  85.             {
  86.                 if(ticks < 200)
  87.                 {
  88.                     ticks++;
  89.                    
  90.                     Iterable<MutableBlockPos> blocksWithin = BlockPos.getAllInBoxMutable(pos.getX() - 3, pos.getY(), pos.getZ() - 3, pos.getX() + 3, pos.getY(), pos.getZ() + 3);
  91.                    
  92.                     for(MutableBlockPos allBlockPos : blocksWithin)
  93.                     {
  94.                         if(world.getTileEntity(allBlockPos) instanceof TileWhitewoodPedestal)
  95.                         {
  96.                             TileWhitewoodPedestal pedestal = (TileWhitewoodPedestal) world.getTileEntity(allBlockPos);
  97.                            
  98.                             if(!pedestal.handler.getStackInSlot(0).isEmpty())
  99.                             {
  100.                                 double posX = (pedestal.getPos().getX() + 0.5D);
  101.                                 double posY = pedestal.getPos().getY() + 1D;
  102.                                 double posZ = (pedestal.getPos().getZ() + 0.5D);
  103.                                 double motionX = ((pos.getX() + 0.5D) - posX) * 0.06D;
  104.                                 double motionZ = ((pos.getZ() + 0.5D) - posZ) * 0.06D;
  105.                                
  106.                                 if(world.isRemote)
  107.                                 {
  108.                                     VoidEssenceParticle essence = new VoidEssenceParticle(world, posX, posY, posZ, motionX, 0D, motionZ);
  109.                                     spawnParticle.addEffect(essence);
  110.                                 }
  111.                             }
  112.                         }
  113.                     }
  114.                 }
  115.                 else if(ticks >= 200)
  116.                 {
  117.                     ticks = 0;
  118.                     stopCasting(false);
  119.                 }
  120.             }
  121.         }
  122.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement