Interface IBlockTrackEntry
- All Known Implementing Classes:
BlockTrackEntryEndPortalFrame,BlockTrackEntryEnergy,BlockTrackEntryFluid,BlockTrackEntryHackable,BlockTrackEntryInventory,BlockTrackEntryMisc,BlockTrackEntryMobSpawner,BlockTrackEntryThaumcraft
public interface IBlockTrackEntry
Implement this interface and register it with
IClientArmorRegistry.registerBlockTrackEntry(ResourceLocation, Supplier).
Your implementation must provide a no-parameter constructor.
These trackers are singleton objects, so any instance data is in effect shared amongst all block positions for which the tracker is applicable (in most cases, instance data should not be necessary).
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddInformation(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.entity.BlockEntity te, net.minecraft.core.Direction face, List<net.minecraft.network.chat.Component> infoList) This method is called each client tick to retrieve the block's additional information.net.minecraft.resources.ResourceLocationReturn a unique identifier for this block track entry.List<net.minecraft.core.BlockPos>getServerUpdatePositions(net.minecraft.world.level.block.entity.BlockEntity te) This method controls whether to send server update requests, at 3 second intervals while the player is looking at the block.static booleanhasCapabilityOnAnyFace(net.minecraftforge.common.capabilities.ICapabilityProvider provider, net.minecraftforge.common.capabilities.Capability<?> cap) Convenience method: check if the given capability provider provides the given capability on any block face.booleanshouldTrackWithThisEntry(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.block.entity.BlockEntity te) This method should return true if the block at the coordinate checked is one that should be tracked.intThe return of this method defines at how many tracked blocks of this type the HUD should stop displaying text at the tracked blocks of this type.
-
Method Details
-
shouldTrackWithThisEntry
boolean shouldTrackWithThisEntry(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.block.entity.BlockEntity te) This method should return true if the block at the coordinate checked is one that should be tracked. This is often as simple as just checking the block type, but could be more complex for some trackers, i.e. checking if a certain capability exists on the block entity. This gets called a lot when the block tracker is active, so keep it as simple as possible.- Parameters:
world- the worldpos- the blockposstate- blockstate at this blockposte- the block entity at this blockpos (may be null)- Returns:
- true if this block should be tracked by this BlockTrackEntry
-
getServerUpdatePositions
List<net.minecraft.core.BlockPos> getServerUpdatePositions(@Nullable net.minecraft.world.level.block.entity.BlockEntity te) This method controls whether to send server update requests, at 3 second intervals while the player is looking at the block. This is specifically aimed at Block Entities, as the server will send an NBT update packet in response. Return an empty list if no updates are needed, otherwise a (possibly immutable) list of the block positions for which updates should be requested (in most cases, only the BE's own block pos, but potentially others for multiblocks like the vanilla double chest)- Parameters:
te- the block entity at the currently checked location, may be null- Returns:
- a list of the block positions for which update request packets should be sent
-
spamThreshold
int spamThreshold()The return of this method defines at how many tracked blocks of this type the HUD should stop displaying text at the tracked blocks of this type.- Returns:
- amount of blocks the HUD should stop displaying the block info.
-
addInformation
void addInformation(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.entity.BlockEntity te, net.minecraft.core.Direction face, List<net.minecraft.network.chat.Component> infoList) This method is called each client tick to retrieve the block's additional information. The method behaves much the same asItem.appendHoverText(ItemStack, Level, List, TooltipFlag). This method is only called ifshouldTrackWithThisEntry(BlockGetter, BlockPos, BlockState, BlockEntity)returned true, and the player is currently focused on the block.- Parameters:
world- the worldpos- the blockposte- the block entity at this blockpos (may be null)face- the block face the player is looking at (null if player is not looking directly at the block)infoList- list of text to add information to
-
getEntryID
@Nonnull net.minecraft.resources.ResourceLocation getEntryID()Return a unique identifier for this block track entry. This is also used for translation key and keybind naming purposes; seeIArmorUpgradeHandler.getStringKey(ResourceLocation)- Returns:
- the ID of this entry
-
hasCapabilityOnAnyFace
static boolean hasCapabilityOnAnyFace(net.minecraftforge.common.capabilities.ICapabilityProvider provider, net.minecraftforge.common.capabilities.Capability<?> cap) Convenience method: check if the given capability provider provides the given capability on any block face.- Parameters:
provider- the capability providercap- the capability- Returns:
- true if the provider provides the capability on any face, including the null "face"
-