This repository has been archived by the owner on Jul 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
8fc7ac7
commit 3005d78
Showing
12 changed files
with
104 additions
and
4 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
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
44 changes: 44 additions & 0 deletions
44
...ava/com/epimorphismmc/monazite/integration/jade/provider/MulitblockStructureProvider.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,44 @@ | ||
package com.epimorphismmc.monazite.integration.jade.provider; | ||
|
||
import com.epimorphismmc.monazite.Monazite; | ||
import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity; | ||
import com.gregtechceu.gtceu.api.machine.feature.multiblock.IMultiController; | ||
import net.minecraft.ChatFormatting; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
import snownee.jade.api.BlockAccessor; | ||
import snownee.jade.api.IBlockComponentProvider; | ||
import snownee.jade.api.IServerDataProvider; | ||
import snownee.jade.api.ITooltip; | ||
import snownee.jade.api.config.IPluginConfig; | ||
|
||
public enum MulitblockStructureProvider implements IBlockComponentProvider, IServerDataProvider<BlockAccessor> { | ||
INSTANCE; | ||
|
||
@Override | ||
public void appendTooltip(ITooltip iTooltip, BlockAccessor blockAccessor, IPluginConfig iPluginConfig) { | ||
if (blockAccessor.getServerData().contains("hasError")) { | ||
boolean hasError = blockAccessor.getServerData().getBoolean("hasError"); | ||
if (hasError) { | ||
iTooltip.add(Component.translatable("gtceu.top.invalid_structure").withStyle(ChatFormatting.RED)); | ||
} else { | ||
iTooltip.add(Component.translatable("gtceu.top.valid_structure").withStyle(ChatFormatting.GREEN)); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void appendServerData(CompoundTag compoundTag, BlockAccessor blockAccessor) { | ||
if (blockAccessor.getBlockEntity() instanceof MetaMachineBlockEntity blockEntity) { | ||
if (blockEntity.getMetaMachine() instanceof IMultiController controller) { | ||
compoundTag.putBoolean("hasError", controller.getMultiblockState().hasError()); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public ResourceLocation getUid() { | ||
return Monazite.id("multiblock_structure"); | ||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
...java/com/epimorphismmc/monazite/integration/top/provider/MulitblockStructureProvider.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,34 @@ | ||
package com.epimorphismmc.monazite.integration.top.provider; | ||
|
||
import com.epimorphismmc.monazite.Monazite; | ||
import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity; | ||
import com.gregtechceu.gtceu.api.machine.feature.multiblock.IMultiController; | ||
import mcjty.theoneprobe.api.CompoundText; | ||
import mcjty.theoneprobe.api.IProbeHitData; | ||
import mcjty.theoneprobe.api.IProbeInfo; | ||
import mcjty.theoneprobe.api.IProbeInfoProvider; | ||
import mcjty.theoneprobe.api.ProbeMode; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
|
||
public class MulitblockStructureProvider implements IProbeInfoProvider { | ||
@Override | ||
public ResourceLocation getID() { | ||
return Monazite.id("multiblock_structure"); | ||
} | ||
|
||
@Override | ||
public void addProbeInfo(ProbeMode probeMode, IProbeInfo iProbeInfo, Player player, Level level, BlockState blockState, IProbeHitData iProbeHitData) { | ||
if (level.getBlockEntity(iProbeHitData.getPos()) instanceof MetaMachineBlockEntity blockEntity) { | ||
if (blockEntity.getMetaMachine() instanceof IMultiController controller) { | ||
if (controller.getMultiblockState().hasError()) { | ||
iProbeInfo.text(CompoundText.create().error("gtceu.top.invalid_structure")); | ||
} else { | ||
iProbeInfo.text(CompoundText.create().ok("gtceu.top.valid_structure")); | ||
} | ||
} | ||
} | ||
} | ||
} |