forked from NegaNote/GregTech-Modern-Utilities
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExpandedMEPatternBufferProxyProvider.java
More file actions
71 lines (61 loc) · 3.07 KB
/
ExpandedMEPatternBufferProxyProvider.java
File metadata and controls
71 lines (61 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package net.neganote.gtutilities.integration.jade.provider;
import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity;
import com.gregtechceu.gtceu.client.util.TooltipHelper;
import com.gregtechceu.gtceu.integration.jade.provider.MEPatternBufferProvider;
import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.neganote.gtutilities.GregTechModernUtilities;
import net.neganote.gtutilities.integration.ae2.machine.ExpandedPatternBufferProxyPartMachine;
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 class ExpandedMEPatternBufferProxyProvider implements IBlockComponentProvider,
IServerDataProvider<BlockAccessor> {
@Override
public void appendTooltip(ITooltip iTooltip, BlockAccessor blockAccessor, IPluginConfig iPluginConfig) {
if (blockAccessor.getBlockEntity() instanceof IMachineBlockEntity blockEntity) {
if (blockEntity.getMetaMachine() instanceof ExpandedPatternBufferProxyPartMachine) {
CompoundTag serverData = blockAccessor.getServerData();
if (!serverData.getBoolean("formed")) return;
if (!serverData.getBoolean("bound")) {
iTooltip.add(Component.translatable("gtceu.top.buffer_not_bound").withStyle(ChatFormatting.RED));
return;
}
int[] pos = serverData.getIntArray("pos");
iTooltip.add(Component.translatable("gtceu.top.buffer_bound_pos", pos[0], pos[1], pos[2])
.withStyle(TooltipHelper.RAINBOW_HSL_SLOW));
MEPatternBufferProvider.readBufferTag(iTooltip,
serverData);
}
}
}
@Override
public void appendServerData(CompoundTag compoundTag, BlockAccessor blockAccessor) {
if (blockAccessor.getBlockEntity() instanceof IMachineBlockEntity blockEntity) {
if (blockEntity.getMetaMachine() instanceof ExpandedPatternBufferProxyPartMachine proxy) {
if (!proxy.isFormed()) {
compoundTag.putBoolean("formed", false);
return;
}
compoundTag.putBoolean("formed", true);
var buffer = proxy.getBuffer();
if (buffer == null) {
compoundTag.putBoolean("bound", false);
return;
}
compoundTag.putBoolean("bound", true);
var pos = buffer.getPos();
compoundTag.putIntArray("pos", new int[] { pos.getX(), pos.getY(), pos.getZ() });
ExpandedMEPatternBufferProvider.writeBufferTag(compoundTag, buffer);
}
}
}
@Override
public ResourceLocation getUid() {
return GregTechModernUtilities.id("me_expanded_pattern_buffer_proxy");
}
}