Skip to content

Commit 84a08c3

Browse files
committed
Phantom ink can be applied to corporea cubes to hide the item count
1 parent 7465f12 commit 84a08c3

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

Xplat/src/main/java/vazkii/botania/client/render/block_entity/CorporeaCrystalCubeBlockEntityRenderer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Making the divider smaller, slows down the cube bobbing (you can multiply instea
8484
ms.popPose();
8585
}
8686

87-
if (!stack.isEmpty() && cube != null) {
87+
if (!stack.isEmpty() && cube != null && !cube.hideCount) {
8888
int count = cube.getItemCount();
8989
String countStr = String.valueOf(count);
9090
int color = 0xFFFFFF;

Xplat/src/main/java/vazkii/botania/common/block/block_entity/BlockEntityConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public final class BlockEntityConstants {
1717
);
1818

1919
public static final Set<BlockEntityType<?>> SELF_PHANTOM_INKABLE_BES = ImmutableSet.of(
20-
BotaniaBlockEntities.LIGHT_RELAY, BotaniaBlockEntities.PLATFORM
20+
BotaniaBlockEntities.LIGHT_RELAY, BotaniaBlockEntities.PLATFORM, BotaniaBlockEntities.CORPOREA_CRYSTAL_CUBE
2121
);
2222

2323
public static final Set<BlockEntityType<?>> SELF_MANA_TRIGGER_BES = ImmutableSet.of(

Xplat/src/main/java/vazkii/botania/common/block/block_entity/corporea/CorporeaCrystalCubeBlockEntity.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,34 @@
2424
import net.minecraft.world.level.Level;
2525
import net.minecraft.world.level.block.Block;
2626
import net.minecraft.world.level.block.state.BlockState;
27+
import net.minecraft.world.level.gameevent.GameEvent;
2728

2829
import org.jetbrains.annotations.Nullable;
2930

31+
import vazkii.botania.api.block.PhantomInkableBlock;
3032
import vazkii.botania.api.block.Wandable;
3133
import vazkii.botania.api.corporea.CorporeaHelper;
3234
import vazkii.botania.api.corporea.CorporeaRequestMatcher;
3335
import vazkii.botania.api.corporea.CorporeaRequestor;
3436
import vazkii.botania.api.corporea.CorporeaSpark;
37+
import vazkii.botania.api.internal.VanillaPacketDispatcher;
3538
import vazkii.botania.client.core.helper.RenderHelper;
3639
import vazkii.botania.common.block.block_entity.BotaniaBlockEntities;
3740

3841
import 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();

web/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ of time the maintainers are able to spend on this effort. For the time being, up
2828
distributed across the available slots, rather than putting the entire stack into a single slot
2929
* Change: Horn/Drum of the Wild also breaks Biomes O' Plenty's high grass by default
3030
* Add: Dispensers can now apply phantom ink to blocks (entities like sparks are not yet supported)
31+
* Add: Phantom ink can be applied to corporea cubes to hide the item count
3132
* Fix: Dandelifeon sometimes generated a randomly greater amount of mana than intended when on enchanted soil
3233
* Fix: Trinkets could not be equipped via right-click (Abbie)
3334
* Fix: Rod of the Highlands now includes placement sound and particles if not used on another solid block

0 commit comments

Comments
 (0)