-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Added support for The One Probe and HWYLA.
-Fixed sync bug with tiny transmitters and receivers where a channel change would not sync to client if change did not result in an output change.
- Loading branch information
Showing
8 changed files
with
148 additions
and
5 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
13 changes: 13 additions & 0 deletions
13
src/main/java/com/dannyandson/rangedwirelessredstone/compat/CompatHandler.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,13 @@ | ||
package com.dannyandson.rangedwirelessredstone.compat; | ||
|
||
import com.dannyandson.rangedwirelessredstone.compat.theoneprobe.InfoProvider; | ||
import net.minecraftforge.fml.InterModComms; | ||
import net.minecraftforge.fml.ModList; | ||
|
||
public class CompatHandler { | ||
public static void register() { | ||
if(ModList.get().isLoaded("theoneprobe")) { | ||
InterModComms.sendTo("theoneprobe", "getTheOneProbe", InfoProvider::new); | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/com/dannyandson/rangedwirelessredstone/compat/hwyla/InfoProvider.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,51 @@ | ||
package com.dannyandson.rangedwirelessredstone.compat.hwyla; | ||
|
||
import com.dannyandson.rangedwirelessredstone.RangedWirelessRedstone; | ||
import com.dannyandson.rangedwirelessredstone.blocks.AbstractWirelessEntity; | ||
import com.dannyandson.rangedwirelessredstone.blocks.ReceiverBlock; | ||
import com.dannyandson.rangedwirelessredstone.blocks.TransmitterBlock; | ||
import mcp.mobius.waila.api.*; | ||
import mcp.mobius.waila.api.config.IPluginConfig; | ||
import mcp.mobius.waila.api.ui.IElement; | ||
import mcp.mobius.waila.api.ui.IElementHelper; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.level.block.entity.BlockEntity; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@WailaPlugin(RangedWirelessRedstone.MODID) | ||
public class InfoProvider implements IWailaPlugin, IComponentProvider { | ||
static final ResourceLocation RENDER_STRING = new ResourceLocation("string"); | ||
static final ResourceLocation RENDER_ITEM_INLINE = new ResourceLocation("item_inline"); | ||
static final ResourceLocation RENDER_INFO_STRING = new ResourceLocation("info_string"); | ||
|
||
@Override | ||
public void register(IRegistrar registrar) { | ||
registrar.registerComponentProvider(this, TooltipPosition.BODY, ReceiverBlock.class); | ||
registrar.registerComponentProvider(this, TooltipPosition.BODY, TransmitterBlock.class); | ||
} | ||
|
||
@Override | ||
public void appendTooltip(ITooltip tooltip, BlockAccessor accessor, IPluginConfig config) { | ||
if(accessor.getBlock() != null) { | ||
BlockPos pos = accessor.getPosition(); | ||
BlockEntity tileEntity = accessor.getLevel().getBlockEntity(pos); | ||
|
||
if (tileEntity instanceof AbstractWirelessEntity wirelessEntity) { | ||
IElementHelper helper = tooltip.getElementHelper(); | ||
|
||
List<IElement> elements = new ArrayList<>(); | ||
elements.add(helper.text(Component.nullToEmpty("Channel:")).tag(RENDER_STRING)); | ||
elements.add(helper.text(Component.nullToEmpty(" " + wirelessEntity.getChannel())).tag(RENDER_INFO_STRING)); | ||
elements.add(helper.text(Component.nullToEmpty(" Signal:")).tag(RENDER_STRING)); | ||
elements.add(helper.text(Component.nullToEmpty(" " + wirelessEntity.getSignal())).tag(RENDER_INFO_STRING)); | ||
tooltip.add(elements); | ||
|
||
} | ||
} | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/com/dannyandson/rangedwirelessredstone/compat/theoneprobe/InfoProvider.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,48 @@ | ||
package com.dannyandson.rangedwirelessredstone.compat.theoneprobe; | ||
|
||
import com.dannyandson.rangedwirelessredstone.RangedWirelessRedstone; | ||
import com.dannyandson.rangedwirelessredstone.blocks.AbstractWirelessEntity; | ||
import com.dannyandson.rangedwirelessredstone.blocks.TransmitterBlockEntity; | ||
import mcjty.theoneprobe.api.*; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.entity.BlockEntity; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
|
||
import java.util.function.Function; | ||
|
||
public class InfoProvider implements IBlockDisplayOverride, Function<ITheOneProbe, Void>, IProbeInfoProvider { | ||
|
||
@Override | ||
public ResourceLocation getID() { | ||
return new ResourceLocation(RangedWirelessRedstone.MODID , "wireless_block"); | ||
} | ||
|
||
@Override | ||
public Void apply(ITheOneProbe theOneProbe) { | ||
theOneProbe.registerBlockDisplayOverride(this); | ||
theOneProbe.registerProvider(this); | ||
return null; | ||
} | ||
|
||
@Override | ||
public void addProbeInfo(ProbeMode probeMode, IProbeInfo probeInfo, Player playerEntity, Level world, BlockState blockState, IProbeHitData probeHitData) { | ||
BlockPos pos = probeHitData.getPos(); | ||
BlockEntity tileEntity = world.getBlockEntity(pos); | ||
|
||
if (tileEntity instanceof AbstractWirelessEntity wirelessEntity) { | ||
probeInfo.horizontal() | ||
.text(CompoundText.createLabelInfo("Channel: ", wirelessEntity.getChannel())); | ||
if (tileEntity instanceof TransmitterBlockEntity) | ||
probeInfo.horizontal() | ||
.text(CompoundText.createLabelInfo("Signal: ", wirelessEntity.getSignal())); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean overrideStandardInfo(ProbeMode probeMode, IProbeInfo iProbeInfo, Player playerEntity, Level world, BlockState blockState, IProbeHitData iProbeHitData) { | ||
return false; | ||
} | ||
} |
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