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
6f8e672
commit 2cc679e
Showing
9 changed files
with
130 additions
and
0 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
55 changes: 55 additions & 0 deletions
55
src/main/java/com/epimorphismmc/monazite/integration/jade/provider/ParallelProvider.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,55 @@ | ||
package com.epimorphismmc.monazite.integration.jade.provider; | ||
|
||
import com.epimorphismmc.monazite.Monazite; | ||
import com.epimorphismmc.monazite.utils.FormattingUtils; | ||
import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity; | ||
import com.gregtechceu.gtceu.api.capability.IParallelHatch; | ||
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; | ||
|
||
import java.util.Optional; | ||
|
||
public enum ParallelProvider implements IBlockComponentProvider, IServerDataProvider<BlockAccessor> { | ||
INSTANCE; | ||
|
||
@Override | ||
public void appendTooltip(ITooltip iTooltip, BlockAccessor blockAccessor, IPluginConfig iPluginConfig) { | ||
if (blockAccessor.getServerData().contains("parallel")) { | ||
int parallel = blockAccessor.getServerData().getInt("parallel"); | ||
if (parallel > 0) { | ||
iTooltip.add(Component.translatable( | ||
"gtceu.multiblock.parallel", | ||
Component.literal(FormattingUtils.abbreviate0F(parallel)).withStyle(ChatFormatting.DARK_PURPLE) | ||
)); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void appendServerData(CompoundTag compoundTag, BlockAccessor blockAccessor) { | ||
if (blockAccessor.getBlockEntity() instanceof MetaMachineBlockEntity blockEntity) { | ||
if (blockEntity.getMetaMachine() instanceof IParallelHatch parallelHatch) { | ||
compoundTag.putInt("parallel", parallelHatch.getCurrentParallel()); | ||
} else if (blockEntity.getMetaMachine() instanceof IMultiController controller) { | ||
Optional<IParallelHatch> parallelHatch = controller.getParts().stream() | ||
.filter(IParallelHatch.class::isInstance) | ||
.map(IParallelHatch.class::cast) | ||
.findAny(); | ||
parallelHatch.ifPresent(iParallelHatch -> compoundTag.putInt("parallel", iParallelHatch.getCurrentParallel())); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public ResourceLocation getUid() { | ||
return Monazite.id("parallel"); | ||
} | ||
} |
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
52 changes: 52 additions & 0 deletions
52
src/main/java/com/epimorphismmc/monazite/integration/top/provider/ParallelProvider.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,52 @@ | ||
package com.epimorphismmc.monazite.integration.top.provider; | ||
|
||
import com.epimorphismmc.monazite.Monazite; | ||
import com.epimorphismmc.monazite.utils.FormattingUtils; | ||
import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity; | ||
import com.gregtechceu.gtceu.api.capability.IParallelHatch; | ||
import com.gregtechceu.gtceu.api.machine.feature.multiblock.IMultiController; | ||
import mcjty.theoneprobe.api.IProbeHitData; | ||
import mcjty.theoneprobe.api.IProbeInfo; | ||
import mcjty.theoneprobe.api.IProbeInfoProvider; | ||
import mcjty.theoneprobe.api.ProbeMode; | ||
import net.minecraft.ChatFormatting; | ||
import net.minecraft.network.chat.Component; | ||
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.Optional; | ||
|
||
public class ParallelProvider implements IProbeInfoProvider { | ||
@Override | ||
public ResourceLocation getID() { | ||
return Monazite.id("parallel"); | ||
} | ||
|
||
@Override | ||
public void addProbeInfo(ProbeMode probeMode, IProbeInfo iProbeInfo, Player player, Level level, BlockState blockState, IProbeHitData iProbeHitData) { | ||
BlockEntity blockEntity = level.getBlockEntity(iProbeHitData.getPos()); | ||
if (blockEntity instanceof MetaMachineBlockEntity machineBlockEntity) { | ||
int parallel = 0; | ||
if (machineBlockEntity.getMetaMachine() instanceof IParallelHatch parallelHatch) { | ||
parallel = parallelHatch.getCurrentParallel(); | ||
} else if (machineBlockEntity.getMetaMachine() instanceof IMultiController controller) { | ||
Optional<IParallelHatch> parallelHatch = controller.getParts().stream() | ||
.filter(IParallelHatch.class::isInstance) | ||
.map(IParallelHatch.class::cast) | ||
.findAny(); | ||
if (parallelHatch.isPresent()) { | ||
parallel = parallelHatch.get().getCurrentParallel(); | ||
} | ||
} | ||
if (parallel > 0) { | ||
iProbeInfo.text(Component.translatable( | ||
"gtceu.multiblock.parallel", | ||
Component.literal(FormattingUtils.abbreviate0F(parallel)).withStyle(ChatFormatting.DARK_PURPLE) | ||
)); | ||
} | ||
} | ||
} | ||
} |