Skip to content

Commit

Permalink
remove add prefix from registrar methods
Browse files Browse the repository at this point in the history
replace component registrar method with separate method for each position
  • Loading branch information
deirn committed Aug 24, 2024
1 parent eabb016 commit 98e1a8c
Show file tree
Hide file tree
Showing 33 changed files with 658 additions and 577 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,37 @@ public class ForgeClientPlugin implements IWailaClientPlugin {
public void register(IClientRegistrar registrar) {
FluidData.describeFluid(Fluid.class, ForgeFluidDescriptor.INSTANCE);

registrar.addToolType(ResourceLocation.withDefaultNamespace("pickaxe"), IToolType.builder()
registrar.toolType(ResourceLocation.withDefaultNamespace("pickaxe"), IToolType.builder()
.lowestTierItem(Items.WOODEN_PICKAXE)
.blockTag(BlockTags.MINEABLE_WITH_PICKAXE)
.itemPredicate(it -> it.canPerformAction(ToolActions.PICKAXE_DIG))
.build());

registrar.addToolType(ResourceLocation.withDefaultNamespace("shovel"), IToolType.builder()
registrar.toolType(ResourceLocation.withDefaultNamespace("shovel"), IToolType.builder()
.lowestTierItem(Items.WOODEN_SHOVEL)
.blockTag(BlockTags.MINEABLE_WITH_SHOVEL)
.itemPredicate(it -> it.canPerformAction(ToolActions.SHOVEL_DIG))
.build());

registrar.addToolType(ResourceLocation.withDefaultNamespace("axe"), IToolType.builder()
registrar.toolType(ResourceLocation.withDefaultNamespace("axe"), IToolType.builder()
.lowestTierItem(Items.WOODEN_AXE)
.blockTag(BlockTags.MINEABLE_WITH_AXE)
.itemPredicate(it -> it.canPerformAction(ToolActions.AXE_DIG))
.build());

registrar.addToolType(ResourceLocation.withDefaultNamespace("hoe"), IToolType.builder()
registrar.toolType(ResourceLocation.withDefaultNamespace("hoe"), IToolType.builder()
.lowestTierItem(Items.WOODEN_HOE)
.blockTag(BlockTags.MINEABLE_WITH_HOE)
.itemPredicate(it -> it.canPerformAction(ToolActions.HOE_DIG))
.build());

registrar.addToolType(ResourceLocation.withDefaultNamespace("sword"), IToolType.builder()
registrar.toolType(ResourceLocation.withDefaultNamespace("sword"), IToolType.builder()
.lowestTierItem(Items.WOODEN_SWORD)
.blockTag(ResourceLocation.parse("forge:mineable/sword"))
.itemPredicate(it -> it.canPerformAction(ToolActions.SWORD_DIG))
.build());

registrar.addToolType(ResourceLocation.withDefaultNamespace("shears"), IToolType.builder()
registrar.toolType(ResourceLocation.withDefaultNamespace("shears"), IToolType.builder()
.lowestTierItem(Items.SHEARS)
.blockPredicate(it -> it.getBlock() instanceof IForgeShearable || it.getBlock() instanceof DoublePlantBlock)
.itemPredicate(it -> it.canPerformAction(ToolActions.SHEARS_DIG))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public class ForgeCommonPlugin implements IWailaCommonPlugin {

@Override
public void register(ICommonRegistrar registrar) {
registrar.addBlockData(EnergyCapabilityProvider.INSTANCE, BlockEntity.class, 2000);
registrar.addBlockData(ItemCapabilityProvider.INSTANCE, BlockEntity.class, 2000);
registrar.addBlockData(FluidCapabilityProvider.INSTANCE, BlockEntity.class, 2000);
registrar.blockData(EnergyCapabilityProvider.INSTANCE, BlockEntity.class, 2000);
registrar.blockData(ItemCapabilityProvider.INSTANCE, BlockEntity.class, 2000);
registrar.blockData(FluidCapabilityProvider.INSTANCE, BlockEntity.class, 2000);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,37 @@ public class NeoClientPlugin implements IWailaClientPlugin {
public void register(IClientRegistrar registrar) {
FluidData.describeFluid(Fluid.class, NeoFluidDescriptor.INSTANCE);

registrar.addToolType(ResourceLocation.withDefaultNamespace("pickaxe"), IToolType.builder()
registrar.toolType(ResourceLocation.withDefaultNamespace("pickaxe"), IToolType.builder()
.lowestTierItem(Items.WOODEN_PICKAXE)
.blockTag(BlockTags.MINEABLE_WITH_PICKAXE)
.itemPredicate(it -> it.canPerformAction(ItemAbilities.PICKAXE_DIG))
.build());

registrar.addToolType(ResourceLocation.withDefaultNamespace("shovel"), IToolType.builder()
registrar.toolType(ResourceLocation.withDefaultNamespace("shovel"), IToolType.builder()
.lowestTierItem(Items.WOODEN_SHOVEL)
.blockTag(BlockTags.MINEABLE_WITH_SHOVEL)
.itemPredicate(it -> it.canPerformAction(ItemAbilities.SHOVEL_DIG))
.build());

registrar.addToolType(ResourceLocation.withDefaultNamespace("axe"), IToolType.builder()
registrar.toolType(ResourceLocation.withDefaultNamespace("axe"), IToolType.builder()
.lowestTierItem(Items.WOODEN_AXE)
.blockTag(BlockTags.MINEABLE_WITH_AXE)
.itemPredicate(it -> it.canPerformAction(ItemAbilities.AXE_DIG))
.build());

registrar.addToolType(ResourceLocation.withDefaultNamespace("hoe"), IToolType.builder()
registrar.toolType(ResourceLocation.withDefaultNamespace("hoe"), IToolType.builder()
.lowestTierItem(Items.WOODEN_HOE)
.blockTag(BlockTags.MINEABLE_WITH_HOE)
.itemPredicate(it -> it.canPerformAction(ItemAbilities.HOE_DIG))
.build());

registrar.addToolType(ResourceLocation.withDefaultNamespace("sword"), IToolType.builder()
registrar.toolType(ResourceLocation.withDefaultNamespace("sword"), IToolType.builder()
.lowestTierItem(Items.WOODEN_SWORD)
.blockTag(BlockTags.SWORD_EFFICIENT)
.itemPredicate(it -> it.canPerformAction(ItemAbilities.SWORD_DIG))
.build());

registrar.addToolType(ResourceLocation.withDefaultNamespace("shears"), IToolType.builder()
registrar.toolType(ResourceLocation.withDefaultNamespace("shears"), IToolType.builder()
.lowestTierItem(Items.SHEARS)
.blockPredicate(it -> it.getBlock() instanceof IShearable || it.getBlock() instanceof DoublePlantBlock)
.itemPredicate(it -> it.canPerformAction(ItemAbilities.SHEARS_DIG))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public class NeoCommonPlugin implements IWailaCommonPlugin {

@Override
public void register(ICommonRegistrar registrar) {
registrar.addBlockData(EnergyCapabilityProvider.INSTANCE, BlockEntity.class, 2000);
registrar.addBlockData(ItemCapabilityProvider.INSTANCE, BlockEntity.class, 2000);
registrar.addBlockData(FluidCapabilityProvider.INSTANCE, BlockEntity.class, 2000);
registrar.blockData(EnergyCapabilityProvider.INSTANCE, BlockEntity.class, 2000);
registrar.blockData(ItemCapabilityProvider.INSTANCE, BlockEntity.class, 2000);
registrar.blockData(FluidCapabilityProvider.INSTANCE, BlockEntity.class, 2000);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,38 @@ public void register(IClientRegistrar registrar) {
FluidData.describeFluid(Fluid.class, TextileFluidDescriptor.INSTANCE);
FluidData.describeCauldron(Block.class, TextileFluidDescriptor.INSTANCE);

registrar.addToolType(ResourceLocation.withDefaultNamespace("pickaxe"), IToolType.builder()
registrar.toolType(ResourceLocation.withDefaultNamespace("pickaxe"), IToolType.builder()
.lowestTierItem(Items.WOODEN_PICKAXE)
.blockTag(BlockTags.MINEABLE_WITH_PICKAXE)
.itemTag(ItemTags.PICKAXES)
.build());

registrar.addToolType(ResourceLocation.withDefaultNamespace("shovel"), IToolType.builder()
registrar.toolType(ResourceLocation.withDefaultNamespace("shovel"), IToolType.builder()
.lowestTierItem(Items.WOODEN_SHOVEL)
.blockTag(BlockTags.MINEABLE_WITH_SHOVEL)
.itemTag(ItemTags.SHOVELS)
.build());

registrar.addToolType(ResourceLocation.withDefaultNamespace("axe"), IToolType.builder()
registrar.toolType(ResourceLocation.withDefaultNamespace("axe"), IToolType.builder()
.lowestTierItem(Items.WOODEN_AXE)
.blockTag(BlockTags.MINEABLE_WITH_AXE)
.itemTag(ItemTags.AXES)
.build());

registrar.addToolType(ResourceLocation.withDefaultNamespace("hoe"), IToolType.builder()
registrar.toolType(ResourceLocation.withDefaultNamespace("hoe"), IToolType.builder()
.lowestTierItem(Items.WOODEN_HOE)
.blockTag(BlockTags.MINEABLE_WITH_HOE)
.itemTag(ItemTags.HOES)
.build());

registrar.addToolType(ResourceLocation.withDefaultNamespace("sword"), IToolType.builder()
registrar.toolType(ResourceLocation.withDefaultNamespace("sword"), IToolType.builder()
.lowestTierItem(Items.WOODEN_SWORD)
.blockTag(BlockTags.SWORD_EFFICIENT)
.itemTag(ItemTags.SWORDS)
.build());

// TODO
registrar.addToolType(ResourceLocation.withDefaultNamespace("shears"), IToolType.builder()
registrar.toolType(ResourceLocation.withDefaultNamespace("shears"), IToolType.builder()
.lowestTierItem(Items.SHEARS)
.blockPredicate(it -> /*it.is(BlockTags.SHEARS_MINEABLE) ||*/ it.getBlock() instanceof IShearable || it.getBlock() instanceof DoublePlantBlock)
.itemTag(ConventionalItemTags.SHEARS_TOOLS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public abstract class TextileCommonPlugin implements IWailaCommonPlugin {

@Override
public void register(ICommonRegistrar registrar) {
registrar.addBlockData(ItemStorageProvider.INSTANCE, BlockEntity.class, 2000);
registrar.addBlockData(FluidStorageProvider.INSTANCE, BlockEntity.class, 2000);
registrar.blockData(ItemStorageProvider.INSTANCE, BlockEntity.class, 2000);
registrar.blockData(FluidStorageProvider.INSTANCE, BlockEntity.class, 2000);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class TeamRebornEnergyCommonPlugin implements IWailaCommonPlugin {

@Override
public void register(ICommonRegistrar registrar) {
registrar.addBlockData(EnergyStorageProvider.INSTANCE, BlockEntity.class, 2000);
registrar.blockData(EnergyStorageProvider.INSTANCE, BlockEntity.class, 2000);
}

}
14 changes: 7 additions & 7 deletions src/api/java/mcp/mobius/waila/api/IBlockComponentProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public interface IBlockComponentProvider {
* @return {@code null} if this method doesn't redirect to anything,
* any result from one of {@link ITargetRedirector}'s methods otherwise
*
* @see IClientRegistrar#addRedirect(IBlockComponentProvider, Class)
* @see IClientRegistrar#redirect(IBlockComponentProvider, Class)
*/
@Nullable
@ApiStatus.Experimental
Expand All @@ -55,7 +55,7 @@ default ITargetRedirector.Result redirect(ITargetRedirector redirect, IBlockAcce
* Note that {@link IBlockAccessor#getData()} will always be empty at this time
* @param config current plugin configuration
*
* @see IClientRegistrar#addDataContext(IBlockComponentProvider, Class)
* @see IClientRegistrar#dataContext(IBlockComponentProvider, Class)
*/
default void appendDataContext(IDataWriter ctx, IBlockAccessor accessor, IPluginConfig config) {
}
Expand All @@ -73,7 +73,7 @@ default void appendDataContext(IDataWriter ctx, IBlockAccessor accessor, IPlugin
*
* @return {@code null} if override is not required, a {@link BlockState} otherwise
*
* @see IClientRegistrar#addOverride(IBlockComponentProvider, Class, int)
* @see IClientRegistrar#override(IBlockComponentProvider, Class, int)
* @see #EMPTY_BLOCK_STATE
*/
@Nullable
Expand All @@ -94,7 +94,7 @@ default BlockState getOverride(IBlockAccessor accessor, IPluginConfig config) {
*
* @return the component to render or {@code null} if this provider doesn't decide it
*
* @see IClientRegistrar#addIcon(IEntityComponentProvider, Class, int)
* @see IClientRegistrar#icon(IEntityComponentProvider, Class, int)
*/
@Nullable
default ITooltipComponent getIcon(IBlockAccessor accessor, IPluginConfig config) {
Expand All @@ -114,7 +114,7 @@ default ITooltipComponent getIcon(IBlockAccessor accessor, IPluginConfig config)
* @param accessor contains most of the relevant information about the current environment
* @param config current plugin configuration
*
* @see IClientRegistrar#addComponent(IBlockComponentProvider, TooltipPosition, Class, int)
* @see IClientRegistrar#head(IBlockComponentProvider, Class, int)
*/
default void appendHead(ITooltip tooltip, IBlockAccessor accessor, IPluginConfig config) {
}
Expand All @@ -132,7 +132,7 @@ default void appendHead(ITooltip tooltip, IBlockAccessor accessor, IPluginConfig
* @param accessor contains most of the relevant information about the current environment
* @param config current plugin configuration
*
* @see IClientRegistrar#addComponent(IBlockComponentProvider, TooltipPosition, Class, int)
* @see IClientRegistrar#body(IBlockComponentProvider, Class, int)
*/
default void appendBody(ITooltip tooltip, IBlockAccessor accessor, IPluginConfig config) {
}
Expand All @@ -150,7 +150,7 @@ default void appendBody(ITooltip tooltip, IBlockAccessor accessor, IPluginConfig
* @param accessor contains most of the relevant information about the current environment
* @param config current plugin configuration
*
* @see IClientRegistrar#addComponent(IBlockComponentProvider, TooltipPosition, Class, int)
* @see IClientRegistrar#tail(IBlockComponentProvider, Class, int)
*/
default void appendTail(ITooltip tooltip, IBlockAccessor accessor, IPluginConfig config) {
}
Expand Down
Loading

0 comments on commit 98e1a8c

Please sign in to comment.