mirror of
https://github.com/GTNewHorizons/Applied-Energistics-2-Unofficial.git
synced 2026-11-14 01:14:11 +00:00
Add encoding timestamps to patterns (#1681)
This commit is contained in:
1 parent
fecabda2e6
commit
142345e468
4 files changed
+18
-2
No files matched your search
@@ -186,6 +186,7 @@ public class PatternEncodingHelper {
|
||||
ItemTunnelPattern.writeTunnelUuid(encodedValue, uuid);
|
||||
}
|
||||
encodedValue.setString("author", auther);
|
||||
encodedValue.setLong("encodedAt", System.currentTimeMillis());
|
||||
|
||||
output.setTagCompound(encodedValue);
|
||||
pattern.setInventorySlotContents(1, output);
|
||||
|
||||
@@ -68,9 +68,10 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
this.canSubstitute = nbt.getBoolean("substitute");
|
||||
this.canBeSubstitute = nbt.getBoolean("beSubstitute");
|
||||
this.patternItem = is;
|
||||
if (nbt.hasKey("author")) {
|
||||
if (nbt.hasKey("author") || nbt.hasKey("encodedAt")) {
|
||||
final ItemStack forComparison = this.patternItem.copy();
|
||||
forComparison.stackTagCompound.removeTag("author");
|
||||
forComparison.stackTagCompound.removeTag("encodedAt");
|
||||
this.pattern = AEItemStack.create(forComparison);
|
||||
} else {
|
||||
this.pattern = AEItemStack.create(is);
|
||||
|
||||
@@ -56,9 +56,10 @@ public class UltimatePatternHelper implements ICraftingPatternDetails, Comparabl
|
||||
this.inputOnly = encodedValue.getBoolean("tunnel");
|
||||
this.inputOnlyUuid = readInputOnlyUuid(encodedValue, this.inputOnly);
|
||||
|
||||
if (encodedValue.hasKey("author")) {
|
||||
if (encodedValue.hasKey("author") || encodedValue.hasKey("encodedAt")) {
|
||||
final ItemStack forComparison = this.patternItem.copy();
|
||||
forComparison.stackTagCompound.removeTag("author");
|
||||
forComparison.stackTagCompound.removeTag("encodedAt");
|
||||
this.pattern = AEItemStack.create(forComparison);
|
||||
} else {
|
||||
this.pattern = AEItemStack.create(is);
|
||||
|
||||
@@ -14,6 +14,9 @@ import static appeng.helpers.PatternHelper.convertToCondensedAEList;
|
||||
import static appeng.helpers.UltimatePatternHelper.loadIAEStackFromNBT;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
@@ -59,6 +62,8 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
|
||||
private static final Map<ItemStack, ItemStack> SIMPLE_CACHE = new WeakHashMap<>();
|
||||
private static final Map<ItemStack, IAEStack<?>> OUTPUT_STACK_CACHE = new WeakHashMap<>();
|
||||
private static final Locale locale = Locale.getDefault();
|
||||
private static final DateTimeFormatter ENCODING_DATE_FORMAT = DateTimeFormatter
|
||||
.ofPattern("yyyy-MM-dd HH:mm:ss", Locale.ROOT).withZone(ZoneId.systemDefault());
|
||||
|
||||
public ItemEncodedPattern() {
|
||||
this.setFeature(EnumSet.of(AEFeature.Patterns));
|
||||
@@ -186,6 +191,14 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
|
||||
lines.add(
|
||||
EnumChatFormatting.LIGHT_PURPLE + GuiText.EncodedBy.getLocal(author)
|
||||
+ EnumChatFormatting.RESET);
|
||||
if (encodedValue.hasKey("encodedAt", NBT.TAG_LONG)) {
|
||||
lines.add(
|
||||
EnumChatFormatting.LIGHT_PURPLE + "("
|
||||
+ ENCODING_DATE_FORMAT
|
||||
.format(Instant.ofEpochMilli(encodedValue.getLong("encodedAt")))
|
||||
+ ")"
|
||||
+ EnumChatFormatting.RESET);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ItemTunnelPattern.isTunnelPattern(stack)) {
|
||||
|
||||
Reference in new issue
Block a user