001 package org.bukkit.material; 002 003 import org.bukkit.Material; 004 005 public class Cake extends MaterialData { 006 public Cake() { 007 super(Material.CAKE_BLOCK); 008 } 009 010 /** 011 * 012 * @deprecated Magic value 013 */ 014 @Deprecated 015 public Cake(int type) { 016 super(type); 017 } 018 019 public Cake(Material type) { 020 super(type); 021 } 022 023 /** 024 * 025 * @deprecated Magic value 026 */ 027 @Deprecated 028 public Cake(int type, byte data) { 029 super(type, data); 030 } 031 032 /** 033 * 034 * @deprecated Magic value 035 */ 036 @Deprecated 037 public Cake(Material type, byte data) { 038 super(type, data); 039 } 040 041 /** 042 * Gets the number of slices eaten from this cake 043 * 044 * @return The number of slices eaten 045 */ 046 public int getSlicesEaten() { 047 return getData(); 048 } 049 050 /** 051 * Gets the number of slices remaining on this cake 052 * 053 * @return The number of slices remaining 054 */ 055 public int getSlicesRemaining() { 056 return 6 - getData(); 057 } 058 059 /** 060 * Sets the number of slices eaten from this cake 061 * 062 * @param n The number of slices eaten 063 */ 064 public void setSlicesEaten(int n) { 065 if (n < 6) { 066 setData((byte) n); 067 } // TODO: else destroy the block? Probably not possible though 068 } 069 070 /** 071 * Sets the number of slices remaining on this cake 072 * 073 * @param n The number of slices remaining 074 */ 075 public void setSlicesRemaining(int n) { 076 if (n > 6) { 077 n = 6; 078 } 079 setData((byte) (6 - n)); 080 } 081 082 @Override 083 public String toString() { 084 return super.toString() + " " + getSlicesEaten() + "/" + getSlicesRemaining() + " slices eaten/remaining"; 085 } 086 087 @Override 088 public Cake clone() { 089 return (Cake) super.clone(); 090 } 091 }