mirror of
https://github.com/GTNewHorizons/Applied-Energistics-2-Unofficial.git
synced 2026-11-13 17:04:17 +00:00
Put memory card copying pattern behind config (#1725)
This commit is contained in:
1 parent
2d5bd34123
commit
44b5a5ac66
6 files changed
+34
-8
No files matched your search
@@ -272,7 +272,7 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
|
||||
}
|
||||
|
||||
if (t instanceof IInterfaceHost iHost) {
|
||||
ToolMemoryCard.savePatterns(data, iHost);
|
||||
ToolMemoryCard.savePatterns(data, player, iHost);
|
||||
}
|
||||
|
||||
memoryCard.notifyUser(player, MemoryCardMessages.SETTINGS_SAVED);
|
||||
|
||||
@@ -139,7 +139,7 @@ public class ClientHelper extends ServerHelper {
|
||||
AEConfig.instance.get("Client", "controllerAnimation", ControllerAnimation.ORIGINAL_RAINBOW.name())
|
||||
.set(controllerAnimation.name());
|
||||
AEConfig.instance.save();
|
||||
syncControllerAnimationDefault();
|
||||
syncPlayerSettings();
|
||||
return controllerAnimation;
|
||||
}
|
||||
|
||||
@@ -149,14 +149,14 @@ public class ClientHelper extends ServerHelper {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerJoinWorld(final EntityJoinWorldEvent event) {
|
||||
if (event.entity instanceof EntityPlayerSP) syncControllerAnimationDefault();
|
||||
if (event.entity instanceof EntityPlayerSP) syncPlayerSettings();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onConfigChanged(final ConfigChangedEvent.OnConfigChangedEvent event) {
|
||||
if (!event.modID.equals(AppEng.MOD_ID)) return;
|
||||
loadControllerAnimation();
|
||||
syncControllerAnimationDefault();
|
||||
syncPlayerSettings();
|
||||
}
|
||||
|
||||
private static void loadControllerAnimation() {
|
||||
@@ -174,12 +174,16 @@ public class ClientHelper extends ServerHelper {
|
||||
}
|
||||
}
|
||||
|
||||
private static void syncControllerAnimationDefault() {
|
||||
private static void syncPlayerSettings() {
|
||||
final Minecraft minecraft = Minecraft.getMinecraft();
|
||||
if (minecraft.thePlayer == null || minecraft.theWorld == null) return;
|
||||
try {
|
||||
NetworkHandler.instance.sendToServer(
|
||||
new PacketValueConfig(PacketValueConfig.CONTROLLER_ANIMATION_DEFAULT, controllerAnimation.name()));
|
||||
NetworkHandler.instance.sendToServer(
|
||||
new PacketValueConfig(
|
||||
PacketValueConfig.MEMORY_CARD_COPY_PATTERNS,
|
||||
String.valueOf(AEConfig.instance.memoryCardCopiesPatterns)));
|
||||
} catch (final IOException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
||||
public int InterfaceTerminalSmallSize = 6;
|
||||
public boolean highlightWhenSomethingStuckInInterface = true;
|
||||
public boolean highlightPatternTypeMismatchInGUI = true;
|
||||
public boolean memoryCardCopiesPatterns = false;
|
||||
public int screenColor = 0xFFFFFF;
|
||||
private boolean useLiteCraftingMode = false;
|
||||
|
||||
@@ -403,6 +404,9 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
||||
.get("Client", "highlightPatternTypeMismatchInGUI", true);
|
||||
highlightPatternTypeMismatchInGUI.comment = "Highlight pattern slots in red when the pattern uses unsupported stack types.";
|
||||
this.highlightPatternTypeMismatchInGUI = highlightPatternTypeMismatchInGUI.getBoolean(true);
|
||||
final Property memoryCardCopiesPatterns = this.get("Client", "memoryCardCopiesPatterns", false);
|
||||
memoryCardCopiesPatterns.comment = "Memory cards copy interface patterns, using blank patterns from your inventory on paste.";
|
||||
this.memoryCardCopiesPatterns = memoryCardCopiesPatterns.getBoolean(false);
|
||||
this.MEMonitorableSmallSize = this.get("Client", "MEMonitorableSmallSize", 6).getInt(6);
|
||||
this.InterfaceTerminalSmallSize = this.get("Client", "InterfaceTerminalSmallSize", 6).getInt(6);
|
||||
Property screenColorProperty = this.get("Client", "screenColor", this.screenColor);
|
||||
|
||||
@@ -45,6 +45,7 @@ import appeng.container.interfaces.ICraftingCPUSelectorContainer;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.helpers.IMouseWheelItem;
|
||||
import appeng.items.tools.ToolMemoryCard;
|
||||
import appeng.tile.networking.TileController;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
@@ -52,6 +53,7 @@ import io.netty.buffer.Unpooled;
|
||||
public class PacketValueConfig extends AppEngPacket {
|
||||
|
||||
public static final String CONTROLLER_ANIMATION_DEFAULT = "ControllerAnimationDefault";
|
||||
public static final String MEMORY_CARD_COPY_PATTERNS = "MemoryCardCopyPatterns";
|
||||
public static final String APPLY_CONTROLLER_ANIMATION_DEFAULT = "ApplyControllerAnimationDefault";
|
||||
public static final String CYCLE_CONTROLLER_ANIMATION = "CycleControllerAnimation";
|
||||
public static final String CYCLE_CONTROLLER_ANIMATION_BACKWARDS = "CycleControllerAnimationBackwards";
|
||||
@@ -94,6 +96,8 @@ public class PacketValueConfig extends AppEngPacket {
|
||||
|
||||
if (this.Name.equals(CONTROLLER_ANIMATION_DEFAULT)) {
|
||||
TileController.setPlayerDefaultAnimation(player, this.Value);
|
||||
} else if (this.Name.equals(MEMORY_CARD_COPY_PATTERNS)) {
|
||||
ToolMemoryCard.setCopyPatterns(player, Boolean.parseBoolean(this.Value));
|
||||
} else if (this.Name.equals("Item") && player.getHeldItem() != null
|
||||
&& player.getHeldItem().getItem() instanceof IMouseWheelItem) {
|
||||
final ItemStack is = player.getHeldItem();
|
||||
|
||||
@@ -172,8 +172,22 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard {
|
||||
}
|
||||
|
||||
private static final String PATTERNS_KEY = "interfacePatterns";
|
||||
private static final String PLAYER_COPY_PATTERNS_NBT_KEY = "ae2.memoryCardCopyPatterns";
|
||||
|
||||
/** Stores the player's client config value on the server. */
|
||||
public static void setCopyPatterns(final EntityPlayer player, final boolean copyPatterns) {
|
||||
player.getEntityData().setBoolean(PLAYER_COPY_PATTERNS_NBT_KEY, copyPatterns);
|
||||
}
|
||||
|
||||
private static boolean canCopyPatterns(final EntityPlayer player) {
|
||||
return player.getEntityData().getBoolean(PLAYER_COPY_PATTERNS_NBT_KEY);
|
||||
}
|
||||
|
||||
public static void savePatterns(final NBTTagCompound data, final EntityPlayer player, final IInterfaceHost iHost) {
|
||||
if (!canCopyPatterns(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
public static void savePatterns(final NBTTagCompound data, final IInterfaceHost iHost) {
|
||||
final IInventory patterns = iHost.getInterfaceDuality().getPatterns();
|
||||
final NBTTagList tagList = new NBTTagList();
|
||||
|
||||
@@ -196,7 +210,7 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard {
|
||||
|
||||
public static void insertPatterns(final NBTTagCompound data, final EntityPlayer player,
|
||||
final IInterfaceHost iHost) {
|
||||
if (!data.hasKey(PATTERNS_KEY, NBT.TAG_LIST)) {
|
||||
if (!canCopyPatterns(player) || !data.hasKey(PATTERNS_KEY, NBT.TAG_LIST)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -456,7 +456,7 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
ToolMemoryCard.setUpgradesInfo(data, ui);
|
||||
|
||||
if (this instanceof IInterfaceHost iHost) {
|
||||
ToolMemoryCard.savePatterns(data, iHost);
|
||||
ToolMemoryCard.savePatterns(data, player, iHost);
|
||||
}
|
||||
|
||||
memoryCard.notifyUser(player, MemoryCardMessages.SETTINGS_SAVED);
|
||||
|
||||
Reference in new issue
Block a user