コード例 #1
0
 @Override
 protected boolean removedByPlayer(EntityPlayer player, boolean willHarvest) {
   if (player.worldObj.isRemote) {
     return false;
   }
   MovingObjectPosition hit = ItemSculptingTool.doRayTrace(player);
   if (hit == null || hit.subHit == -1 || parts.size() < 1) {
     return super.removedByPlayer(player, willHarvest);
   }
   Coord here = getCoord();
   ClayState state = getState();
   // If it's solid, break it.
   // If we're sneaking & creative, break it
   boolean shouldDestroy = player.isSneaking() || parts.size() == 1;
   if (player.capabilities.isCreativeMode) {
     if (shouldDestroy) {
       return super.removedByPlayer(player, willHarvest);
     } else {
       removeLump(hit.subHit);
       return true;
     }
   }
   shouldDestroy |= state != ClayState.WET;
   if (shouldDestroy) {
     InvUtil.spawnItemStack(here, getItem());
     here.setAir();
   } else {
     removeLump(hit.subHit);
     InvUtil.spawnItemStack(here, new ItemStack(Items.clay_ball));
   }
   return false;
 }
コード例 #2
0
 @Override
 public void update() {
   if (worldObj.isRemote) {
     return;
   }
   // TODO: Ugh, laaaame. Schedule a block update?
   if (!partsValidated) {
     partsValidated = true;
     Iterator<ClayLump> it = parts.iterator();
     while (it.hasNext()) {
       ClayLump lump = it.next();
       if (!isValidLump(lump)) {
         if (parts.size() == 1) {
           lump.asDefault();
         } else {
           it.remove();
           InvUtil.spawnItemStack(getCoord(), new ItemStack(Items.clay_ball));
         }
       }
     }
   }
   if (getState() == ClayState.WET) {
     if (!worldObj.isRaining()) {
       lastTouched++;
     }
     if (totalHeat > 0) {
       totalHeat--;
       lastTouched++;
     }
   }
   if (getState() != lastState) {
     lastState = getState();
     broadcastMessage(null, SculptState, lastState.ordinal());
   }
 }