From 99f0948399c95cec03e4062ea0aaaf387b4e37c6 Mon Sep 17 00:00:00 2001 From: Fluffies Date: Tue, 1 Dec 2015 15:44:03 -0500 Subject: [PATCH] Adding a clockwork powered block and reworked time to use integers. --- .../api/ITemporalMaterial.java | 7 - .../api/TemporalAchievementList.java | 14 +- .../ISteamReceiver.java | 2 +- .../ITimezoneProvider.java} | 14 +- .../clockwork/IClockworkDestination.java | 16 ++ .../api/block/clockwork/IClockworkSource.java | 16 ++ .../api/block/clockwork/IClockworkTile.java | 14 + .../clockworkphase2/api/item/ITimeSand.java | 16 +- .../item/clockwork/IClockworkComponent.java | 27 +- .../item/clockwork/IClockworkConstruct.java | 15 +- .../timestream/IReversableTimestream.java | 18 -- .../api/item/timestream/ITimestream.java | 5 - .../api/steammachine/ISteamProvider.java | 21 -- .../api/time/ITimeContainerItem.java | 8 +- .../api/time/ITimeProvider.java | 6 +- .../api/time/ITimeReceiver.java | 6 +- .../api/time/ITimeStorage.java | 8 +- .../api/time/ItemTimeContainer.java | 28 +- .../clockworkphase2/api/time/TimeStorage.java | 28 +- .../api/time/TimezoneHandler.java | 15 +- .../api/util/AssemblyHelper.java | 11 +- .../api/util/ClockworkHelper.java | 38 ++- .../api/util/InformationDisplay.java | 36 ++- .../api/util/TimeConverter.java | 181 ++----------- .../clockworkphase2/api/util/TimeHelper.java | 18 +- .../api/util/internal/NBTTags.java | 2 +- .../clockwork/BlockClockworkFurnace.java | 107 ++++++++ .../block/clockwork/BlockCrank.java | 60 +++++ .../itemblock/ItemBlockClockworkFurnace.java | 138 ++++++++++ .../client/gui/GuiClockworkFurnace.java | 58 ++++ .../client/gui/GuiHandler.java | 6 + .../sequence/ParticleSequenceTimezone.java | 6 +- .../client/render/RenderHandler.java | 8 +- ...OverlayRenderElementTemporalInfluence.java | 10 +- .../container/ContainerClockworkFurnace.java | 91 +++++++ .../ExtendedPlayerProperties.java | 12 +- .../handler/EntityHandler.java | 6 +- .../mods/clockworkphase2/init/ModBlocks.java | 17 ++ .../item/ItemTemporalHourglass.java | 30 +-- .../item/ItemTemporalIngot.java | 4 +- .../components/tool/clockwork/ItemGear.java | 2 +- .../tool/clockwork/ItemMemoryComponent.java | 2 +- .../item/construct/tool/ItemClockworkAxe.java | 5 +- .../construct/tool/ItemClockworkPickaxe.java | 5 +- .../construct/tool/ItemClockworkShovel.java | 5 +- .../construct/tool/ItemClockworkTool.java | 15 +- .../ItemTimestreamExtradimensionalTank.java | 3 +- .../timestream/ItemTimestreamLightning.java | 3 +- .../timestream/ItemTimestreamMobRepulser.java | 3 +- .../timestream/ItemTimestreamRelocation.java | 3 +- .../ItemTimestreamSilkyHarvest.java | 3 +- .../item/timestream/ItemTimestreamSmelt.java | 3 +- .../mods/clockworkphase2/lib/Names.java | 3 + .../message/MessageTemporalInfluence.java | 8 +- .../tile/TileCelestialCompass.java | 14 +- .../tile/clockwork/TileClockwork.java | 78 ++++++ .../tile/clockwork/TileClockworkFurnace.java | 252 ++++++++++++++++++ .../tile/generic/TileTemporal.java | 12 +- .../machine/TileTimezoneFluidExporter.java | 4 +- .../machine/TileTimezoneFluidImporter.java | 4 +- .../tile/temporal/TileTemporalFurnace.java | 14 +- .../tile/temporal/TileTimeCollector.java | 6 +- .../tile/temporal/TileTimeWell.java | 10 +- 63 files changed, 1143 insertions(+), 437 deletions(-) delete mode 100644 src/main/java/lumaceon/mods/clockworkphase2/api/ITemporalMaterial.java rename src/main/java/lumaceon/mods/clockworkphase2/api/{steammachine => block}/ISteamReceiver.java (96%) rename src/main/java/lumaceon/mods/clockworkphase2/api/{time/ITimezone.java => block/ITimezoneProvider.java} (75%) create mode 100644 src/main/java/lumaceon/mods/clockworkphase2/api/block/clockwork/IClockworkDestination.java create mode 100644 src/main/java/lumaceon/mods/clockworkphase2/api/block/clockwork/IClockworkSource.java create mode 100644 src/main/java/lumaceon/mods/clockworkphase2/api/block/clockwork/IClockworkTile.java delete mode 100644 src/main/java/lumaceon/mods/clockworkphase2/api/item/timestream/IReversableTimestream.java delete mode 100644 src/main/java/lumaceon/mods/clockworkphase2/api/item/timestream/ITimestream.java delete mode 100644 src/main/java/lumaceon/mods/clockworkphase2/api/steammachine/ISteamProvider.java create mode 100644 src/main/java/lumaceon/mods/clockworkphase2/block/clockwork/BlockClockworkFurnace.java create mode 100644 src/main/java/lumaceon/mods/clockworkphase2/block/clockwork/BlockCrank.java create mode 100644 src/main/java/lumaceon/mods/clockworkphase2/block/itemblock/ItemBlockClockworkFurnace.java create mode 100644 src/main/java/lumaceon/mods/clockworkphase2/client/gui/GuiClockworkFurnace.java create mode 100644 src/main/java/lumaceon/mods/clockworkphase2/container/ContainerClockworkFurnace.java create mode 100644 src/main/java/lumaceon/mods/clockworkphase2/tile/clockwork/TileClockwork.java create mode 100644 src/main/java/lumaceon/mods/clockworkphase2/tile/clockwork/TileClockworkFurnace.java diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/ITemporalMaterial.java b/src/main/java/lumaceon/mods/clockworkphase2/api/ITemporalMaterial.java deleted file mode 100644 index bb3116f..0000000 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/ITemporalMaterial.java +++ /dev/null @@ -1,7 +0,0 @@ -package lumaceon.mods.clockworkphase2.api; - -/** - * Used to mark this item as being made of temporal material. If an item implements this, that item cannot be processed - * in the temporalizer. - */ -public interface ITemporalMaterial {} \ No newline at end of file diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/TemporalAchievementList.java b/src/main/java/lumaceon/mods/clockworkphase2/api/TemporalAchievementList.java index 52bdd7f..547891b 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/TemporalAchievementList.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/TemporalAchievementList.java @@ -10,7 +10,7 @@ public class TemporalAchievementList { - public static Map achievementValues = new HashMap(AchievementList.achievementList.size()); + public static Map achievementValues = new HashMap(AchievementList.achievementList.size()); public static boolean isAchievementListed(Achievement achievement) { return achievementValues.containsKey(achievement) && achievementValues.get(achievement) > 0; @@ -27,9 +27,9 @@ public static int getPageBonusMultiplier(AchievementPage page) public static class INTERNAL { - public static long totalWeight = 0; - public static long specialAchievementCount = 0; - public static long maxPageMultiplier = 1; + public static int totalWeight = 0; + public static int specialAchievementCount = 0; + public static int maxPageMultiplier = 1; public static double specialAchievementMultiplierExponent = 1; /** @@ -39,11 +39,11 @@ public static class INTERNAL * @param achievement The achievement to calculate. * @return The weight of this achievement. */ - public static long registerAchievement(Achievement achievement) + public static int registerAchievement(Achievement achievement) { if(achievement.isIndependent || !achievement.isAchievement()) return 0; - long calculatedWeight = 60; + int calculatedWeight = 60; Achievement temp = achievement.parentAchievement; while(temp != null) @@ -76,7 +76,7 @@ public static int registerPage(AchievementPage page) } public static void setupSpecialMultiplier() { - long maxValueWithoutSpecialMultipliers = totalWeight * maxPageMultiplier; + int maxValueWithoutSpecialMultipliers = totalWeight * maxPageMultiplier; specialAchievementMultiplierExponent = Math.log(TimeConverter.INFINITE / maxValueWithoutSpecialMultipliers) / Math.log(specialAchievementCount + 1); } } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/steammachine/ISteamReceiver.java b/src/main/java/lumaceon/mods/clockworkphase2/api/block/ISteamReceiver.java similarity index 96% rename from src/main/java/lumaceon/mods/clockworkphase2/api/steammachine/ISteamReceiver.java rename to src/main/java/lumaceon/mods/clockworkphase2/api/block/ISteamReceiver.java index d5e7949..9a3157e 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/steammachine/ISteamReceiver.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/block/ISteamReceiver.java @@ -1,4 +1,4 @@ -package lumaceon.mods.clockworkphase2.api.steammachine; +package lumaceon.mods.clockworkphase2.api.block; import net.minecraftforge.common.util.ForgeDirection; diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/time/ITimezone.java b/src/main/java/lumaceon/mods/clockworkphase2/api/block/ITimezoneProvider.java similarity index 75% rename from src/main/java/lumaceon/mods/clockworkphase2/api/time/ITimezone.java rename to src/main/java/lumaceon/mods/clockworkphase2/api/block/ITimezoneProvider.java index 19a5fa8..b52afe3 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/time/ITimezone.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/block/ITimezoneProvider.java @@ -1,8 +1,8 @@ -package lumaceon.mods.clockworkphase2.api.time; +package lumaceon.mods.clockworkphase2.api.block; import net.minecraft.item.ItemStack; -public interface ITimezone +public interface ITimezoneProvider { public float getRange(); public int getX(); @@ -17,21 +17,21 @@ public interface ITimezone public void setTimestream(int index, ItemStack item); - public long getMaxTimeSand(); - public long getTimeSand(); - public void setTimeSand(long timeSand); + public int getMaxTimeSand(); + public int getTimeSand(); + public void setTimeSand(int timeSand); /** * Adds time sand to this timezone. * @param timeSand Amount of time sand to add to this timezone. * @return The amount of time sand successfully added. */ - public long addTimeSand(long timeSand); + public int addTimeSand(int timeSand); /** * Consumes time sand from this timezone. * @param timeSand Amount of time sand to remove from this timezone. * @return The amount of time sand successfully consumed. */ - public long consumeTimeSand(long timeSand); + public int consumeTimeSand(int timeSand); } \ No newline at end of file diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/block/clockwork/IClockworkDestination.java b/src/main/java/lumaceon/mods/clockworkphase2/api/block/clockwork/IClockworkDestination.java new file mode 100644 index 0000000..a847c87 --- /dev/null +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/block/clockwork/IClockworkDestination.java @@ -0,0 +1,16 @@ +package lumaceon.mods.clockworkphase2.api.block.clockwork; + +import net.minecraftforge.common.util.ForgeDirection; + +public interface IClockworkDestination extends IClockworkTile +{ + public boolean canReceiveFrom(ForgeDirection direction); + + /** + * Called to transfer clockwork energy into this destination. + * + * @param maxReception The amount of energy this destination is being exposed to. + * @return The amount of energy taken by this destination. + */ + public int receiveClockworkEnergy(ForgeDirection from, int maxReception); +} diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/block/clockwork/IClockworkSource.java b/src/main/java/lumaceon/mods/clockworkphase2/api/block/clockwork/IClockworkSource.java new file mode 100644 index 0000000..5c83785 --- /dev/null +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/block/clockwork/IClockworkSource.java @@ -0,0 +1,16 @@ +package lumaceon.mods.clockworkphase2.api.block.clockwork; + +import net.minecraftforge.common.util.ForgeDirection; + +public interface IClockworkSource extends IClockworkTile +{ + public boolean canDistributeTo(ForgeDirection direction); + + /** + * Called to transfer clockwork energy from this source outward. + * + * @param maxExtraction The amount of energy trying to be extracted. + * @return The amount of energy taken from this source. + */ + public int distributeClockworkEnergy(ForgeDirection direction, int maxExtraction); +} diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/block/clockwork/IClockworkTile.java b/src/main/java/lumaceon/mods/clockworkphase2/api/block/clockwork/IClockworkTile.java new file mode 100644 index 0000000..69234fb --- /dev/null +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/block/clockwork/IClockworkTile.java @@ -0,0 +1,14 @@ +package lumaceon.mods.clockworkphase2.api.block.clockwork; + +public interface IClockworkTile +{ + public int getMaxCapacity(); + public int getEnergyStored(); + + /** + * All clockwork tiles can be wound up, regardless of whether they are a destination or not. + * @param tension Tension to wind. + * @return The tension that was wound. + */ + public int wind(int tension); +} diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/item/ITimeSand.java b/src/main/java/lumaceon/mods/clockworkphase2/api/item/ITimeSand.java index b924adf..d272e8c 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/item/ITimeSand.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/item/ITimeSand.java @@ -5,16 +5,16 @@ public interface ITimeSand { - public long getTimeSand(ItemStack item); + public int getTimeSand(ItemStack item); /** * Returns only this item's max time sand, does not take into account internal temporal cores. * @param item Item to check. * @return The max time sand for this item. */ - public long getMaxTimeSand(ItemStack item); - public void setTimeSand(ItemStack item, EntityPlayer player, long timeSand); - public void setTimeSand(ItemStack item, long timeSand); //Overloaded version for when there is no player involved. + public int getMaxTimeSand(ItemStack item); + public void setTimeSand(ItemStack item, EntityPlayer player, int timeSand); + public void setTimeSand(ItemStack item, int timeSand); //Overloaded version for when there is no player involved. /** * Called to add time sand to the given itemstack. * @param item The itemstack to add timesand to. @@ -22,8 +22,8 @@ public interface ITimeSand * @param amount The amount of time sand to add. * @return The amount of time sand that was successfully added. */ - public long addTimeSand(ItemStack item, EntityPlayer player, long amount); - public long addTimeSand(ItemStack item, long amount); //Overloaded version for when there is no player involved. + public int addTimeSand(ItemStack item, EntityPlayer player, int amount); + public int addTimeSand(ItemStack item, int amount); //Overloaded version for when there is no player involved. /** * Called to remove time sand from the given itemstack. @@ -32,6 +32,6 @@ public interface ITimeSand * @param amount The amount of time sand to consume. * @return The amount of time sand that was successfully consumed. */ - public long consumeTimeSand(ItemStack item, EntityPlayer player, long amount); - public long consumeTimeSand(ItemStack item, long amount); //Overloaded version for when there is no player involved. + public int consumeTimeSand(ItemStack item, EntityPlayer player, int amount); + public int consumeTimeSand(ItemStack item, int amount); //Overloaded version for when there is no player involved. } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/item/clockwork/IClockworkComponent.java b/src/main/java/lumaceon/mods/clockworkphase2/api/item/clockwork/IClockworkComponent.java index a689474..7044a01 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/item/clockwork/IClockworkComponent.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/item/clockwork/IClockworkComponent.java @@ -2,23 +2,20 @@ import net.minecraft.item.ItemStack; -public interface IClockworkComponent +public interface IClockworkComponent extends IClockwork { - public int getQuality(ItemStack is); - public int getSpeed(ItemStack is); - /** - * Default clockwork tools will take on the greatest harvest level found in their components. - * + * Default clockwork tools will take on the greatest 'tier' found in their components as their harvest level. + * Machines may ignore this depending on the machine in question. There is no standard convention for component tier + * use in machines, so base your tier off of the (sometimes theoretical) pickaxe mining level. * -1 - Hand. - * 0 - Wood. - * 1 - Stone. - * 2 - Iron (and most metals). - * 3 - Diamond. - * 4 - Modded materials (Alumite and similar materials from tinker's construct). - * 5 - Modded materials (Manyullyn from tinker's construct). - * 6+ - Modded materials. - * @return This component's harvest level. + * 0 - Wood pickaxe. + * 1 - Stone pickaxe. + * 2 - Iron pickaxe. + * 3 - Diamond pickaxe. + * 4 - Mod tools (Not used in vanilla, a good example is the Alumite pickaxe from Tinker's Construct). + * 5 - Mod tools (Not used in vanilla, a good example is the Manyullyn pickaxe from Tinker's Construct). + * @return This component's tier. */ - public int getHarvestLevel(ItemStack is); + public int getTier(ItemStack is); } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/item/clockwork/IClockworkConstruct.java b/src/main/java/lumaceon/mods/clockworkphase2/api/item/clockwork/IClockworkConstruct.java index 0fb8c59..d06cdde 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/item/clockwork/IClockworkConstruct.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/item/clockwork/IClockworkConstruct.java @@ -5,14 +5,19 @@ import java.util.List; -public interface IClockworkConstruct +public interface IClockworkConstruct extends IClockwork { + public int getTier(ItemStack item); public int getTension(ItemStack item); public int getMaxTension(ItemStack item); - public int getQuality(ItemStack item); - public int getSpeed(ItemStack item); public void setTension(ItemStack item, int tension); - public void setHarvestLevels(ItemStack item, int harvestLevel); + + /** + * Sets the 'tier' of this construct's clockwork. This is context sensitive; in clockwork tools this sets the + * appropriate harvest level, but in machines it's usually ignored or saved and referred to directly. + * @param tier The tier to set up, which is set by the highest tiered component in the clockwork. + */ + public void setTier(ItemStack item, int tier); /** * Used by a winding box and similar contraptions to add tension to this item. @@ -33,5 +38,5 @@ public interface IClockworkConstruct * @param item The itemstack to add information for. * @param list The list of informative lines. */ - public void addClockworkInformation(ItemStack item, EntityPlayer player, List list); + public void addConstructInformation(ItemStack item, EntityPlayer player, List list); } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/item/timestream/IReversableTimestream.java b/src/main/java/lumaceon/mods/clockworkphase2/api/item/timestream/IReversableTimestream.java deleted file mode 100644 index d3c17b7..0000000 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/item/timestream/IReversableTimestream.java +++ /dev/null @@ -1,18 +0,0 @@ -package lumaceon.mods.clockworkphase2.api.item.timestream; - -import net.minecraft.item.ItemStack; - -/** - * Used in the timestream cannibalizer to reverse this timestream. Most generating timestreams are reverse timestreams. - * The resultant timestream should also be reversible to allow 2-way reversals. - */ -public interface IReversableTimestream extends ITimestream -{ - /** - * Called from the timestream cannibalizer to reverse this timestream's function. Reversed timestreams are usually - * considered cannibalistic timestreams; in most cases (though not all cases), they consume effects and generate - * time sand. - * @param item The IReversableTimestream stack to reverse. - */ - public void reverseTimestream(ItemStack item); -} \ No newline at end of file diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/item/timestream/ITimestream.java b/src/main/java/lumaceon/mods/clockworkphase2/api/item/timestream/ITimestream.java deleted file mode 100644 index 9db5a07..0000000 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/item/timestream/ITimestream.java +++ /dev/null @@ -1,5 +0,0 @@ -package lumaceon.mods.clockworkphase2.api.item.timestream; - -import lumaceon.mods.clockworkphase2.api.ITemporalMaterial; - -public interface ITimestream extends ITemporalMaterial {} \ No newline at end of file diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/steammachine/ISteamProvider.java b/src/main/java/lumaceon/mods/clockworkphase2/api/steammachine/ISteamProvider.java deleted file mode 100644 index 8141b76..0000000 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/steammachine/ISteamProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -package lumaceon.mods.clockworkphase2.api.steammachine; - -import net.minecraftforge.common.util.ForgeDirection; - -/** - * Tile Entities implementing this interface are considered capable of providing steam to connected pipes. - */ -public interface ISteamProvider -{ - /** - * Drains steam from this tile. - * @param drainingFrom The direction to drain from. - * @param amountToDrain The amount of steam to drain. - * @return The amount of steam that was drained. - */ - public int drain(ForgeDirection drainingFrom, int amountToDrain); - - public int getSteamAvailable(ForgeDirection drainingFrom); - - public boolean canDrainFrom(ForgeDirection direction); -} diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/time/ITimeContainerItem.java b/src/main/java/lumaceon/mods/clockworkphase2/api/time/ITimeContainerItem.java index 822d8ed..9060b26 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/time/ITimeContainerItem.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/time/ITimeContainerItem.java @@ -18,7 +18,7 @@ public interface ITimeContainerItem * @param simulate If true, a simulation will occur, but no time will actually be added. * @return The amount of time that was added successfully (or would have been added if simulated). */ - public long receiveTime(ItemStack timeItem, long maxReceive, boolean simulate); + public int receiveTime(ItemStack timeItem, int maxReceive, boolean simulate); /** * Extracts time from the timeItem passed in. @@ -27,15 +27,15 @@ public interface ITimeContainerItem * @param simulate If true, a simulation will occur, but no time will actually be removed. * @return The amount of time that was removed successfully (or would have been removed if simulated). */ - public long extractTime(ItemStack timeItem, long maxExtract, boolean simulate); + public int extractTime(ItemStack timeItem, int maxExtract, boolean simulate); /** * Returns the maximum amount of time that can be stored in this ItemStack. */ - public long getMaxCapacity(ItemStack timeItem); + public int getMaxCapacity(ItemStack timeItem); /** * Returns the amount of time that's stored in this ItemStack. */ - public long getTimeStored(ItemStack timeItem); + public int getTimeStored(ItemStack timeItem); } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/time/ITimeProvider.java b/src/main/java/lumaceon/mods/clockworkphase2/api/time/ITimeProvider.java index 9ebf93e..e6b0cd4 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/time/ITimeProvider.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/time/ITimeProvider.java @@ -16,15 +16,15 @@ public interface ITimeProvider extends ITimeConnection * @param simulate If true, a simulation will occur, but no time will actually be removed. * @return The amount of time that was removed successfully (or would have been removed if simulated). */ - public long extractTime(long maxExtract, boolean simulate); + public int extractTime(int maxExtract, boolean simulate); /** * Returns the maximum amount of time that can be stored. */ - public long getMaxCapacity(); + public int getMaxCapacity(); /** * Returns the amount of time that's stored. */ - public long getTimeStored(); + public int getTimeStored(); } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/time/ITimeReceiver.java b/src/main/java/lumaceon/mods/clockworkphase2/api/time/ITimeReceiver.java index d9238eb..15d47a3 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/time/ITimeReceiver.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/time/ITimeReceiver.java @@ -16,15 +16,15 @@ public interface ITimeReceiver extends ITimeConnection * @param simulate If true, a simulation will occur, but no time will actually be added. * @return The amount of time that was added successfully (or would have been added if simulated). */ - public long receiveTime(long maxReceive, boolean simulate); + public int receiveTime(int maxReceive, boolean simulate); /** * Returns the maximum amount of time that can be stored. */ - public long getMaxCapacity(); + public int getMaxCapacity(); /** * Returns the amount of time that's stored. */ - public long getTimeStored(); + public int getTimeStored(); } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/time/ITimeStorage.java b/src/main/java/lumaceon/mods/clockworkphase2/api/time/ITimeStorage.java index cbc5c60..29b0927 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/time/ITimeStorage.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/time/ITimeStorage.java @@ -15,7 +15,7 @@ public interface ITimeStorage * @param simulate If true, a simulation will occur, but no time will actually be added. * @return The amount of time that was added successfully (or would have been added if simulated). */ - public long receiveTime(long maxReceive, boolean simulate); + public int receiveTime(int maxReceive, boolean simulate); /** * Extract time from this storage. @@ -23,15 +23,15 @@ public interface ITimeStorage * @param simulate If true, a simulation will occur, but no time will actually be removed. * @return The amount of time that was removed successfully (or would have been removed if simulated). */ - public long extractTime(long maxExtract, boolean simulate); + public int extractTime(int maxExtract, boolean simulate); /** * Returns the maximum amount of time that can be stored. */ - public long getMaxCapacity(); + public int getMaxCapacity(); /** * Returns the amount of time that's in this storage. */ - public long getTimeStored(); + public int getTimeStored(); } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/time/ItemTimeContainer.java b/src/main/java/lumaceon/mods/clockworkphase2/api/time/ItemTimeContainer.java index 8b41612..1c6711d 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/time/ItemTimeContainer.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/time/ItemTimeContainer.java @@ -7,9 +7,9 @@ public class ItemTimeContainer extends Item implements ITimeContainerItem { - public long capacity; + public int capacity; - public ItemTimeContainer(int maxStack, int maxDamage, long capacity) + public ItemTimeContainer(int maxStack, int maxDamage, int capacity) { this.setMaxStackSize(maxStack); this.setMaxDamage(maxDamage); @@ -17,36 +17,36 @@ public ItemTimeContainer(int maxStack, int maxDamage, long capacity) } @Override - public long receiveTime(ItemStack timeItem, long maxReceive, boolean simulate) + public int receiveTime(ItemStack timeItem, int maxReceive, boolean simulate) { - long currentTime = NBTHelper.LONG.get(timeItem, NBTTags.TIME); - long timeReceived = Math.min(getEmptySpace(timeItem), maxReceive); + int currentTime = NBTHelper.INT.get(timeItem, NBTTags.TIME); + int timeReceived = Math.min(getEmptySpace(timeItem), maxReceive); if(!simulate) - NBTHelper.LONG.set(timeItem, NBTTags.TIME, currentTime + timeReceived); + NBTHelper.INT.set(timeItem, NBTTags.TIME, currentTime + timeReceived); return timeReceived; } @Override - public long extractTime(ItemStack timeItem, long maxExtract, boolean simulate) + public int extractTime(ItemStack timeItem, int maxExtract, boolean simulate) { - long currentTime = NBTHelper.LONG.get(timeItem, NBTTags.TIME); - long timeExtracted = Math.min(currentTime, maxExtract); + int currentTime = NBTHelper.INT.get(timeItem, NBTTags.TIME); + int timeExtracted = Math.min(currentTime, maxExtract); if(!simulate) - NBTHelper.LONG.set(timeItem, NBTTags.TIME, currentTime - timeExtracted); + NBTHelper.INT.set(timeItem, NBTTags.TIME, currentTime - timeExtracted); return timeExtracted; } @Override - public long getMaxCapacity(ItemStack timeItem) { + public int getMaxCapacity(ItemStack timeItem) { return capacity; } @Override - public long getTimeStored(ItemStack timeItem) { - return NBTHelper.LONG.get(timeItem, NBTTags.TIME); + public int getTimeStored(ItemStack timeItem) { + return NBTHelper.INT.get(timeItem, NBTTags.TIME); } - public long getEmptySpace(ItemStack timeItem) { + public int getEmptySpace(ItemStack timeItem) { return getMaxCapacity(timeItem) - getTimeStored(timeItem); } } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/time/TimeStorage.java b/src/main/java/lumaceon/mods/clockworkphase2/api/time/TimeStorage.java index 7638fea..bbf38c8 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/time/TimeStorage.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/time/TimeStorage.java @@ -12,29 +12,29 @@ */ public class TimeStorage implements ITimeStorage { - protected long time, capacity; + protected int time, capacity; - public TimeStorage(long capacity) { + public TimeStorage(int capacity) { this.capacity = capacity; } public TimeStorage writeToNBT(NBTTagCompound nbt) { - nbt.setLong("time_stored", time); - nbt.setLong("storage_cap", capacity); + nbt.setInteger("time_stored", time); + nbt.setInteger("storage_cap", capacity); return this; } public NBTTagCompound readFromNBT(NBTTagCompound nbt) { if(nbt.hasKey("time_stored")) - time = nbt.getLong("time_stored"); + time = nbt.getInteger("time_stored"); if(nbt.hasKey("storage_cap")) - capacity = nbt.getLong("storage_cap"); + capacity = nbt.getInteger("storage_cap"); return nbt; } - public void setCapacity(long capacity) + public void setCapacity(int capacity) { this.capacity = capacity; if(getTimeStored() > getMaxCapacity()) @@ -42,34 +42,34 @@ public void setCapacity(long capacity) } @Override - public long receiveTime(long maxReceive, boolean simulate) + public int receiveTime(int maxReceive, boolean simulate) { - long timeReceived = Math.min(getEmptySpace(), maxReceive); + int timeReceived = Math.min(getEmptySpace(), maxReceive); if(!simulate) time += timeReceived; return timeReceived; } @Override - public long extractTime(long maxExtract, boolean simulate) + public int extractTime(int maxExtract, boolean simulate) { - long timeExtracted = Math.min(time, maxExtract); + int timeExtracted = Math.min(time, maxExtract); if(!simulate) time -= timeExtracted; return timeExtracted; } @Override - public long getMaxCapacity() { + public int getMaxCapacity() { return capacity; } @Override - public long getTimeStored() { + public int getTimeStored() { return time; } - public long getEmptySpace() { + public int getEmptySpace() { return getMaxCapacity() - getTimeStored(); } } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/time/TimezoneHandler.java b/src/main/java/lumaceon/mods/clockworkphase2/api/time/TimezoneHandler.java index a73ecaa..c09ea17 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/time/TimezoneHandler.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/time/TimezoneHandler.java @@ -1,5 +1,6 @@ package lumaceon.mods.clockworkphase2.api.time; +import lumaceon.mods.clockworkphase2.api.block.ITimezoneProvider; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; @@ -13,7 +14,7 @@ public class TimezoneHandler * @param world The world to search. * @return A Timezone class that holds timesand and other time-streams. */ - public static ITimezone getTimeZone(double x, double y, double z, World world) + public static ITimezoneProvider getTimeZone(double x, double y, double z, World world) { for(int[] timezone : timezones) { @@ -21,9 +22,9 @@ public static ITimezone getTimeZone(double x, double y, double z, World world) if(sameWorld) { TileEntity te = world.getTileEntity(timezone[0], timezone[1], timezone[2]); - if(te != null && te instanceof ITimezone) + if(te != null && te instanceof ITimezoneProvider) { - ITimezone tz = (ITimezone) te; + ITimezoneProvider tz = (ITimezoneProvider) te; double dist = Math.sqrt(Math.pow(x - timezone[0], 2) + Math.pow(z - timezone[2], 2)); boolean inRange = dist <= tz.getRange(); @@ -41,7 +42,7 @@ public static ITimezone getTimeZone(double x, double y, double z, World world) * Returns the timezone encompassing the given area on the given dimension, or null if none exist. * @return A Timezone class that holds timesand and other time-streams. */ - public static ITimezone getTimeZone(double x, double y, double z, int dimensionId) + public static ITimezoneProvider getTimeZone(double x, double y, double z, int dimensionId) { for(int[] timezone : timezones) { @@ -49,9 +50,9 @@ public static ITimezone getTimeZone(double x, double y, double z, int dimensionI if(sameWorld) { TileEntity te = DimensionManager.getWorld(dimensionId).getTileEntity(timezone[0], timezone[1], timezone[2]); - if(te != null && te instanceof ITimezone) + if(te != null && te instanceof ITimezoneProvider) { - ITimezone tz = (ITimezone) te; + ITimezoneProvider tz = (ITimezoneProvider) te; double dist = Math.sqrt(Math.pow(x - timezone[0], 2) + Math.pow(z - timezone[2], 2)); boolean inRange = dist <= tz.getRange(); @@ -117,7 +118,7 @@ public static void pingAndCleanTimezones() timezone = timezones.get(n); World world = DimensionManager.getWorld(timezone[3]); TileEntity te = world.getTileEntity(timezone[0], timezone[1], timezone[2]); - boolean tzExists = te != null && te instanceof ITimezone; + boolean tzExists = te != null && te instanceof ITimezoneProvider; if(!tzExists) { timezones.remove(n); diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/util/AssemblyHelper.java b/src/main/java/lumaceon/mods/clockworkphase2/api/util/AssemblyHelper.java index fc3abfd..e2d31f8 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/util/AssemblyHelper.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/util/AssemblyHelper.java @@ -2,7 +2,6 @@ import lumaceon.mods.clockworkphase2.api.assembly.ContainerAssemblyTable; import lumaceon.mods.clockworkphase2.api.assembly.InventoryAssemblyTableComponents; -import lumaceon.mods.clockworkphase2.api.item.ITemporalToolModule; import lumaceon.mods.clockworkphase2.api.item.clockwork.IClockworkComponent; import lumaceon.mods.clockworkphase2.api.item.clockwork.IClockworkConstruct; import lumaceon.mods.clockworkphase2.api.util.internal.NBTHelper; @@ -57,15 +56,15 @@ public static void assembleClockworkCore(ContainerAssemblyTable container) { quality += ((IClockworkComponent) item.getItem()).getQuality(item); speed += ((IClockworkComponent) item.getItem()).getSpeed(item); - harvestLevel = Math.max(harvestLevel, ((IClockworkComponent) item.getItem()).getHarvestLevel(item)); + harvestLevel = Math.max(harvestLevel, ((IClockworkComponent) item.getItem()).getTier(item)); } } NBTHelper.INT.set(mainItem, NBTTags.QUALITY, quality); NBTHelper.INT.set(mainItem, NBTTags.SPEED, speed); - NBTHelper.INT.set(mainItem, NBTTags.HARVEST_LEVEL, harvestLevel); + NBTHelper.INT.set(mainItem, NBTTags.TIER, harvestLevel); } - public static void assembleClockworkTool(ContainerAssemblyTable container, int mainspringSlotIndex, int clockworkSlotIndex) + public static void assembleClockworkConstruct(ContainerAssemblyTable container, int mainspringSlotIndex, int clockworkSlotIndex) { ItemStack mainItem = container.mainInventory.getStackInSlot(0); ItemStack mainspring = container.componentInventory.getStackInSlot(mainspringSlotIndex); @@ -89,14 +88,14 @@ public static void assembleClockworkTool(ContainerAssemblyTable container, int m NBTHelper.INT.set(mainItem, NBTTags.QUALITY, NBTHelper.INT.get(clockwork, NBTTags.QUALITY)); NBTHelper.INT.set(mainItem, NBTTags.SPEED, NBTHelper.INT.get(clockwork, NBTTags.SPEED)); if(mainItem.getItem() instanceof IClockworkConstruct) - ((IClockworkConstruct) mainItem.getItem()).setHarvestLevels(mainItem, NBTHelper.INT.get(clockwork, NBTTags.HARVEST_LEVEL)); + ((IClockworkConstruct) mainItem.getItem()).setTier(mainItem, NBTHelper.INT.get(clockwork, NBTTags.TIER)); } else { NBTHelper.INT.set(mainItem, NBTTags.QUALITY, 0); NBTHelper.INT.set(mainItem, NBTTags.SPEED, 0); if(mainItem.getItem() instanceof IClockworkConstruct) - ((IClockworkConstruct) mainItem.getItem()).setHarvestLevels(mainItem, -1); + ((IClockworkConstruct) mainItem.getItem()).setTier(mainItem, -1); } } } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/util/ClockworkHelper.java b/src/main/java/lumaceon/mods/clockworkphase2/api/util/ClockworkHelper.java index e87fed8..b77bc7a 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/util/ClockworkHelper.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/util/ClockworkHelper.java @@ -2,33 +2,37 @@ import lumaceon.mods.clockworkphase2.api.item.clockwork.IClockworkConstruct; import lumaceon.mods.clockworkphase2.api.util.internal.NBTHelper; +import lumaceon.mods.clockworkphase2.api.util.internal.NBTTags; import net.minecraft.item.ItemStack; public class ClockworkHelper { - public static final String MAX_TENSION = "max_tension"; - public static final String CURRENT_TENSION = "current_tension"; - public static final String QUALITY = "cp_quality"; - public static final String SPEED = "cp_speed"; - public static int getMaxTension(ItemStack item) { - return NBTHelper.hasTag(item, MAX_TENSION) ? NBTHelper.INT.get(item, MAX_TENSION) : 0; + return NBTHelper.hasTag(item, NBTTags.MAX_TENSION) ? NBTHelper.INT.get(item, NBTTags.MAX_TENSION) : 0; } public static int getTension(ItemStack item) { - return NBTHelper.hasTag(item, CURRENT_TENSION) ? NBTHelper.INT.get(item, CURRENT_TENSION) : 0; + return NBTHelper.hasTag(item, NBTTags.CURRENT_TENSION) ? NBTHelper.INT.get(item, NBTTags.CURRENT_TENSION) : 0; } public static int getQuality(ItemStack item) { - return NBTHelper.hasTag(item, QUALITY) ? NBTHelper.INT.get(item, QUALITY) : 0; + return NBTHelper.hasTag(item, NBTTags.QUALITY) ? NBTHelper.INT.get(item, NBTTags.QUALITY) : 0; } public static int getSpeed(ItemStack item) { - return NBTHelper.hasTag(item, SPEED) ? NBTHelper.INT.get(item, SPEED) : 0; + return NBTHelper.hasTag(item, NBTTags.SPEED) ? NBTHelper.INT.get(item, NBTTags.SPEED) : 0; + } + + public static int getTier(ItemStack item) { + return NBTHelper.hasTag(item, NBTTags.TIER) ? NBTHelper.INT.get(item, NBTTags.TIER) : 0; } public static void setTension(ItemStack item, int tension) { - NBTHelper.INT.set(item, CURRENT_TENSION, tension); + NBTHelper.INT.set(item, NBTTags.CURRENT_TENSION, tension); + } + + public static void setTier(ItemStack item, int tier) { + NBTHelper.INT.set(item, NBTTags.TIER, tier); } public static int addTension(ItemStack item, int tension) @@ -101,4 +105,18 @@ public static int getTensionCostFromStats(int baseCost, int quality, int speed) float efficiency = (float) speed / quality; return (int) Math.round(baseCost * Math.pow(efficiency, 2)); } + + /** + * Used by machines (or items) that wish to have work speed increase exponentially with the speed stat. This method + * provides a standard most clockwork machines follow, which assumes a 'par' speed of 200. + * @param speed The speed of the clockwork. + * @return A multiplier for the work done per tick, which can be less than 1 in cases where speed is poor (<200). + */ + public static double getStandardExponentialSpeedMultiplier(int speed) + { + if(speed <= 0) + return 0; + double d = (double) speed; + return Math.pow(d/200.0, 3.5); + } } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/util/InformationDisplay.java b/src/main/java/lumaceon/mods/clockworkphase2/api/util/InformationDisplay.java index 20b7290..88376c4 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/util/InformationDisplay.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/util/InformationDisplay.java @@ -23,6 +23,11 @@ public class InformationDisplay public static int defaultTensionPerBlock = 50; + /** + * Adds information based on a simple clockwork component (such as a gear). + * @param component + * @param list + */ public static void addClockworkComponentInformation(ItemStack component, List list) { if(component.getItem() instanceof IClockworkComponent) @@ -30,7 +35,7 @@ public static void addClockworkComponentInformation(ItemStack component, List li IClockworkComponent clockworkComponent = (IClockworkComponent) component.getItem(); int quality = clockworkComponent.getQuality(component); int speed = clockworkComponent.getSpeed(component); - int harvestLevel = clockworkComponent.getHarvestLevel(component); + int harvestLevel = clockworkComponent.getTier(component); String color = getColorFromComponentStat(quality); if(quality > 0) @@ -42,7 +47,13 @@ public static void addClockworkComponentInformation(ItemStack component, List li } } - public static void addClockworkConstructInformation(ItemStack construct, EntityPlayer player, List list, boolean isTool) + /** + * Used as a conventional tool-tip for clockwork itemstacks. Call during addInformation() in a custom Item class. + * @param construct Itemstack representing the construct. + * @param player Player looking at the itemstack. + * @param list A list of information to add to. + */ + public static void addClockworkConstructInformation(ItemStack construct, EntityPlayer player, List list, boolean flag) { if(construct.getItem() instanceof IClockworkConstruct) { @@ -57,7 +68,7 @@ public static void addClockworkConstructInformation(ItemStack construct, EntityP { list.add(""); list.add(Colors.BLUE + "~/Construct Details\\~"); - clockworkConstruct.addClockworkInformation(construct, player, list); + clockworkConstruct.addConstructInformation(construct, player, list); list.add(Colors.BLUE + "~/Construct Details\\~"); list.add(""); } @@ -83,17 +94,14 @@ public static void addClockworkConstructInformation(ItemStack construct, EntityP public static void addClockworkToolInformation(ItemStack tool, EntityPlayer player, List list) { - if(tool.getItem() instanceof IClockworkConstruct) - { - IClockworkConstruct clockworkComponent = (IClockworkConstruct) tool.getItem(); - int quality = clockworkComponent.getQuality(tool); - int speed = clockworkComponent.getSpeed(tool); - int harvestLevel = Math.max(Math.max(tool.getItem().getHarvestLevel(tool, "pickaxe"), tool.getItem().getHarvestLevel(tool, "axe")), tool.getItem().getHarvestLevel(tool, "shovel")); - - list.add(Colors.WHITE + "Harvest Level: " + Colors.GOLD + harvestLevel + " " + getMaterialNameFromHarvestLevel(harvestLevel)); - list.add(Colors.WHITE + "Mining Speed: " + Colors.GOLD + speed / 25); - list.add(Colors.WHITE + "Tension Per Block: " + Colors.GOLD + ClockworkHelper.getTensionCostFromStats(defaultTensionPerBlock, quality, speed)); - } + IClockworkConstruct clockworkComponent = (IClockworkConstruct) tool.getItem(); + int quality = clockworkComponent.getQuality(tool); + int speed = clockworkComponent.getSpeed(tool); + int harvestLevel = Math.max(Math.max(tool.getItem().getHarvestLevel(tool, "pickaxe"), tool.getItem().getHarvestLevel(tool, "axe")), tool.getItem().getHarvestLevel(tool, "shovel")); + + list.add(Colors.WHITE + "Harvest Level: " + Colors.GOLD + harvestLevel + " " + getMaterialNameFromHarvestLevel(harvestLevel)); + list.add(Colors.WHITE + "Mining Speed: " + Colors.GOLD + speed / 25); + list.add(Colors.WHITE + "Tension Per Block: " + Colors.GOLD + ClockworkHelper.getTensionCostFromStats(defaultTensionPerBlock, quality, speed)); } public static void addMainspringInformation(ItemStack is, List list) diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/util/TimeConverter.java b/src/main/java/lumaceon/mods/clockworkphase2/api/util/TimeConverter.java index 22bb349..203aa14 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/util/TimeConverter.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/util/TimeConverter.java @@ -1,26 +1,15 @@ package lumaceon.mods.clockworkphase2.api.util; -/** - * The times used here follow this article - http://en.wikipedia.org/wiki/Unit_of_time - * Yottaseconds? Ain't nobody got time for that. - */ public class TimeConverter { - public static final long SECOND = 20; - public static final long MINUTE = SECOND * 60; //1200 - public static final long HOUR = MINUTE * 60; //72,000 - public static final long DAY = HOUR * 24; //1,728,000 - public static final long WEEK = DAY * 7; //12,096,000 - Skipped in most cases. - public static final long MONTH = DAY * 30; //51,840,000 - public static final long YEAR = MONTH * 12; //622,080,000 - public static final long DECADE = YEAR * 10; //6,220,800,000 - public static final long CENTURY = YEAR * 100; //62,208,000,000 - public static final long MILLENNIUM = YEAR * 1000; //622,080,000,000 - public static final long TERASECOND = 20000000000000L; //20,000,000,000,000 | one trillion seconds. - public static final long EPOCH = YEAR * 10000000; //6,220,800,000,000,000 | 10 million years. - public static final long ERA = EPOCH * 10; //62,208,000,000,000,000 | 100 million years. - public static final long EON = ERA * 10; //622,080,000,000,000,000 | 1 billion years. - public static final long INFINITE = 9223372036854775807L; //Never shown: if this is acquired, do something cool. + public static final int SECOND = 20; + public static final int MINUTE = SECOND * 60; //1200 + public static final int HOUR = MINUTE * 60; //72,000 + public static final int DAY = HOUR * 24; //1,728,000 + public static final int WEEK = DAY * 7; //12,096,000 - Skipped in most cases. + public static final int MONTH = DAY * 30; //51,840,000 + public static final int YEAR = MONTH * 12; //622,080,000 + public static final long INFINITE = Integer.MAX_VALUE; //Never shown: if this is acquired, do something cool. /** * Takes a number of time sand and parses it into a readable time, much like a clock. The field typesToParse allows @@ -28,135 +17,19 @@ public class TimeConverter * * For example: calling parseNumber(3740, 2) would return "1 Hour, 2 Minutes" as a string. * Calling parseNumber(3740, 3) would, instead, return "1 Hour, 2 Minutes, 20 Seconds" as a string. - * @param timeSand The time sand number to parse. + * @param time The time sand number to parse. * @param typesToParse The maximum amount of times names to parse, after which, others will be ignored. (max 15) * @return A string representing the time sand in time format. */ - public static String parseNumber(long timeSand, int typesToParse) + public static String parseNumber(int time, int typesToParse) { String parsedString = ""; int pass = 0; long numberOf; - if(timeSand >= EON) + if(time >= YEAR) { - numberOf = timeSand / EON; - parsedString = parsedString.concat(Long.toString(numberOf)); - parsedString = parsedString.concat(" Eon"); - if(numberOf > 1) - parsedString = parsedString.concat("s"); - pass++; - if(pass == typesToParse) - return parsedString; - else - timeSand -= EON * numberOf; - } - - if(timeSand >= ERA) - { - numberOf = timeSand / ERA; - if(pass > 0) - parsedString = parsedString.concat(", "); - parsedString = parsedString.concat(Long.toString(numberOf)); - parsedString = parsedString.concat(" Era"); - if(numberOf > 1) - parsedString = parsedString.concat("s"); - pass++; - if(pass == typesToParse) - return parsedString; - else - timeSand -= ERA * numberOf; - } - - if(timeSand >= EPOCH) - { - numberOf = timeSand / EPOCH; - if(pass > 0) - parsedString = parsedString.concat(", "); - parsedString = parsedString.concat(Long.toString(numberOf)); - parsedString = parsedString.concat(" Epoch"); - if(numberOf > 1) - parsedString = parsedString.concat("s"); - pass++; - if(pass == typesToParse) - return parsedString; - else - timeSand -= EPOCH * numberOf; - } - - if(timeSand >= TERASECOND) - { - numberOf = timeSand / TERASECOND; - if(pass > 0) - parsedString = parsedString.concat(", "); - parsedString = parsedString.concat(Long.toString(numberOf)); - parsedString = parsedString.concat(" Terasecond"); - if(numberOf > 1) - parsedString = parsedString.concat("s"); - pass++; - if(pass == typesToParse) - return parsedString; - else - timeSand -= TERASECOND * numberOf; - } - - if(timeSand >= MILLENNIUM) - { - numberOf = timeSand / MILLENNIUM; - if(pass > 0) - parsedString = parsedString.concat(", "); - parsedString = parsedString.concat(Long.toString(numberOf)); - parsedString = parsedString.concat(" Millenni"); - if(numberOf > 1) - parsedString = parsedString.concat("um"); - else - parsedString = parsedString.concat("a"); - pass++; - if(pass == typesToParse) - return parsedString; - else - timeSand -= MILLENNIUM * numberOf; - } - - if(timeSand >= CENTURY) - { - numberOf = timeSand / CENTURY; - if(pass > 0) - parsedString = parsedString.concat(", "); - parsedString = parsedString.concat(Long.toString(numberOf)); - parsedString = parsedString.concat(" Centur"); - if(numberOf > 1) - parsedString = parsedString.concat("ies"); - else - parsedString = parsedString.concat("y"); - pass++; - if(pass == typesToParse) - return parsedString; - else - timeSand -= CENTURY * numberOf; - } - - if(timeSand >= DECADE) - { - numberOf = timeSand / DECADE; - if(pass > 0) - parsedString = parsedString.concat(", "); - parsedString = parsedString.concat(Long.toString(numberOf)); - parsedString = parsedString.concat(" Decade"); - if(numberOf > 1) - parsedString = parsedString.concat("s"); - pass++; - if(pass == typesToParse) - return parsedString; - else - timeSand -= DECADE * numberOf; - } - - if(timeSand >= YEAR) - { - numberOf = timeSand / YEAR; - if(pass > 0) - parsedString = parsedString.concat(", "); + numberOf = time / YEAR; parsedString = parsedString.concat(Long.toString(numberOf)); parsedString = parsedString.concat(" Year"); if(numberOf > 1) @@ -165,12 +38,12 @@ public static String parseNumber(long timeSand, int typesToParse) if(pass == typesToParse) return parsedString; else - timeSand -= YEAR * numberOf; + time -= YEAR * numberOf; } - if(timeSand >= MONTH) + if(time >= MONTH) { - numberOf = timeSand / MONTH; + numberOf = time / MONTH; if(pass > 0) parsedString = parsedString.concat(", "); parsedString = parsedString.concat(Long.toString(numberOf)); @@ -181,12 +54,12 @@ public static String parseNumber(long timeSand, int typesToParse) if(pass == typesToParse) return parsedString; else - timeSand -= MONTH * numberOf; + time -= MONTH * numberOf; } - if(timeSand >= DAY) + if(time >= DAY) { - numberOf = timeSand / DAY; + numberOf = time / DAY; if(pass > 0) parsedString = parsedString.concat(", "); parsedString = parsedString.concat(Long.toString(numberOf)); @@ -197,12 +70,12 @@ public static String parseNumber(long timeSand, int typesToParse) if(pass == typesToParse) return parsedString; else - timeSand -= DAY * numberOf; + time -= DAY * numberOf; } - if(timeSand >= HOUR) + if(time >= HOUR) { - numberOf = timeSand / HOUR; + numberOf = time / HOUR; if(pass > 0) parsedString = parsedString.concat(", "); parsedString = parsedString.concat(Long.toString(numberOf)); @@ -213,12 +86,12 @@ public static String parseNumber(long timeSand, int typesToParse) if(pass == typesToParse) return parsedString; else - timeSand -= HOUR * numberOf; + time -= HOUR * numberOf; } - if(timeSand >= MINUTE) + if(time >= MINUTE) { - numberOf = timeSand / MINUTE; + numberOf = time / MINUTE; if(pass > 0) parsedString = parsedString.concat(", "); parsedString = parsedString.concat(Long.toString(numberOf)); @@ -229,12 +102,12 @@ public static String parseNumber(long timeSand, int typesToParse) if(pass == typesToParse) return parsedString; else - timeSand -= MINUTE * numberOf; + time -= MINUTE * numberOf; } - if(timeSand >= SECOND) + if(time >= SECOND) { - numberOf = timeSand / SECOND; + numberOf = time / SECOND; if(pass > 0) parsedString = parsedString.concat(", "); parsedString = parsedString.concat(Long.toString(numberOf)); diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/util/TimeHelper.java b/src/main/java/lumaceon/mods/clockworkphase2/api/util/TimeHelper.java index 3082f9a..fa793b3 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/util/TimeHelper.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/util/TimeHelper.java @@ -15,10 +15,10 @@ public class TimeHelper * from any of them, and this method will return false. * @return True if all the time was consumed, false if there isn't enough and none was consumed. */ - public static boolean consumeTimeAllOrNothing(IInventory inventory, long timeToConsume) + public static boolean consumeTimeAllOrNothing(IInventory inventory, int timeToConsume) { ArrayList timeSuppliers = new ArrayList(); - long timeAvailable = 0; + int timeAvailable = 0; for(int n = 0; n < inventory.getSizeInventory(); n++) { ItemStack is = inventory.getStackInSlot(n); @@ -33,7 +33,7 @@ public static boolean consumeTimeAllOrNothing(IInventory inventory, long timeToC return false; else { - long timeConsumed = 0; + int timeConsumed = 0; for(ItemStack is : timeSuppliers) { timeConsumed += ((ITimeSupplierItem) is.getItem()).extractTime(is, timeToConsume - timeConsumed, false); @@ -50,9 +50,9 @@ public static boolean consumeTimeAllOrNothing(IInventory inventory, long timeToC * @param timeToConsume The amount of time to attempt to consume. * @return The amount of time that was successfully consumed. */ - public static long consumeTimeMostPossible(IInventory inventory, long timeToConsume) + public static int consumeTimeMostPossible(IInventory inventory, int timeToConsume) { - long timeConsumed = 0; + int timeConsumed = 0; for(int n = 0; n < inventory.getSizeInventory(); n++) { ItemStack is = inventory.getStackInSlot(n); @@ -66,9 +66,9 @@ public static long consumeTimeMostPossible(IInventory inventory, long timeToCons return timeConsumed; } - public static long getTimeInInventory(IInventory inventory) + public static int getTimeInInventory(IInventory inventory) { - long timeFound = 0; + int timeFound = 0; for(int n = 0; n < inventory.getSizeInventory(); n++) { ItemStack is = inventory.getStackInSlot(n); @@ -86,13 +86,13 @@ public static long getTimeInInventory(IInventory inventory) * @param temporalExcavator The temporal excavator itemstack. * @return The time, in ticks, it takes to break the block. */ - public static long timeToBreakBlock(float blockHardness, EntityPlayer player, ItemStack temporalExcavator) + public static int timeToBreakBlock(float blockHardness, EntityPlayer player, ItemStack temporalExcavator) { float timeCostInSeconds = blockHardness * 1.5F / 8.0F; if(player.isInWater()) timeCostInSeconds *= 5.0F; if(player.isAirBorne) timeCostInSeconds *= 5.0F; - return (long) (timeCostInSeconds * 20); + return (int) (timeCostInSeconds * 20); } } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/api/util/internal/NBTTags.java b/src/main/java/lumaceon/mods/clockworkphase2/api/util/internal/NBTTags.java index 6960b1d..e4d3925 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/api/util/internal/NBTTags.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/api/util/internal/NBTTags.java @@ -10,7 +10,7 @@ public class NBTTags public static final String QUALITY = "cp_quality"; public static final String SPEED = "cp_speed"; public static final String MEMORY = "cp_memory"; - public static final String HARVEST_LEVEL = "harvest_lvl"; + public static final String TIER = "cp_tier"; public static final String HARVEST_LEVEL_PICKAXE = "harvest_lvl_pick"; public static final String HARVEST_LEVEL_AXE = "harvest_lvl_axe"; public static final String HARVEST_LEVEL_SHOVEL = "harvest_lvl_shovel"; diff --git a/src/main/java/lumaceon/mods/clockworkphase2/block/clockwork/BlockClockworkFurnace.java b/src/main/java/lumaceon/mods/clockworkphase2/block/clockwork/BlockClockworkFurnace.java new file mode 100644 index 0000000..e0b71b0 --- /dev/null +++ b/src/main/java/lumaceon/mods/clockworkphase2/block/clockwork/BlockClockworkFurnace.java @@ -0,0 +1,107 @@ +package lumaceon.mods.clockworkphase2.block.clockwork; + +import lumaceon.mods.clockworkphase2.ClockworkPhase2; +import lumaceon.mods.clockworkphase2.block.BlockClockworkPhase; +import lumaceon.mods.clockworkphase2.tile.clockwork.TileClockworkFurnace; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import java.util.ArrayList; + +public class BlockClockworkFurnace extends BlockClockworkPhase implements ITileEntityProvider +{ + public BlockClockworkFurnace(Material blockMaterial, String unlocalizedName) { + super(blockMaterial, unlocalizedName); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int meta, float f0, float f1, float f2) + { + if(player.isSneaking()) + return false; + if(!world.isRemote) + player.openGui(ClockworkPhase2.instance, 2, world, x, y, z); + return true; + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) + { + super.onBlockPlacedBy(world, x, y, z, player, stack); + TileEntity te = world.getTileEntity(x, y, z); + if(te != null && te instanceof TileClockworkFurnace) + { + TileClockworkFurnace CWFurnace = (TileClockworkFurnace) te; + CWFurnace.setTileDataFromItemStack(stack); + CWFurnace.markDirty(); + } + } + + @Override + public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) + { + if(!world.isRemote && !player.capabilities.isCreativeMode) + { + TileEntity te = world.getTileEntity(x, y, z); + if(te != null && te instanceof TileClockworkFurnace) + { + TileClockworkFurnace CWFurnace = (TileClockworkFurnace) te; + ItemStack result = CWFurnace.itemBlock.copy(); + + float f = 0.7F; + double d0 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D; + double d1 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D; + double d2 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D; + EntityItem entityitem = new EntityItem(world, x + d0, y + d1, z + d2, result); + + entityitem.delayBeforeCanPickup = 10; + world.spawnEntityInWorld(entityitem); + } + } + + return super.removedByPlayer(world, player, x, y, z, willHarvest); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) + { + ArrayList results = new ArrayList(1); + if(!world.isRemote) + { + TileEntity te = world.getTileEntity(x, y, z); + if(te != null && te instanceof TileClockworkFurnace) + { + TileClockworkFurnace CWFurnace = (TileClockworkFurnace) te; + ItemStack result = CWFurnace.itemBlock.copy(); + results.add(result); + } + } + return results; + } + + @Override + public int getRenderType() { + return -1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + return new TileClockworkFurnace(); + } +} diff --git a/src/main/java/lumaceon/mods/clockworkphase2/block/clockwork/BlockCrank.java b/src/main/java/lumaceon/mods/clockworkphase2/block/clockwork/BlockCrank.java new file mode 100644 index 0000000..3810440 --- /dev/null +++ b/src/main/java/lumaceon/mods/clockworkphase2/block/clockwork/BlockCrank.java @@ -0,0 +1,60 @@ +package lumaceon.mods.clockworkphase2.block.clockwork; + +import lumaceon.mods.clockworkphase2.api.block.clockwork.IClockworkTile; +import lumaceon.mods.clockworkphase2.block.BlockClockworkPhase; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class BlockCrank extends BlockClockworkPhase +{ + public BlockCrank(Material blockMaterial, String unlocalizedName) { + super(blockMaterial, unlocalizedName); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int meta, float f0, float f1, float f2) + { + if(!player.isSneaking()) + { + TileEntity te = world.getTileEntity(x + 1, y, z); + if(te != null && te instanceof IClockworkTile) + { + ((IClockworkTile) te).wind(1000 * 10); + return false; + } + te = world.getTileEntity(x - 1, y, z); + if(te != null && te instanceof IClockworkTile) + { + ((IClockworkTile) te).wind(1000 * 10); + return false; + } + te = world.getTileEntity(x, y + 1, z); + if(te != null && te instanceof IClockworkTile) + { + ((IClockworkTile) te).wind(1000 * 10); + return false; + } + te = world.getTileEntity(x, y - 1, z); + if(te != null && te instanceof IClockworkTile) + { + ((IClockworkTile) te).wind(1000 * 10); + return false; + } + te = world.getTileEntity(x, y, z + 1); + if(te != null && te instanceof IClockworkTile) + { + ((IClockworkTile) te).wind(1000 * 10); + return false; + } + te = world.getTileEntity(x, y, z - 1); + if(te != null && te instanceof IClockworkTile) + { + ((IClockworkTile) te).wind(1000 * 10); + return false; + } + } + return false; + } +} diff --git a/src/main/java/lumaceon/mods/clockworkphase2/block/itemblock/ItemBlockClockworkFurnace.java b/src/main/java/lumaceon/mods/clockworkphase2/block/itemblock/ItemBlockClockworkFurnace.java new file mode 100644 index 0000000..b75e835 --- /dev/null +++ b/src/main/java/lumaceon/mods/clockworkphase2/block/itemblock/ItemBlockClockworkFurnace.java @@ -0,0 +1,138 @@ +package lumaceon.mods.clockworkphase2.block.itemblock; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import lumaceon.mods.clockworkphase2.api.assembly.ContainerAssemblyTable; +import lumaceon.mods.clockworkphase2.api.assembly.IAssemblable; +import lumaceon.mods.clockworkphase2.api.assembly.InventoryAssemblyTableComponents; +import lumaceon.mods.clockworkphase2.api.item.clockwork.IClockworkConstruct; +import lumaceon.mods.clockworkphase2.api.util.AssemblyHelper; +import lumaceon.mods.clockworkphase2.api.util.ClockworkHelper; +import lumaceon.mods.clockworkphase2.api.util.InformationDisplay; +import lumaceon.mods.clockworkphase2.api.util.TimeConverter; +import lumaceon.mods.clockworkphase2.api.util.internal.Colors; +import lumaceon.mods.clockworkphase2.init.ModItems; +import lumaceon.mods.clockworkphase2.inventory.slot.SlotItemSpecific; +import lumaceon.mods.clockworkphase2.lib.Textures; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import java.util.List; + +public class ItemBlockClockworkFurnace extends ItemBlock implements IAssemblable, IClockworkConstruct +{ + public ItemBlockClockworkFurnace(Block p_i45328_1_) { + super(p_i45328_1_); + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack is, EntityPlayer player, List list, boolean flag) { + InformationDisplay.addClockworkConstructInformation(is, player, list, flag); + } + + @Override + public ResourceLocation getGUIBackground(ContainerAssemblyTable container) { + return Textures.GUI.ASSEMBLY_TABLE; + } + + @Override + public InventoryAssemblyTableComponents getGUIInventory(ContainerAssemblyTable container) { + InventoryAssemblyTableComponents inventory = new InventoryAssemblyTableComponents(container, 2, 1); + AssemblyHelper.GET_GUI_INVENTORY.loadStandardComponentInventory(container, inventory); + return inventory; + } + + @Override + public Slot[] getContainerSlots(IInventory inventory) + { + return new Slot[] + { + new SlotItemSpecific(inventory, 0, 120, 30, ModItems.mainspring), + new SlotItemSpecific(inventory, 1, 120, 54, ModItems.clockworkCore), + }; + } + + @Override + public void saveComponentInventory(ContainerAssemblyTable container) { + AssemblyHelper.SAVE_COMPONENT_INVENTORY.saveComponentInventory(container); + } + + @Override + public void onInventoryChange(ContainerAssemblyTable container) { + AssemblyHelper.ON_INVENTORY_CHANGE.assembleClockworkConstruct(container, 0, 1); + } + + @Override + public int getQuality(ItemStack item) { + return ClockworkHelper.getQuality(item); + } + + @Override + public int getSpeed(ItemStack item) { + return ClockworkHelper.getSpeed(item); + } + + @Override + public int getTier(ItemStack item) { + return ClockworkHelper.getTier(item); + } + + @Override + public int getTension(ItemStack item) { + return ClockworkHelper.getTension(item); + } + + @Override + public int getMaxTension(ItemStack item) { + return ClockworkHelper.getMaxTension(item); + } + + @Override + public void setTension(ItemStack item, int tension) { + ClockworkHelper.setTension(item, tension); + } + + @Override + public void setTier(ItemStack item, int tier) { + ClockworkHelper.setTier(item, tier); + } + + @Override + public int addTension(ItemStack item, int tension) { + return ClockworkHelper.addTension(item, tension); + } + + @Override + public int consumeTension(ItemStack item, int tension) { + return ClockworkHelper.consumeTension(item, tension); + } + + @Override + public void addConstructInformation(ItemStack item, EntityPlayer player, List list) + { + int quality = getQuality(item); + int speed = getSpeed(item); + + if(speed <= 0 || quality <= 0 || ((int) (ClockworkHelper.getStandardExponentialSpeedMultiplier(speed) * 50)) == 0) + { + list.add(Colors.RED + "NON-FUNCTIONAL"); + return; + } + + int timePerSmelt = 10000 / ((int) (ClockworkHelper.getStandardExponentialSpeedMultiplier(speed) * 50)); + if(timePerSmelt >= 20) + list.add(Colors.WHITE + "Time Per Smelt: " + Colors.GOLD + TimeConverter.parseNumber(timePerSmelt, 1)); + else if(timePerSmelt != 1) + list.add(Colors.WHITE + "Time Per Smelt: " + Colors.GOLD + timePerSmelt + " Ticks"); + else + list.add(Colors.WHITE + "Time Per Smelt: " + Colors.GOLD + "1 Tick"); + list.add(Colors.WHITE + "~Tension Used Per Operation: " + Colors.GOLD + (ClockworkHelper.getTensionCostFromStats((int) (ClockworkHelper.getStandardExponentialSpeedMultiplier(speed) * 50), quality, speed) / 50) * timePerSmelt); + list.add(Colors.WHITE + "~Tension Used Per Second: " + Colors.GOLD + (ClockworkHelper.getTensionCostFromStats((int) (ClockworkHelper.getStandardExponentialSpeedMultiplier(speed) * 50), quality, speed) / 50) * 20); + } +} diff --git a/src/main/java/lumaceon/mods/clockworkphase2/client/gui/GuiClockworkFurnace.java b/src/main/java/lumaceon/mods/clockworkphase2/client/gui/GuiClockworkFurnace.java new file mode 100644 index 0000000..5e98059 --- /dev/null +++ b/src/main/java/lumaceon/mods/clockworkphase2/client/gui/GuiClockworkFurnace.java @@ -0,0 +1,58 @@ +package lumaceon.mods.clockworkphase2.client.gui; + +import lumaceon.mods.clockworkphase2.api.util.ClockworkHelper; +import lumaceon.mods.clockworkphase2.container.ContainerClockworkFurnace; +import lumaceon.mods.clockworkphase2.lib.Textures; +import lumaceon.mods.clockworkphase2.tile.clockwork.TileClockworkFurnace; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; + +public class GuiClockworkFurnace extends GuiContainer +{ + public TileClockworkFurnace te; + + public GuiClockworkFurnace(InventoryPlayer ip, TileClockworkFurnace te, World world) + { + super(new ContainerClockworkFurnace(ip, te, world)); + this.te = te; + this.xSize = 300; + this.ySize = 230; + } + + @Override + public void initGui() + { + super.initGui(); + buttonList.clear(); + this.guiLeft = (this.width - this.xSize) / 2; + this.guiTop = (this.height - this.ySize) / 2; + } + + @Override + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { + this.drawCenteredString(fontRendererObj, "Cooking Progress: " + String.valueOf(te.getCookProgressScaled(100)) + "%", 150, 23 - fontRendererObj.FONT_HEIGHT / 2, 0x00D0FF); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + Minecraft.getMinecraft().renderEngine.bindTexture(Textures.GUI.BASE); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + } + + @Override + public void drawTexturedModalRect(int p_73729_1_, int p_73729_2_, int p_73729_3_, int p_73729_4_, int p_73729_5_, int p_73729_6_) + { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, 0, 1); + tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, 1, 1); + tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + 0), (double)this.zLevel, 1, 0); + tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + 0), (double)this.zLevel, 0, 0); + tessellator.draw(); + } +} diff --git a/src/main/java/lumaceon/mods/clockworkphase2/client/gui/GuiHandler.java b/src/main/java/lumaceon/mods/clockworkphase2/client/gui/GuiHandler.java index 09ba70b..1cf266a 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/client/gui/GuiHandler.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/client/gui/GuiHandler.java @@ -4,8 +4,10 @@ import cpw.mods.fml.common.network.NetworkRegistry; import lumaceon.mods.clockworkphase2.ClockworkPhase2; import lumaceon.mods.clockworkphase2.api.assembly.ContainerAssemblyTable; +import lumaceon.mods.clockworkphase2.container.ContainerClockworkFurnace; import lumaceon.mods.clockworkphase2.container.ContainerTemporalFurnace; import lumaceon.mods.clockworkphase2.container.ContainerTimeWell; +import lumaceon.mods.clockworkphase2.tile.clockwork.TileClockworkFurnace; import lumaceon.mods.clockworkphase2.tile.temporal.TileTemporalFurnace; import lumaceon.mods.clockworkphase2.tile.temporal.TileTimeWell; import net.minecraft.entity.player.EntityPlayer; @@ -29,6 +31,8 @@ public Object getServerGuiElement(int ID, EntityPlayer player, World world, int return new ContainerAssemblyTable(player.inventory, world); case 1: return new ContainerTimeWell(player.inventory, (TileTimeWell) te, world); + case 2: + return new ContainerClockworkFurnace(player.inventory, (TileClockworkFurnace) te, world); case 4: return new ContainerTemporalFurnace(player.inventory, (TileTemporalFurnace) te, world); } @@ -45,6 +49,8 @@ public Object getClientGuiElement(int ID, EntityPlayer player, World world, int return new GuiAssemblyTable(player.inventory, world, x, y, z); case 1: return new GuiTimeWell(player.inventory, (TileTimeWell) te, world); + case 2: + return new GuiClockworkFurnace(player.inventory, (TileClockworkFurnace) te, world); case 4: return new GuiTemporalFurnace(player.inventory, (TileTemporalFurnace) te, world); } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/client/particle/sequence/ParticleSequenceTimezone.java b/src/main/java/lumaceon/mods/clockworkphase2/client/particle/sequence/ParticleSequenceTimezone.java index e3cdd93..d85fc7a 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/client/particle/sequence/ParticleSequenceTimezone.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/client/particle/sequence/ParticleSequenceTimezone.java @@ -1,6 +1,6 @@ package lumaceon.mods.clockworkphase2.client.particle.sequence; -import lumaceon.mods.clockworkphase2.api.time.ITimezone; +import lumaceon.mods.clockworkphase2.api.block.ITimezoneProvider; import lumaceon.mods.clockworkphase2.client.particle.ParticleSpawn; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.EntityFX; @@ -10,10 +10,10 @@ public class ParticleSequenceTimezone extends ParticleSequence { public Random rand = new Random(); - public ITimezone timezone; + public ITimezoneProvider timezone; public EntityFX entityFX; - public ParticleSequenceTimezone(ITimezone timezone, double x, double y, double z) { + public ParticleSequenceTimezone(ITimezoneProvider timezone, double x, double y, double z) { super(x, y, z); this.timezone = timezone; } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/client/render/RenderHandler.java b/src/main/java/lumaceon/mods/clockworkphase2/client/render/RenderHandler.java index c238de6..e117f54 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/client/render/RenderHandler.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/client/render/RenderHandler.java @@ -3,7 +3,7 @@ import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import lumaceon.mods.clockworkphase2.api.item.ITimezoneModule; -import lumaceon.mods.clockworkphase2.api.time.ITimezone; +import lumaceon.mods.clockworkphase2.api.block.ITimezoneProvider; import lumaceon.mods.clockworkphase2.api.time.TimezoneHandler; import lumaceon.mods.clockworkphase2.block.BlockCelestialCompassSB; import lumaceon.mods.clockworkphase2.client.particle.sequence.ParticleSequence; @@ -117,7 +117,7 @@ public void onRenderWorld(RenderWorldLastEvent event) { for(int[] area : TimezoneHandler.timezones) { - ITimezone timezone = TimezoneHandler.getTimeZone(area[0], area[1], area[2], area[3]); + ITimezoneProvider timezone = TimezoneHandler.getTimeZone(area[0], area[1], area[2], area[3]); if(timezone != null) { ItemStack coreStack = timezone.getTimezoneModule(8); @@ -139,9 +139,9 @@ public void onRenderWorld(RenderWorldLastEvent event) public static class TIMEZONE { - public static Map timezoneSequences = new HashMap(); + public static Map timezoneSequences = new HashMap(); - public static void renderGlyph(int[] area, double x, double y, double z, ITimezone timezone) + public static void renderGlyph(int[] area, double x, double y, double z, ITimezoneProvider timezone) { if(mc.renderViewEntity != null) { diff --git a/src/main/java/lumaceon/mods/clockworkphase2/client/render/elements/overlay/OverlayRenderElementTemporalInfluence.java b/src/main/java/lumaceon/mods/clockworkphase2/client/render/elements/overlay/OverlayRenderElementTemporalInfluence.java index 4344537..7e247ac 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/client/render/elements/overlay/OverlayRenderElementTemporalInfluence.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/client/render/elements/overlay/OverlayRenderElementTemporalInfluence.java @@ -11,7 +11,7 @@ public class OverlayRenderElementTemporalInfluence extends OverlayRenderElement { public ArrayList additionList = new ArrayList(5); - public long displayInfluence; + public int displayInfluence; public int sleepTimer = 0; public int yTranslation = -100; @@ -41,7 +41,7 @@ public boolean render(RenderGameOverlayEvent.Post event) if(!additionList.isEmpty() && additionList.get(0).tweening == 10) { InfluenceIncrease ii = additionList.get(0); - displayInfluence = Math.min((long) (ii.previousInfluence + ((ii.newInfluence - ii.previousInfluence) * (ii.ticksIncreased / 200.0))), ii.newInfluence); + displayInfluence = Math.min((int) (ii.previousInfluence + ((ii.newInfluence - ii.previousInfluence) * (ii.ticksIncreased / 200.0))), ii.newInfluence); ii.ticksIncreased++; additionList.get(0).show = false; @@ -66,7 +66,7 @@ public void update() { } - public void displayInfluenceIncrease(long previousInfluence, long newInfluence) + public void displayInfluenceIncrease(int previousInfluence, int newInfluence) { additionList.add(new InfluenceIncrease(previousInfluence, newInfluence)); if(!RenderHandler.overlayRenderList.contains(this)) @@ -75,12 +75,12 @@ public void displayInfluenceIncrease(long previousInfluence, long newInfluence) public class InfluenceIncrease { - public long previousInfluence, newInfluence; + public int previousInfluence, newInfluence; public int tweening = 0; public int ticksIncreased = 0; public boolean show = true; - public InfluenceIncrease(long previousInfluence, long newInfluence) + public InfluenceIncrease(int previousInfluence, int newInfluence) { this.previousInfluence = previousInfluence; this.newInfluence = newInfluence; diff --git a/src/main/java/lumaceon/mods/clockworkphase2/container/ContainerClockworkFurnace.java b/src/main/java/lumaceon/mods/clockworkphase2/container/ContainerClockworkFurnace.java new file mode 100644 index 0000000..d8005b0 --- /dev/null +++ b/src/main/java/lumaceon/mods/clockworkphase2/container/ContainerClockworkFurnace.java @@ -0,0 +1,91 @@ +package lumaceon.mods.clockworkphase2.container; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import lumaceon.mods.clockworkphase2.inventory.slot.SlotInventoryValid; +import lumaceon.mods.clockworkphase2.tile.clockwork.TileClockworkFurnace; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class ContainerClockworkFurnace extends Container +{ + private World world; + private TileClockworkFurnace te; + + private int previousCookTime; + private int previousCurrentTension; + + public ContainerClockworkFurnace(InventoryPlayer ip, TileClockworkFurnace te, World world) + { + this.world = world; + this.te = te; + + for(int x = 0; x < 9; x++) + this.addSlotToContainer(new Slot(ip, x, 70 + x * 18 , 205)); + + for(int x = 0; x < 9; x++) + for(int y = 0; y < 3; y++) + this.addSlotToContainer(new Slot(ip, 9 + y * 9 + x, 70 + x * 18, 147 + y * 18)); + + this.addSlotToContainer(new SlotInventoryValid(te, 0, 70, 72)); + this.addSlotToContainer(new SlotInventoryValid(te, 1, 214, 72)); + } + + @Override + public void addCraftingToCrafters(ICrafting crafting) { + super.addCraftingToCrafters(crafting); + crafting.sendProgressBarUpdate(this, 0, te.furnaceCookTime); + crafting.sendProgressBarUpdate(this, 1, te.currentTension); + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + ICrafting crafting; + for(Object i : this.crafters) + { + if(i instanceof ICrafting) + { + crafting = (ICrafting) i; + if(this.previousCookTime != te.furnaceCookTime) + crafting.sendProgressBarUpdate(this, 0, te.furnaceCookTime); + if(this.previousCurrentTension != te.currentTension) + crafting.sendProgressBarUpdate(this, 1, te.currentTension); + } + } + + this.previousCookTime = te.furnaceCookTime; + this.previousCurrentTension = te.currentTension; + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int id, int value) + { + switch(id) + { + case 0: + te.furnaceCookTime = value; + break; + case 1: + te.currentTension = value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return te.isUseableByPlayer(player); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) { + return null; + } +} diff --git a/src/main/java/lumaceon/mods/clockworkphase2/extendeddata/ExtendedPlayerProperties.java b/src/main/java/lumaceon/mods/clockworkphase2/extendeddata/ExtendedPlayerProperties.java index 879c232..81f0c85 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/extendeddata/ExtendedPlayerProperties.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/extendeddata/ExtendedPlayerProperties.java @@ -23,10 +23,10 @@ public class ExtendedPlayerProperties implements IExtendedEntityProperties public PlayerPropertiesPAC PACProperties; //Represents overall progression in the game, as dictated by achievements. - public long temporalInfluence = 0; + public int temporalInfluence = 0; //Used in rendering to show the increase of temporal influence. - public long previousTemporalInfluence = 0; + public int previousTemporalInfluence = 0; public int totalAchievementWeight = 0; public int totalSpecialAchievementsEarned = 0; @@ -52,12 +52,12 @@ private static String getSaveKey(EntityPlayer player) { @Override public void saveNBTData(NBTTagCompound compound) { - compound.setLong("temporalInfluence", temporalInfluence); + compound.setInteger("temporalInfluence", temporalInfluence); } @Override public void loadNBTData(NBTTagCompound compound) { - temporalInfluence = compound.getLong("temporalInfluence"); + temporalInfluence = compound.getInteger("temporalInfluence"); } @Override @@ -74,7 +74,7 @@ public void calculateTemporalInfluence(Achievement achievement) if(player != null && player.worldObj != null && !player.worldObj.isRemote) { EntityPlayerMP playerMP = ((EntityPlayerMP)player); - long baseInfluence = 0; + int baseInfluence = 0; int pageMultiplier = 1; int specialAchievements = 0; for(Object object : AchievementList.achievementList) @@ -101,7 +101,7 @@ public void calculateTemporalInfluence(Achievement achievement) } previousTemporalInfluence = temporalInfluence; - temporalInfluence = baseInfluence * pageMultiplier * (long) Math.pow(specialAchievements + 1, TemporalAchievementList.INTERNAL.specialAchievementMultiplierExponent); + temporalInfluence = baseInfluence * pageMultiplier * (int) Math.pow(specialAchievements + 1, TemporalAchievementList.INTERNAL.specialAchievementMultiplierExponent); if(previousTemporalInfluence != temporalInfluence) PacketHandler.INSTANCE.sendTo(new MessageTemporalInfluence(temporalInfluence), playerMP); diff --git a/src/main/java/lumaceon/mods/clockworkphase2/handler/EntityHandler.java b/src/main/java/lumaceon/mods/clockworkphase2/handler/EntityHandler.java index 79e1134..58fadec 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/handler/EntityHandler.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/handler/EntityHandler.java @@ -3,9 +3,8 @@ import cpw.mods.fml.common.eventhandler.Event; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import lumaceon.mods.clockworkphase2.api.MemoryItemRegistry; -import lumaceon.mods.clockworkphase2.api.time.ITimezone; +import lumaceon.mods.clockworkphase2.api.block.ITimezoneProvider; import lumaceon.mods.clockworkphase2.api.time.TimezoneHandler; -import lumaceon.mods.clockworkphase2.entity.EntityPAC; import lumaceon.mods.clockworkphase2.extendeddata.ExtendedPlayerProperties; import lumaceon.mods.clockworkphase2.init.ModItems; import lumaceon.mods.clockworkphase2.item.timezonemodule.ItemTimezoneModuleMobRepellent; @@ -15,7 +14,6 @@ import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.event.entity.living.LivingDropsEvent; import net.minecraftforge.event.entity.living.LivingSpawnEvent; -import net.minecraftforge.event.entity.player.EntityInteractEvent; public class EntityHandler { @@ -59,7 +57,7 @@ public void onEntitySpawn(LivingSpawnEvent.CheckSpawn event) { if(!event.isCanceled()) { - ITimezone timezone = TimezoneHandler.getTimeZone(event.x, event.y, event.z, event.world); + ITimezoneProvider timezone = TimezoneHandler.getTimeZone(event.x, event.y, event.z, event.world); if(timezone != null) { ItemStack timestream; diff --git a/src/main/java/lumaceon/mods/clockworkphase2/init/ModBlocks.java b/src/main/java/lumaceon/mods/clockworkphase2/init/ModBlocks.java index 470f281..6c82116 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/init/ModBlocks.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/init/ModBlocks.java @@ -2,9 +2,13 @@ import cpw.mods.fml.common.registry.GameRegistry; import lumaceon.mods.clockworkphase2.block.*; +import lumaceon.mods.clockworkphase2.block.clockwork.BlockClockworkFurnace; +import lumaceon.mods.clockworkphase2.block.clockwork.BlockCrank; +import lumaceon.mods.clockworkphase2.block.itemblock.ItemBlockClockworkFurnace; import lumaceon.mods.clockworkphase2.block.steammachine.BlockBoiler; import lumaceon.mods.clockworkphase2.lib.Names; import lumaceon.mods.clockworkphase2.tile.*; +import lumaceon.mods.clockworkphase2.tile.clockwork.TileClockworkFurnace; import lumaceon.mods.clockworkphase2.tile.temporal.TileTemporalFurnace; import lumaceon.mods.clockworkphase2.tile.machine.TileTimezoneFluidExporter; import lumaceon.mods.clockworkphase2.tile.machine.TileTimezoneFluidImporter; @@ -19,6 +23,7 @@ public class ModBlocks public static void init() { //initSteamMachines(); + initClockworkMachines(); initTimeMachines(); initFluids(); initOres(); @@ -35,6 +40,17 @@ public static void initSteamMachines() GameRegistry.registerBlock(boiler, Names.BLOCK.BOILER); } + public static Block crank; + public static Block clockworkFurnace; + public static void initClockworkMachines() + { + crank = new BlockCrank(Material.iron, Names.BLOCK.CRANK); + clockworkFurnace = new BlockClockworkFurnace(Material.iron, Names.BLOCK.CLOCKWORK_FURNACE); + + GameRegistry.registerBlock(crank, Names.BLOCK.CRANK); + GameRegistry.registerBlock(clockworkFurnace, ItemBlockClockworkFurnace.class, Names.BLOCK.CLOCKWORK_FURNACE); + } + public static Block celestialCompass; public static Block celestialCompassSB; public static Block temporalDisplacementAltar; @@ -156,6 +172,7 @@ public static void initMisc() public static void initTE() { + GameRegistry.registerTileEntity(TileClockworkFurnace.class, Names.BLOCK.CLOCKWORK_FURNACE); GameRegistry.registerTileEntity(TileCelestialCompass.class, Names.BLOCK.CELESTIAL_COMPASS); GameRegistry.registerTileEntity(TileTemporalDisplacementAltar.class, Names.BLOCK.TEMPORAL_DISPLACEMENT_ALTAR); GameRegistry.registerTileEntity(TileTDA.class, Names.BLOCK.TDA); diff --git a/src/main/java/lumaceon/mods/clockworkphase2/item/ItemTemporalHourglass.java b/src/main/java/lumaceon/mods/clockworkphase2/item/ItemTemporalHourglass.java index 9fb86b4..c8933bb 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/item/ItemTemporalHourglass.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/item/ItemTemporalHourglass.java @@ -16,9 +16,9 @@ public class ItemTemporalHourglass extends ItemClockworkPhase implements ITimeSupplierItem { - public long capacity; + public int capacity; - public ItemTemporalHourglass(int maxStack, int maxDamage, long capacity, String unlocalizedName) { + public ItemTemporalHourglass(int maxStack, int maxDamage, int capacity, String unlocalizedName) { super(maxStack, maxDamage, unlocalizedName); this.capacity = capacity; } @@ -32,40 +32,40 @@ public void onUpdate(ItemStack is, World world, Entity entity, int p_77663_4_, b @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack is, EntityPlayer player, List list, boolean flag) { - list.add("Time Stored: " + Colors.AQUA + TimeConverter.parseNumber(NBTHelper.LONG.get(is, NBTTags.TIME), 3)); + list.add("Time Stored: " + Colors.AQUA + TimeConverter.parseNumber(NBTHelper.INT.get(is, NBTTags.TIME), 3)); } @Override - public long receiveTime(ItemStack timeItem, long maxReceive, boolean simulate) + public int receiveTime(ItemStack timeItem, int maxReceive, boolean simulate) { - long currentTime = NBTHelper.LONG.get(timeItem, NBTTags.TIME); - long timeReceived = Math.min(getEmptySpace(timeItem), maxReceive); + int currentTime = NBTHelper.INT.get(timeItem, NBTTags.TIME); + int timeReceived = Math.min(getEmptySpace(timeItem), maxReceive); if(!simulate) - NBTHelper.LONG.set(timeItem, NBTTags.TIME, currentTime + timeReceived); + NBTHelper.INT.set(timeItem, NBTTags.TIME, currentTime + timeReceived); return timeReceived; } @Override - public long extractTime(ItemStack timeItem, long maxExtract, boolean simulate) + public int extractTime(ItemStack timeItem, int maxExtract, boolean simulate) { - long currentTime = NBTHelper.LONG.get(timeItem, NBTTags.TIME); - long timeExtracted = Math.min(currentTime, maxExtract); + int currentTime = NBTHelper.INT.get(timeItem, NBTTags.TIME); + int timeExtracted = Math.min(currentTime, maxExtract); if(!simulate) - NBTHelper.LONG.set(timeItem, NBTTags.TIME, currentTime - timeExtracted); + NBTHelper.INT.set(timeItem, NBTTags.TIME, currentTime - timeExtracted); return timeExtracted; } @Override - public long getMaxCapacity(ItemStack timeItem) { + public int getMaxCapacity(ItemStack timeItem) { return capacity; } @Override - public long getTimeStored(ItemStack timeItem) { - return NBTHelper.LONG.get(timeItem, NBTTags.TIME); + public int getTimeStored(ItemStack timeItem) { + return NBTHelper.INT.get(timeItem, NBTTags.TIME); } - public long getEmptySpace(ItemStack timeItem) { + public int getEmptySpace(ItemStack timeItem) { return getMaxCapacity(timeItem) - getTimeStored(timeItem); } } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/item/ItemTemporalIngot.java b/src/main/java/lumaceon/mods/clockworkphase2/item/ItemTemporalIngot.java index abe2ad9..6d6e183 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/item/ItemTemporalIngot.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/item/ItemTemporalIngot.java @@ -1,8 +1,6 @@ package lumaceon.mods.clockworkphase2.item; -import lumaceon.mods.clockworkphase2.api.ITemporalMaterial; - -public class ItemTemporalIngot extends ItemClockworkPhase implements ITemporalMaterial +public class ItemTemporalIngot extends ItemClockworkPhase { public ItemTemporalIngot(int maxStack, int maxDamage, String unlocalizedName) { super(maxStack, maxDamage, unlocalizedName); diff --git a/src/main/java/lumaceon/mods/clockworkphase2/item/components/tool/clockwork/ItemGear.java b/src/main/java/lumaceon/mods/clockworkphase2/item/components/tool/clockwork/ItemGear.java index 69855d0..c0e1093 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/item/components/tool/clockwork/ItemGear.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/item/components/tool/clockwork/ItemGear.java @@ -39,7 +39,7 @@ public int getSpeed(ItemStack is) { } @Override - public int getHarvestLevel(ItemStack is) { + public int getTier(ItemStack is) { return harvestLevel; } } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/item/components/tool/clockwork/ItemMemoryComponent.java b/src/main/java/lumaceon/mods/clockworkphase2/item/components/tool/clockwork/ItemMemoryComponent.java index 3b6924e..ff2c92b 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/item/components/tool/clockwork/ItemMemoryComponent.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/item/components/tool/clockwork/ItemMemoryComponent.java @@ -39,7 +39,7 @@ public int getSpeed(ItemStack is) { } @Override - public int getHarvestLevel(ItemStack is) { + public int getTier(ItemStack is) { return harvestLevel; } } \ No newline at end of file diff --git a/src/main/java/lumaceon/mods/clockworkphase2/item/construct/tool/ItemClockworkAxe.java b/src/main/java/lumaceon/mods/clockworkphase2/item/construct/tool/ItemClockworkAxe.java index bf2f8bf..ea875e4 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/item/construct/tool/ItemClockworkAxe.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/item/construct/tool/ItemClockworkAxe.java @@ -37,7 +37,8 @@ public float func_150893_a(ItemStack is, Block block) } @Override - public void setHarvestLevels(ItemStack item, int harvestLevel) { - NBTHelper.INT.set(item, NBTTags.HARVEST_LEVEL_AXE, harvestLevel); + public void setTier(ItemStack item, int tier) { + super.setTier(item, tier); + NBTHelper.INT.set(item, NBTTags.HARVEST_LEVEL_AXE, tier); } } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/item/construct/tool/ItemClockworkPickaxe.java b/src/main/java/lumaceon/mods/clockworkphase2/item/construct/tool/ItemClockworkPickaxe.java index 9457c41..66e35c4 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/item/construct/tool/ItemClockworkPickaxe.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/item/construct/tool/ItemClockworkPickaxe.java @@ -42,7 +42,8 @@ public float func_150893_a(ItemStack is, Block block) } @Override - public void setHarvestLevels(ItemStack item, int harvestLevel) { - NBTHelper.INT.set(item, NBTTags.HARVEST_LEVEL_PICKAXE, harvestLevel); + public void setTier(ItemStack item, int tier) { + super.setTier(item, tier); + NBTHelper.INT.set(item, NBTTags.HARVEST_LEVEL_PICKAXE, tier); } } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/item/construct/tool/ItemClockworkShovel.java b/src/main/java/lumaceon/mods/clockworkphase2/item/construct/tool/ItemClockworkShovel.java index 2ad5eef..4416d2e 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/item/construct/tool/ItemClockworkShovel.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/item/construct/tool/ItemClockworkShovel.java @@ -23,7 +23,8 @@ public boolean func_150897_b(Block p_150897_1_) { } @Override - public void setHarvestLevels(ItemStack item, int harvestLevel) { - NBTHelper.INT.set(item, NBTTags.HARVEST_LEVEL_SHOVEL, harvestLevel); + public void setTier(ItemStack item, int tier) { + super.setTier(item, tier); + NBTHelper.INT.set(item, NBTTags.HARVEST_LEVEL_SHOVEL, tier); } } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/item/construct/tool/ItemClockworkTool.java b/src/main/java/lumaceon/mods/clockworkphase2/item/construct/tool/ItemClockworkTool.java index 456254d..30a9d55 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/item/construct/tool/ItemClockworkTool.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/item/construct/tool/ItemClockworkTool.java @@ -44,7 +44,7 @@ public ItemClockworkTool(float var1, ToolMaterial toolMaterial, Set set, String @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack is, EntityPlayer player, List list, boolean flag) { - InformationDisplay.addClockworkConstructInformation(is, player, list, true); + InformationDisplay.addClockworkConstructInformation(is, player, list, flag); } @Override @@ -120,6 +120,11 @@ public boolean onBlockDestroyed(ItemStack is, World world, Block block, int x, i return true; } + @Override + public int getTier(ItemStack item) { + return ClockworkHelper.getTier(item); + } + @Override public int getTension(ItemStack item) { return ClockworkHelper.getTension(item); @@ -146,7 +151,9 @@ public void setTension(ItemStack item, int tension) { } @Override - public void setHarvestLevels(ItemStack item, int harvestLevel) {} + public void setTier(ItemStack item, int tier) { + ClockworkHelper.setTier(item, tier); + } @Override public int addTension(ItemStack item, int tension) { @@ -159,7 +166,7 @@ public int consumeTension(ItemStack item, int tension) { } @Override - public void addClockworkInformation(ItemStack item, EntityPlayer player, List list) { + public void addConstructInformation(ItemStack item, EntityPlayer player, List list) { InformationDisplay.addClockworkToolInformation(item, player, list); } @@ -208,6 +215,6 @@ public void saveComponentInventory(ContainerAssemblyTable container) { @Override public void onInventoryChange(ContainerAssemblyTable container) { - AssemblyHelper.ON_INVENTORY_CHANGE.assembleClockworkTool(container, 0, 1); + AssemblyHelper.ON_INVENTORY_CHANGE.assembleClockworkConstruct(container, 0, 1); } } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamExtradimensionalTank.java b/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamExtradimensionalTank.java index 74e9bd1..8702680 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamExtradimensionalTank.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamExtradimensionalTank.java @@ -1,9 +1,8 @@ package lumaceon.mods.clockworkphase2.item.timestream; -import lumaceon.mods.clockworkphase2.api.item.timestream.ITimestream; import lumaceon.mods.clockworkphase2.item.ItemClockworkPhase; -public class ItemTimestreamExtradimensionalTank extends ItemClockworkPhase implements ITimestream +public class ItemTimestreamExtradimensionalTank extends ItemClockworkPhase { public ItemTimestreamExtradimensionalTank(int maxStack, int maxDamage, String unlocalizedName) { super(maxStack, maxDamage, unlocalizedName); diff --git a/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamLightning.java b/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamLightning.java index 9a6392c..9274e1d 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamLightning.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamLightning.java @@ -1,9 +1,8 @@ package lumaceon.mods.clockworkphase2.item.timestream; -import lumaceon.mods.clockworkphase2.api.item.timestream.ITimestream; import lumaceon.mods.clockworkphase2.item.ItemClockworkPhase; -public class ItemTimestreamLightning extends ItemClockworkPhase implements ITimestream +public class ItemTimestreamLightning extends ItemClockworkPhase { public ItemTimestreamLightning(int maxStack, int maxDamage, String unlocalizedName) { super(maxStack, maxDamage, unlocalizedName); diff --git a/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamMobRepulser.java b/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamMobRepulser.java index b5e1b10..6fa5a6f 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamMobRepulser.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamMobRepulser.java @@ -1,9 +1,8 @@ package lumaceon.mods.clockworkphase2.item.timestream; -import lumaceon.mods.clockworkphase2.api.item.timestream.ITimestream; import lumaceon.mods.clockworkphase2.item.ItemClockworkPhase; -public class ItemTimestreamMobRepulser extends ItemClockworkPhase implements ITimestream +public class ItemTimestreamMobRepulser extends ItemClockworkPhase { public ItemTimestreamMobRepulser(int maxStack, int maxDamage, String unlocalizedName) { super(maxStack, maxDamage, unlocalizedName); diff --git a/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamRelocation.java b/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamRelocation.java index 1f988dc..d1e8dd8 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamRelocation.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamRelocation.java @@ -2,14 +2,13 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import lumaceon.mods.clockworkphase2.api.item.timestream.ITimestream; import lumaceon.mods.clockworkphase2.item.ItemClockworkPhase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import java.util.List; -public class ItemTimestreamRelocation extends ItemClockworkPhase implements ITimestream +public class ItemTimestreamRelocation extends ItemClockworkPhase { public ItemTimestreamRelocation(int maxStack, int maxDamage, String unlocalizedName) { super(maxStack, maxDamage, unlocalizedName); diff --git a/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamSilkyHarvest.java b/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamSilkyHarvest.java index 30f7aad..597e3e2 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamSilkyHarvest.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamSilkyHarvest.java @@ -2,14 +2,13 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import lumaceon.mods.clockworkphase2.api.item.timestream.ITimestream; import lumaceon.mods.clockworkphase2.item.ItemClockworkPhase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import java.util.List; -public class ItemTimestreamSilkyHarvest extends ItemClockworkPhase implements ITimestream +public class ItemTimestreamSilkyHarvest extends ItemClockworkPhase { public ItemTimestreamSilkyHarvest(int maxStack, int maxDamage, String unlocalizedName) { super(maxStack, maxDamage, unlocalizedName); diff --git a/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamSmelt.java b/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamSmelt.java index 057a8a6..c6f0445 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamSmelt.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/item/timestream/ItemTimestreamSmelt.java @@ -2,14 +2,13 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import lumaceon.mods.clockworkphase2.api.item.timestream.ITimestream; import lumaceon.mods.clockworkphase2.item.ItemClockworkPhase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import java.util.List; -public class ItemTimestreamSmelt extends ItemClockworkPhase implements ITimestream +public class ItemTimestreamSmelt extends ItemClockworkPhase { public ItemTimestreamSmelt(int maxStack, int maxDamage, String unlocalizedName) { super(maxStack, maxDamage, unlocalizedName); diff --git a/src/main/java/lumaceon/mods/clockworkphase2/lib/Names.java b/src/main/java/lumaceon/mods/clockworkphase2/lib/Names.java index 66d1f43..d54d3b4 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/lib/Names.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/lib/Names.java @@ -7,6 +7,9 @@ public class Names { public class BLOCK { + public static final String CRANK = "crank"; + public static final String CLOCKWORK_FURNACE = "clockwork_furnace"; + public static final String TIME_SAND = "time_sand"; public static final String BASIC_WINDING_BOX = "basic_winding_box"; public static final String ASSEMBLY_TABLE = "assembly_table"; diff --git a/src/main/java/lumaceon/mods/clockworkphase2/network/message/MessageTemporalInfluence.java b/src/main/java/lumaceon/mods/clockworkphase2/network/message/MessageTemporalInfluence.java index 7997e85..d03670a 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/network/message/MessageTemporalInfluence.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/network/message/MessageTemporalInfluence.java @@ -5,21 +5,21 @@ public class MessageTemporalInfluence implements IMessage { - public long newTemporalInfluence; + public int newTemporalInfluence; public MessageTemporalInfluence() {} - public MessageTemporalInfluence(long newTemporalInfluence) { + public MessageTemporalInfluence(int newTemporalInfluence) { this.newTemporalInfluence = newTemporalInfluence; } @Override public void toBytes(ByteBuf buf) { - buf.writeLong(newTemporalInfluence); + buf.writeInt(newTemporalInfluence); } @Override public void fromBytes(ByteBuf buf) { - newTemporalInfluence = buf.readLong(); + newTemporalInfluence = buf.readInt(); } } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/tile/TileCelestialCompass.java b/src/main/java/lumaceon/mods/clockworkphase2/tile/TileCelestialCompass.java index 14a8c28..a645c3e 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/tile/TileCelestialCompass.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/tile/TileCelestialCompass.java @@ -2,7 +2,7 @@ import lumaceon.mods.clockworkphase2.api.item.ITimeSand; import lumaceon.mods.clockworkphase2.api.item.ITimezoneModule; -import lumaceon.mods.clockworkphase2.api.time.ITimezone; +import lumaceon.mods.clockworkphase2.api.block.ITimezoneProvider; import lumaceon.mods.clockworkphase2.api.time.TimezoneHandler; import lumaceon.mods.clockworkphase2.init.ModBlocks; import lumaceon.mods.clockworkphase2.lib.BlockPatterns; @@ -16,7 +16,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -public class TileCelestialCompass extends TileClockworkPhase implements ITimezone +public class TileCelestialCompass extends TileClockworkPhase implements ITimezoneProvider { private int blocksToPlace = 96; private boolean registerTimezone = true; @@ -242,7 +242,7 @@ public void setTimestream(int index, ItemStack item) { } @Override - public long getMaxTimeSand() + public int getMaxTimeSand() { if(timestreamItems[8] != null && timestreamItems[8].getItem() instanceof ITimeSand) return ((ITimeSand) timestreamItems[8].getItem()).getMaxTimeSand(timestreamItems[8]); @@ -250,7 +250,7 @@ public long getMaxTimeSand() } @Override - public long getTimeSand() + public int getTimeSand() { if(timestreamItems[8] != null && timestreamItems[8].getItem() instanceof ITimeSand) return ((ITimeSand) timestreamItems[8].getItem()).getTimeSand(timestreamItems[8]); @@ -258,7 +258,7 @@ public long getTimeSand() } @Override - public void setTimeSand(long timeSand) + public void setTimeSand(int timeSand) { if(timestreamItems[8] != null && timestreamItems[8].getItem() instanceof ITimeSand) { @@ -268,7 +268,7 @@ public void setTimeSand(long timeSand) } @Override - public long addTimeSand(long timeSand) + public int addTimeSand(int timeSand) { if(timestreamItems[8] != null && timestreamItems[8].getItem() instanceof ITimeSand) { @@ -279,7 +279,7 @@ public long addTimeSand(long timeSand) } @Override - public long consumeTimeSand(long timeSand) + public int consumeTimeSand(int timeSand) { if(timestreamItems[8] != null && timestreamItems[8].getItem() instanceof ITimeSand) { diff --git a/src/main/java/lumaceon/mods/clockworkphase2/tile/clockwork/TileClockwork.java b/src/main/java/lumaceon/mods/clockworkphase2/tile/clockwork/TileClockwork.java new file mode 100644 index 0000000..d689183 --- /dev/null +++ b/src/main/java/lumaceon/mods/clockworkphase2/tile/clockwork/TileClockwork.java @@ -0,0 +1,78 @@ +package lumaceon.mods.clockworkphase2.tile.clockwork; + +import lumaceon.mods.clockworkphase2.api.block.clockwork.IClockworkDestination; +import lumaceon.mods.clockworkphase2.api.util.internal.NBTTags; +import lumaceon.mods.clockworkphase2.tile.generic.TileClockworkPhase; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +public class TileClockwork extends TileClockworkPhase implements IClockworkDestination +{ + public ItemStack itemBlock; + public int quality; //Tension efficiency; higher = less tension used per operation. + public int speed; //Work speed; higher = faster machines. + public int maxTension; + public int currentTension; + + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + NBTTagCompound tag; + if(itemBlock != null) + { + tag = new NBTTagCompound(); + itemBlock.writeToNBT(tag); + nbt.setTag("itemBlock", tag); + } + + nbt.setInteger(NBTTags.QUALITY, quality); + nbt.setInteger(NBTTags.SPEED, speed); + nbt.setInteger(NBTTags.MAX_TENSION, maxTension); + nbt.setInteger(NBTTags.CURRENT_TENSION, currentTension); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + NBTTagCompound tagCompound; + tagCompound = nbt.getCompoundTag("itemBlock"); + itemBlock = ItemStack.loadItemStackFromNBT(tagCompound); + + quality = nbt.getInteger(NBTTags.QUALITY); + speed = nbt.getInteger(NBTTags.SPEED); + maxTension = nbt.getInteger(NBTTags.MAX_TENSION); + currentTension = nbt.getInteger(NBTTags.CURRENT_TENSION); + } + + @Override + public boolean canReceiveFrom(ForgeDirection direction) { + return ForgeDirection.getOrientation(blockMetadata).ordinal() != direction.getOpposite().ordinal(); + } + + @Override + public int receiveClockworkEnergy(ForgeDirection from, int maxReception) { + int energyTaken = canReceiveFrom(from) ? Math.min(maxTension - currentTension, maxReception) : 0; + currentTension += energyTaken; + return energyTaken; + } + + @Override + public int getMaxCapacity() { return maxTension; } + @Override + public int getEnergyStored() { return currentTension; } + + @Override + public int wind(int tension) { + int amountToAdd = Math.min(this.maxTension - this.currentTension, tension); + currentTension += amountToAdd; + return amountToAdd; + } + + @Override + public void setState(int state) {} + @Override + public void setStateAndUpdate(int state) {} +} diff --git a/src/main/java/lumaceon/mods/clockworkphase2/tile/clockwork/TileClockworkFurnace.java b/src/main/java/lumaceon/mods/clockworkphase2/tile/clockwork/TileClockworkFurnace.java new file mode 100644 index 0000000..b835e60 --- /dev/null +++ b/src/main/java/lumaceon/mods/clockworkphase2/tile/clockwork/TileClockworkFurnace.java @@ -0,0 +1,252 @@ +package lumaceon.mods.clockworkphase2.tile.clockwork; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import lumaceon.mods.clockworkphase2.api.item.clockwork.IClockwork; +import lumaceon.mods.clockworkphase2.api.util.ClockworkHelper; +import lumaceon.mods.clockworkphase2.api.util.internal.NBTHelper; +import lumaceon.mods.clockworkphase2.api.util.internal.NBTTags; +import lumaceon.mods.clockworkphase2.item.components.tool.ItemClockworkCore; +import lumaceon.mods.clockworkphase2.item.components.tool.ItemMainspring; +import lumaceon.mods.clockworkphase2.tile.generic.TileClockworkPhaseInventory; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + +public class TileClockworkFurnace extends TileClockwork implements ISidedInventory +{ + protected ItemStack[] inventory = new ItemStack[2]; //0 - Input, 1 - Output + /** The number of ticks that the current item has been cooking for */ + public int furnaceCookTime; + + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + + NBTTagList nbtList = new NBTTagList(); + for(int index = 0; index < inventory.length; index++) + { + if(inventory[index] != null) + { + NBTTagCompound tag = new NBTTagCompound(); + tag.setByte("slot_index", (byte)index); + inventory[index].writeToNBT(tag); + nbtList.appendTag(tag); + } + } + nbt.setTag(TileClockworkPhaseInventory.INVENTORY_TAG, nbtList); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + + NBTTagList tagList = nbt.getTagList(TileClockworkPhaseInventory.INVENTORY_TAG, 10); + inventory = new ItemStack[getSizeInventory()]; + for(int i = 0; i < tagList.tagCount(); ++i) + { + NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); + byte slotIndex = tagCompound.getByte("slot_index"); + if(slotIndex >= 0 && slotIndex < inventory.length) + inventory[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound); + } + } + + @Override + public void updateEntity() + { + boolean furnaceOn = isBurning(); + boolean isChanged = false; + + if(!this.worldObj.isRemote) + { + if(furnaceOn && this.inventory[0] != null) + { + currentTension -= ClockworkHelper.getTensionCostFromStats((int) (ClockworkHelper.getStandardExponentialSpeedMultiplier(speed) * 50), quality, speed) / 50; + currentTension = Math.max(currentTension, 0); + if(this.isBurning() && this.canSmelt()) + { + this.furnaceCookTime += (int) (ClockworkHelper.getStandardExponentialSpeedMultiplier(speed) * 50); + if(this.furnaceCookTime >= 10000) + { + this.furnaceCookTime -= 10000; + this.smeltItem(); + isChanged = true; + } + } + else + this.furnaceCookTime = 0; + } + + if(furnaceOn != isBurning()) + isChanged = true; + } + + if(isChanged) + this.markDirty(); + } + + public boolean isBurning() { + return this.currentTension > 0 && speed > 0 && quality > 0; + } + + public boolean canSmelt() + { + if(this.inventory[0] == null) + return false; + else + { + ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.inventory[0]); + if(itemstack == null) return false; + if(this.inventory[1] == null) return true; + if(!this.inventory[1].isItemEqual(itemstack)) return false; + int result = inventory[1].stackSize + itemstack.stackSize; + return result <= getInventoryStackLimit() && result <= this.inventory[1].getMaxStackSize(); + } + } + + public void smeltItem() + { + if(this.canSmelt()) + { + ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.inventory[0]); + + if(this.inventory[1] == null) + this.inventory[1] = itemstack.copy(); + else if(this.inventory[1].getItem() == itemstack.getItem()) + this.inventory[1].stackSize += itemstack.stackSize; + + --this.inventory[0].stackSize; + + if(this.inventory[0].stackSize <= 0) + this.inventory[0] = null; + } + } + + /** + * Returns an integer between 0 and the passed value representing how close the current item is to being completely + * cooked + */ + @SideOnly(Side.CLIENT) + public int getCookProgressScaled(int p_145953_1_) { + return this.furnaceCookTime * p_145953_1_ / 10000; + } + + @Override + public int getSizeInventory() { + return inventory.length; + } + + @Override + public ItemStack getStackInSlot(int slot) { + return inventory[slot]; + } + + @Override + public ItemStack decrStackSize(int slot, int amountToDecrease) + { + ItemStack is = getStackInSlot(slot); + if(is != null) + { + if(amountToDecrease >= is.stackSize) + setInventorySlotContents(slot, null); + else + { + is = is.splitStack(amountToDecrease); + if(is.stackSize == 0) + setInventorySlotContents(slot, null); + } + } + return is; + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) + { + if(inventory[slot] != null) + { + ItemStack itemStack = inventory[slot]; + inventory[slot] = null; + return itemStack; + } + return null; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack item) + { + inventory[slot] = item; + + if(item != null && item.stackSize > this.getInventoryStackLimit()) + item.stackSize = this.getInventoryStackLimit(); + this.markDirty(); + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return player.getDistance((double) xCoord, (double) yCoord, (double) zCoord) <= 8; + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack item) { + return true; + } + + @Override + public void openInventory() {} + @Override + public void closeInventory() {} + @Override + public String getInventoryName() { return null; } + @Override + public boolean hasCustomInventoryName() { return false; } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return new int[] { 0, 1 }; + } + + @Override + public boolean canInsertItem(int slotID, ItemStack inputStack, int side) { + return + inputStack != null + && FurnaceRecipes.smelting().getSmeltingResult(inputStack) != null + && (inventory[0] == null || inventory[0].stackSize < inventory[0].getMaxStackSize()) + && slotID == 0; + } + + @Override + public boolean canExtractItem(int slotID, ItemStack outputStack, int side) { + return slotID == 1; + } + + @Override + public int wind(int tension) { + int amountToAdd = Math.min(this.maxTension - this.currentTension, tension); + currentTension += amountToAdd; + return amountToAdd; + } + + public void setTileDataFromItemStack(ItemStack item) + { + this.itemBlock = item.copy(); + ItemStack[] items = NBTHelper.INVENTORY.get(item, NBTTags.COMPONENT_INVENTORY); + if(items[0] != null && items[0].getItem() instanceof ItemMainspring) + this.maxTension = NBTHelper.INT.get(items[0], NBTTags.MAX_TENSION); + if(items[1] != null && items[1].getItem() instanceof IClockwork) + { + this.quality = ((IClockwork) items[1].getItem()).getQuality(items[1]); + this.speed = ((IClockwork) items[1].getItem()).getSpeed(items[1]); + } + } +} diff --git a/src/main/java/lumaceon/mods/clockworkphase2/tile/generic/TileTemporal.java b/src/main/java/lumaceon/mods/clockworkphase2/tile/generic/TileTemporal.java index a590981..d573eb6 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/tile/generic/TileTemporal.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/tile/generic/TileTemporal.java @@ -1,6 +1,6 @@ package lumaceon.mods.clockworkphase2.tile.generic; -import lumaceon.mods.clockworkphase2.api.time.ITimezone; +import lumaceon.mods.clockworkphase2.api.block.ITimezoneProvider; import lumaceon.mods.clockworkphase2.api.time.TimeStorage; import lumaceon.mods.clockworkphase2.api.time.TimezoneHandler; import net.minecraft.nbt.NBTTagCompound; @@ -8,7 +8,7 @@ public abstract class TileTemporal extends TileClockworkPhase { - private ITimezone timezone; + private ITimezoneProvider timezone; public TimeStorage timeStorage; protected int tz_x, tz_y, tz_z; @@ -28,20 +28,20 @@ public void readFromNBT(NBTTagCompound nbt) timeStorage.readFromNBT(nbt); } - public ITimezone getTimezone() + public ITimezoneProvider getTimezone() { if(timezone != null && Math.sqrt(Math.pow(tz_x - xCoord, 2) + Math.pow(tz_z - zCoord, 2)) <= timezone.getRange()) return timezone; TileEntity te = worldObj.getTileEntity(tz_x, tz_y, tz_z); - if(te != null && te instanceof ITimezone) + if(te != null && te instanceof ITimezoneProvider) { if(Math.sqrt(Math.pow(tz_x - xCoord, 2) + Math.pow(tz_z - zCoord, 2)) > timezone.getRange()) return null; - timezone = (ITimezone) te; + timezone = (ITimezoneProvider) te; return timezone; } - ITimezone timezone = TimezoneHandler.getTimeZone(xCoord, yCoord, zCoord, worldObj); + ITimezoneProvider timezone = TimezoneHandler.getTimeZone(xCoord, yCoord, zCoord, worldObj); if(timezone != null) this.timezone = timezone; if(timezone == null || Math.sqrt(Math.pow(tz_x - xCoord, 2) + Math.pow(tz_z - zCoord, 2)) <= timezone.getRange()) diff --git a/src/main/java/lumaceon/mods/clockworkphase2/tile/machine/TileTimezoneFluidExporter.java b/src/main/java/lumaceon/mods/clockworkphase2/tile/machine/TileTimezoneFluidExporter.java index b23b412..147b4ed 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/tile/machine/TileTimezoneFluidExporter.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/tile/machine/TileTimezoneFluidExporter.java @@ -1,7 +1,7 @@ package lumaceon.mods.clockworkphase2.tile.machine; import cpw.mods.fml.common.network.NetworkRegistry; -import lumaceon.mods.clockworkphase2.api.time.ITimezone; +import lumaceon.mods.clockworkphase2.api.block.ITimezoneProvider; import lumaceon.mods.clockworkphase2.item.timezonemodule.ItemTimezoneModuleTank; import lumaceon.mods.clockworkphase2.network.PacketHandler; import lumaceon.mods.clockworkphase2.network.message.MessageTileStateChange; @@ -108,7 +108,7 @@ else if(found && tank != null && tank.fluid != null && FluidRegistry.isFluidRegi public ItemStack getTimezoneModule() { - ITimezone timezone = getTimezone(); + ITimezoneProvider timezone = getTimezone(); ItemStack timezoneModule; if(timezone != null) { diff --git a/src/main/java/lumaceon/mods/clockworkphase2/tile/machine/TileTimezoneFluidImporter.java b/src/main/java/lumaceon/mods/clockworkphase2/tile/machine/TileTimezoneFluidImporter.java index ed3aec1..bc5c47a 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/tile/machine/TileTimezoneFluidImporter.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/tile/machine/TileTimezoneFluidImporter.java @@ -1,6 +1,6 @@ package lumaceon.mods.clockworkphase2.tile.machine; -import lumaceon.mods.clockworkphase2.api.time.ITimezone; +import lumaceon.mods.clockworkphase2.api.block.ITimezoneProvider; import lumaceon.mods.clockworkphase2.item.timezonemodule.ItemTimezoneModuleTank; import lumaceon.mods.clockworkphase2.tile.generic.TileTemporal; import net.minecraft.item.ItemStack; @@ -14,7 +14,7 @@ public class TileTimezoneFluidImporter extends TileTemporal implements IFluidHan { public ItemStack getTimezoneModule() { - ITimezone timezone = getTimezone(); + ITimezoneProvider timezone = getTimezone(); ItemStack timezoneModule; if(timezone != null) { diff --git a/src/main/java/lumaceon/mods/clockworkphase2/tile/temporal/TileTemporalFurnace.java b/src/main/java/lumaceon/mods/clockworkphase2/tile/temporal/TileTemporalFurnace.java index c923009..24438f8 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/tile/temporal/TileTemporalFurnace.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/tile/temporal/TileTemporalFurnace.java @@ -13,7 +13,7 @@ public class TileTemporalFurnace extends TileTemporalInventory implements ITimeReceiver, ITimeProvider { - public long ticksPerAction = 200; //10 seconds, the time of a normal furnace. + public int ticksPerAction = 200; //10 seconds, the time of a normal furnace. public TileTemporalFurnace() { super(); @@ -83,7 +83,7 @@ private boolean canSmelt() */ private boolean consumeTime() { - long timeConsumed = Math.min(timeStorage.getTimeStored(), ticksPerAction); + int timeConsumed = Math.min(timeStorage.getTimeStored(), ticksPerAction); if(timeConsumed < ticksPerAction) //Could not consume all time required, take additional time from timezone. { timeStorage.extractTime(timeStorage.getTimeStored(), false); @@ -101,26 +101,26 @@ public void setState(int state) {} public void setStateAndUpdate(int state) {} @Override - public long extractTime(long maxExtract, boolean simulate) { + public int extractTime(int maxExtract, boolean simulate) { return timeStorage.extractTime(maxExtract, simulate); } @Override - public long receiveTime(long maxReceive, boolean simulate) { + public int receiveTime(int maxReceive, boolean simulate) { return timeStorage.receiveTime(maxReceive, simulate); } @Override - public long getMaxCapacity() { + public int getMaxCapacity() { return timeStorage.getMaxCapacity(); } @Override - public long getTimeStored() { + public int getTimeStored() { return timeStorage.getTimeStored(); } - public long getEmptySpace() { + public int getEmptySpace() { return timeStorage.getEmptySpace(); } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/tile/temporal/TileTimeCollector.java b/src/main/java/lumaceon/mods/clockworkphase2/tile/temporal/TileTimeCollector.java index 25ec9d1..ffd1c5d 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/tile/temporal/TileTimeCollector.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/tile/temporal/TileTimeCollector.java @@ -41,17 +41,17 @@ public void readFromNBT(NBTTagCompound nbt) } @Override - public long extractTime(long maxExtract, boolean simulate) { + public int extractTime(int maxExtract, boolean simulate) { return timeStorage.extractTime(maxExtract, simulate); } @Override - public long getMaxCapacity() { + public int getMaxCapacity() { return timeStorage.getMaxCapacity(); } @Override - public long getTimeStored() { + public int getTimeStored() { return timeStorage.getTimeStored(); } diff --git a/src/main/java/lumaceon/mods/clockworkphase2/tile/temporal/TileTimeWell.java b/src/main/java/lumaceon/mods/clockworkphase2/tile/temporal/TileTimeWell.java index afbd949..9a02653 100644 --- a/src/main/java/lumaceon/mods/clockworkphase2/tile/temporal/TileTimeWell.java +++ b/src/main/java/lumaceon/mods/clockworkphase2/tile/temporal/TileTimeWell.java @@ -17,7 +17,7 @@ public class TileTimeWell extends TileTemporalInventory implements ITimeReceiver, ITimeProvider, IInventory { - long maxDrainPerTick = TimeConverter.SECOND * 10; + int maxDrainPerTick = TimeConverter.SECOND * 10; public TileTimeWell() { super(); @@ -49,22 +49,22 @@ public void updateEntity() } @Override - public long extractTime(long maxExtract, boolean simulate) { + public int extractTime(int maxExtract, boolean simulate) { return timeStorage.extractTime(maxExtract, simulate); } @Override - public long receiveTime(long maxReceive, boolean simulate) { + public int receiveTime(int maxReceive, boolean simulate) { return timeStorage.receiveTime(maxReceive, simulate); } @Override - public long getMaxCapacity() { + public int getMaxCapacity() { return timeStorage.getMaxCapacity(); } @Override - public long getTimeStored() { + public int getTimeStored() { return timeStorage.getTimeStored(); }