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.
Merge remote-tracking branch 'origin/1.20.1' into 1.20.1
- Loading branch information
Showing
16 changed files
with
365 additions
and
9 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"); | ||
} | ||
} |
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"); | ||
} | ||
} |
Oops, something went wrong.