From 5b37474e09bcbb03871cfc6aa2457cb10c5f15d9 Mon Sep 17 00:00:00 2001 From: Sampsa Date: Thu, 26 Dec 2024 23:08:44 +0200 Subject: [PATCH] Add separate minimum & default tick rates for covers and make select covers have a lower minimum tick rate --- .../gregtech/api/util/CoverBehaviorBase.java | 19 +++++++++++++++++++ .../gregtech/common/covers/CoverInfo.java | 2 ++ .../common/covers/CoverItemMeter.java | 6 ++++++ .../common/covers/CoverLiquidMeter.java | 6 ++++++ .../CoverAdvancedWirelessRedstoneBase.java | 5 +++++ .../CoverWirelessDoesWorkDetector.java | 6 ++++++ 6 files changed, 44 insertions(+) diff --git a/src/main/java/gregtech/api/util/CoverBehaviorBase.java b/src/main/java/gregtech/api/util/CoverBehaviorBase.java index cd8a1f5ba92..552eeabe66f 100644 --- a/src/main/java/gregtech/api/util/CoverBehaviorBase.java +++ b/src/main/java/gregtech/api/util/CoverBehaviorBase.java @@ -376,6 +376,16 @@ public final int getTickRate(ForgeDirection side, int aCoverID, ISerializableObj return getTickRateImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); } + /** + * Gets the initial tick rate for doCoverThings of the Cover + *

+ * Defaults to getTickRate(), override for different initial and minimum tick rates + */ + public final int getDefaultTickRate(ForgeDirection side, int aCoverID, ISerializableObject aCoverVariable, + ICoverable aTileEntity) { + return getDefaultTickRateImpl(side, aCoverID, forceCast(aCoverVariable), aTileEntity); + } + /** * The MC Color of this Lens. -1 for no Color (meaning this isn't a Lens then). */ @@ -760,6 +770,15 @@ protected int getTickRateImpl(ForgeDirection side, int aCoverID, T aCoverVariabl return 0; } + /** + * Gets the initial tick rate for doCoverThings of the Cover + *

+ * Defaults to getTickRate(), override for different initial and minimum tick rates + */ + protected int getDefaultTickRateImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + return getTickRateImpl(side, aCoverID, aCoverVariable, aTileEntity); + } + /** * The MC Color of this Lens. -1 for no Color (meaning this isn't a Lens then). */ diff --git a/src/main/java/gregtech/common/covers/CoverInfo.java b/src/main/java/gregtech/common/covers/CoverInfo.java index 0a3ef3a07b7..8c5f4fdd25c 100644 --- a/src/main/java/gregtech/common/covers/CoverInfo.java +++ b/src/main/java/gregtech/common/covers/CoverInfo.java @@ -52,6 +52,8 @@ public CoverInfo(ForgeDirection side, int aID, ICoverable aTile, ISerializableOb coverBehavior = GregTechAPI.getCoverBehaviorNew(aID); coverData = aCoverData == null ? coverBehavior.createDataObject() : aCoverData; coveredTile = new WeakReference<>(aTile); + tickRateAddition = coverBehavior.getDefaultTickRate(coverSide, coverID, coverData, coveredTile.get()) + - this.getMinimumTickRate(); } public CoverInfo(ICoverable aTile, NBTTagCompound aNBT) { diff --git a/src/main/java/gregtech/common/covers/CoverItemMeter.java b/src/main/java/gregtech/common/covers/CoverItemMeter.java index 376a93682c3..84a2c9613c7 100644 --- a/src/main/java/gregtech/common/covers/CoverItemMeter.java +++ b/src/main/java/gregtech/common/covers/CoverItemMeter.java @@ -178,6 +178,12 @@ protected boolean manipulatesSidedRedstoneOutputImpl(ForgeDirection side, int aC @Override protected int getTickRateImpl(ForgeDirection side, int aCoverID, ItemMeterData aCoverVariable, + ICoverable aTileEntity) { + return 1; + } + + @Override + protected int getDefaultTickRateImpl(ForgeDirection side, int aCoverID, ItemMeterData aCoverVariable, ICoverable aTileEntity) { return 5; } diff --git a/src/main/java/gregtech/common/covers/CoverLiquidMeter.java b/src/main/java/gregtech/common/covers/CoverLiquidMeter.java index 2f13f25421e..c826d794829 100644 --- a/src/main/java/gregtech/common/covers/CoverLiquidMeter.java +++ b/src/main/java/gregtech/common/covers/CoverLiquidMeter.java @@ -150,6 +150,12 @@ protected boolean manipulatesSidedRedstoneOutputImpl(ForgeDirection side, int aC @Override protected int getTickRateImpl(ForgeDirection side, int aCoverID, LiquidMeterData aCoverVariable, + ICoverable aTileEntity) { + return 1; + } + + @Override + protected int getDefaultTickRateImpl(ForgeDirection side, int aCoverID, LiquidMeterData aCoverVariable, ICoverable aTileEntity) { return 5; } diff --git a/src/main/java/gregtech/common/covers/redstone/CoverAdvancedWirelessRedstoneBase.java b/src/main/java/gregtech/common/covers/redstone/CoverAdvancedWirelessRedstoneBase.java index 963678a24cb..e3881258ca4 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverAdvancedWirelessRedstoneBase.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverAdvancedWirelessRedstoneBase.java @@ -150,6 +150,11 @@ public String getDescriptionImpl(ForgeDirection side, int aCoverID, T aCoverVari @Override public int getTickRateImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { + return 1; + } + + @Override + protected int getDefaultTickRateImpl(ForgeDirection side, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { return 5; } diff --git a/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java b/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java index 1d5f89ee902..769f578fd12 100644 --- a/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java +++ b/src/main/java/gregtech/common/covers/redstone/CoverWirelessDoesWorkDetector.java @@ -95,6 +95,12 @@ protected boolean manipulatesSidedRedstoneOutputImpl(ForgeDirection side, int aC @Override public int getTickRateImpl(ForgeDirection side, int aCoverID, ActivityTransmitterData aCoverVariable, + ICoverable aTileEntity) { + return 1; + } + + @Override + protected int getDefaultTickRateImpl(ForgeDirection side, int aCoverID, ActivityTransmitterData aCoverVariable, ICoverable aTileEntity) { return 5; }