コード例 #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 boolean activate(EntityPlayer player, EnumFacing side) {
   ClayState state = getState();
   if (state == ClayState.WET) {
     touch();
   }
   ItemStack held = player.getCurrentEquippedItem();
   if (held == null) {
     return false;
   }
   Item heldId = held.getItem();
   boolean creative = player.capabilities.isCreativeMode;
   if (heldId == Items.blaze_powder && state != ClayState.HIGHFIRED) {
     PlayerUtil.cheatDecr(player, held);
     // TODO: Untested. Blaze powder should just finish the thing. Should also play a noise + emit
     // particles.
     if (totalHeat < bisqueHeat) {
       totalHeat = bisqueHeat;
     } else if (totalHeat < highfireHeat) {
       totalHeat = highfireHeat;
     }
     return true;
   }
   if (heldId == Items.water_bucket && state == ClayState.DRY) {
     lastTouched = 0;
     if (creative) {
       return true;
     }
     int ci = player.inventory.currentItem;
     player.inventory.mainInventory[ci] = new ItemStack(Items.bucket);
     return true;
   }
   if (heldId == woolItem) {
     lastTouched = dryTime + 1;
     return true;
   }
   if (held.getItem() != Items.clay_ball || held.stackSize == 0) {
     return false;
   }
   if (!creative && state != ClayState.WET) {
     new Notice(this, "Not wet").send(player);
     return false;
   }
   if (!creative) {
     held.stackSize--;
   }
   if (player.worldObj.isRemote) {
     // Let the server tell us the results
     return true;
   }
   if (parts.size() >= MAX_PARTS) {
     new Notice(this, "Too complex").send(player);
     held.stackSize++;
     return false;
   }
   ClayLump toAdd = addLump();
   MovingObjectPosition hit = ItemSculptingTool.doRayTrace(player);
   if (hit == null || hit.subHit == -1) {
     return true;
   }
   ClayLump against = parts.get(hit.subHit);
   ClayLump extrusion = extrudeLump(against, hit.sideHit);
   if (isValidLump(extrusion)) {
     changeLump(parts.size() - 1, extrusion);
   } else {
     // TODO: Sometimes it fails when it shouldn't.
   }
   return true;
 }