Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
157 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/slimeknights/tmechworks/integration/waila/GenericTileDataProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package slimeknights.tmechworks.integration.waila; | ||
|
||
import mcp.mobius.waila.api.IComponentProvider; | ||
import mcp.mobius.waila.api.IDataAccessor; | ||
import mcp.mobius.waila.api.IPluginConfig; | ||
import mcp.mobius.waila.api.IServerDataProvider; | ||
import net.minecraft.entity.player.ServerPlayerEntity; | ||
import net.minecraft.nbt.CompoundNBT; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.text.ITextComponent; | ||
import net.minecraft.world.World; | ||
|
||
import java.util.List; | ||
|
||
public class GenericTileDataProvider implements IServerDataProvider<TileEntity>, IComponentProvider { | ||
public static final GenericTileDataProvider INSTANCE = new GenericTileDataProvider(); | ||
|
||
@Override | ||
public void appendServerData(CompoundNBT nbt, ServerPlayerEntity player, World world, TileEntity tile) { | ||
if(tile instanceof IInformationProvider) | ||
((IInformationProvider)tile).syncInformation(nbt, player); | ||
} | ||
|
||
@Override | ||
public void appendHead(List<ITextComponent> tooltip, IDataAccessor accessor, IPluginConfig config) { | ||
call(tooltip, accessor, IInformationProvider.InformationType.HEAD); | ||
} | ||
|
||
@Override | ||
public void appendBody(List<ITextComponent> tooltip, IDataAccessor accessor, IPluginConfig config) { | ||
call(tooltip, accessor, IInformationProvider.InformationType.BODY); | ||
} | ||
|
||
@Override | ||
public void appendTail(List<ITextComponent> tooltip, IDataAccessor accessor, IPluginConfig config) { | ||
call(tooltip, accessor, IInformationProvider.InformationType.TAIL); | ||
} | ||
|
||
private void call(List<ITextComponent> tooltip, IDataAccessor accessor, IInformationProvider.InformationType type) { | ||
TileEntity te = accessor.getTileEntity(); | ||
|
||
if(te instanceof IInformationProvider) | ||
((IInformationProvider)te).getInformation(tooltip, type, accessor.getServerData(), accessor.getPlayer()); | ||
} | ||
} |
30 changes: 29 additions & 1 deletion
30
src/main/java/slimeknights/tmechworks/integration/waila/IInformationProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/slimeknights/tmechworks/integration/waila/WailaIntegration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package slimeknights.tmechworks.integration.waila; | ||
|
||
import mcp.mobius.waila.api.IRegistrar; | ||
import mcp.mobius.waila.api.IWailaPlugin; | ||
import mcp.mobius.waila.api.TooltipPosition; | ||
import mcp.mobius.waila.api.WailaPlugin; | ||
import net.minecraft.util.ResourceLocation; | ||
import slimeknights.tmechworks.library.Util; | ||
|
||
@WailaPlugin | ||
public class WailaIntegration implements IWailaPlugin { | ||
private static final ResourceLocation CONFIG_REDSTONE_MACHINE = Util.getResource("redstone_machine"); | ||
|
||
@Override | ||
public void register(IRegistrar registrar) { | ||
registrar.addConfig(CONFIG_REDSTONE_MACHINE, true); | ||
|
||
registrar.registerComponentProvider(GenericTileDataProvider.INSTANCE, TooltipPosition.HEAD, IInformationProvider.class); | ||
registrar.registerComponentProvider(GenericTileDataProvider.INSTANCE, TooltipPosition.BODY, IInformationProvider.class); | ||
registrar.registerComponentProvider(GenericTileDataProvider.INSTANCE, TooltipPosition.TAIL, IInformationProvider.class); | ||
registrar.registerBlockDataProvider(GenericTileDataProvider.INSTANCE, IInformationProvider.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters