2424import net .minecraft .world .level .Level ;
2525import net .minecraft .world .level .block .Block ;
2626import net .minecraft .world .level .block .state .BlockState ;
27+ import net .minecraft .world .level .gameevent .GameEvent ;
2728
2829import org .jetbrains .annotations .Nullable ;
2930
31+ import vazkii .botania .api .block .PhantomInkableBlock ;
3032import vazkii .botania .api .block .Wandable ;
3133import vazkii .botania .api .corporea .CorporeaHelper ;
3234import vazkii .botania .api .corporea .CorporeaRequestMatcher ;
3335import vazkii .botania .api .corporea .CorporeaRequestor ;
3436import vazkii .botania .api .corporea .CorporeaSpark ;
37+ import vazkii .botania .api .internal .VanillaPacketDispatcher ;
3538import vazkii .botania .client .core .helper .RenderHelper ;
3639import vazkii .botania .common .block .block_entity .BotaniaBlockEntities ;
3740
3841import java .util .List ;
3942
40- public class CorporeaCrystalCubeBlockEntity extends BaseCorporeaBlockEntity implements CorporeaRequestor , Wandable {
43+ public class CorporeaCrystalCubeBlockEntity extends BaseCorporeaBlockEntity implements CorporeaRequestor , Wandable , PhantomInkableBlock {
4144 private static final String TAG_REQUEST_TARGET = "requestTarget" ;
4245 private static final String TAG_ITEM_COUNT = "itemCount" ;
4346 private static final String TAG_LOCK = "lock" ;
47+ private static final String TAG_HIDE_COUNT = "hideCount" ;
4448
4549 private ItemStack requestTarget = ItemStack .EMPTY ;
4650 private int itemCount = 0 ;
4751 private int ticks = 0 ;
4852 private int compValue = 0 ;
4953 public boolean locked = false ;
54+ public boolean hideCount = false ;
5055
5156 public CorporeaCrystalCubeBlockEntity (BlockPos pos , BlockState state ) {
5257 super (BotaniaBlockEntities .CORPOREA_CRYSTAL_CUBE , pos , state );
@@ -126,6 +131,7 @@ public void writePacketNBT(CompoundTag tag) {
126131 tag .put (TAG_REQUEST_TARGET , cmp );
127132 tag .putInt (TAG_ITEM_COUNT , itemCount );
128133 tag .putBoolean (TAG_LOCK , locked );
134+ tag .putBoolean (TAG_HIDE_COUNT , hideCount );
129135 }
130136
131137 @ Override
@@ -135,6 +141,7 @@ public void readPacketNBT(CompoundTag tag) {
135141 requestTarget = ItemStack .of (cmp );
136142 setCount (tag .getInt (TAG_ITEM_COUNT ));
137143 locked = tag .getBoolean (TAG_LOCK );
144+ hideCount = tag .getBoolean (TAG_HIDE_COUNT );
138145 }
139146
140147 public int getComparatorValue () {
@@ -173,6 +180,23 @@ public boolean onUsedByWand(@Nullable Player player, ItemStack stack, Direction
173180 return false ;
174181 }
175182
183+ @ Override
184+ public boolean onPhantomInked (@ Nullable Player player , ItemStack stack , Direction side ) {
185+ if (hideCount ) {
186+ return false ;
187+ }
188+ if (!level .isClientSide ()) {
189+ if (player == null || !player .getAbilities ().instabuild ) {
190+ stack .shrink (1 );
191+ }
192+ hideCount = true ;
193+ setChanged ();
194+ level .gameEvent (null , GameEvent .BLOCK_CHANGE , getBlockPos ());
195+ VanillaPacketDispatcher .dispatchTEToNearbyPlayers (this );
196+ }
197+ return true ;
198+ }
199+
176200 @ Override
177201 public void setChanged () {
178202 super .setChanged ();
0 commit comments