From 5d15dce9293f7c37089be3adfe0768de425838e2 Mon Sep 17 00:00:00 2001 From: Jordan Byrne Date: Wed, 21 Feb 2018 14:38:10 +1000 Subject: $ Tree Farmer Work. % Package cleanup. - Removed /Bed command. --- src/Java/gtPlusPlus/GTplusplus.java | 12 +- .../api/analytics/AnalyticsLoggingPlugin.java | 39 -- .../gtPlusPlus/api/analytics/BlockingFlush.java | 67 --- .../gtPlusPlus/api/analytics/SegmentAnalytics.java | 271 --------- .../gtPlusPlus/api/analytics/SegmentHelper.java | 81 --- .../api/damage/BaseCustomDamageSource.java | 22 - .../gtPlusPlus/api/damage/DamageTeslaTower.java | 1 + .../gtPlusPlus/api/helpers/MaterialHelper.java | 18 + .../gtPlusPlus/api/interfaces/IEntityCatcher.java | 2 +- .../gtPlusPlus/api/objects/CSPRNG_DO_NOT_USE.java | 271 --------- src/Java/gtPlusPlus/api/objects/ChunkManager.java | 309 ----------- src/Java/gtPlusPlus/api/objects/DimChunkPos.java | 53 -- src/Java/gtPlusPlus/api/objects/GenericStack.java | 41 -- .../gtPlusPlus/api/objects/MaterialHelper.java | 18 - src/Java/gtPlusPlus/api/objects/XSTR.java | 266 --------- src/Java/gtPlusPlus/api/objects/data/AutoMap.java | 77 +++ src/Java/gtPlusPlus/api/objects/data/Pair.java | 27 + src/Java/gtPlusPlus/api/objects/data/Quad.java | 33 ++ src/Java/gtPlusPlus/api/objects/data/Triplet.java | 27 + .../gtPlusPlus/api/objects/minecraft/BlockPos.java | 85 +++ .../api/objects/minecraft/ChunkManager.java | 309 +++++++++++ .../api/objects/minecraft/DimChunkPos.java | 52 ++ .../api/objects/minecraft/GenericStack.java | 41 ++ .../api/objects/random/CSPRNG_DO_NOT_USE.java | 271 +++++++++ src/Java/gtPlusPlus/api/objects/random/XSTR.java | 266 +++++++++ .../core/block/general/BlockTankXpConverter.java | 2 +- .../gtPlusPlus/core/block/general/HellFire.java | 2 +- .../core/client/renderer/RenderPlasmaBolt.java | 2 +- src/Java/gtPlusPlus/core/commands/CommandMath.java | 110 ++-- src/Java/gtPlusPlus/core/common/CommonProxy.java | 2 +- .../core/entity/EntityTeslaTowerLightning.java | 2 +- .../projectile/EntityHydrofluoricAcidPotion.java | 2 +- .../projectile/EntitySulfuricAcidPotion.java | 2 +- .../core/handler/BurnableFuelHandler.java | 2 +- .../handler/analytics/AnalyticsLoggingPlugin.java | 39 ++ .../core/handler/analytics/BlockingFlush.java | 67 +++ .../core/handler/analytics/SegmentAnalytics.java | 271 +++++++++ .../core/handler/analytics/SegmentHelper.java | 81 +++ .../core/handler/events/BlockEventHandler.java | 4 +- .../core/handler/events/LoginEventHandler.java | 4 +- .../events/ZombieBackupSpawnEventHandler.java | 2 +- src/Java/gtPlusPlus/core/item/base/BaseEuItem.java | 2 +- .../core/item/base/BaseItemBurnable.java | 2 +- .../core/item/general/ItemAreaClear.java | 2 +- .../item/general/capture/ItemEntityCatcher.java | 2 +- .../core/item/tool/staballoy/MultiPickaxeBase.java | 2 +- src/Java/gtPlusPlus/core/lib/CORE.java | 6 +- src/Java/gtPlusPlus/core/material/Material.java | 4 +- .../core/slots/SlotModularBaubleUpgrades.java | 2 +- .../core/tileentities/base/TilePoweredGT.java | 2 +- .../machines/TileEntityModularityTable.java | 2 +- src/Java/gtPlusPlus/core/util/Utils.java | 2 +- src/Java/gtPlusPlus/core/util/array/AutoMap.java | 77 --- src/Java/gtPlusPlus/core/util/array/BlockPos.java | 28 - src/Java/gtPlusPlus/core/util/array/Pair.java | 27 - src/Java/gtPlusPlus/core/util/array/Quad.java | 33 -- src/Java/gtPlusPlus/core/util/array/Triplet.java | 27 - .../gtPlusPlus/core/util/entity/EntityUtils.java | 2 +- src/Java/gtPlusPlus/core/util/item/ItemUtils.java | 2 +- src/Java/gtPlusPlus/core/util/math/MathUtils.java | 2 +- .../core/util/nbt/ModularArmourUtils.java | 2 +- .../gtPlusPlus/core/util/uuid/UUIDGenerator.java | 2 +- .../core/world/damage/BaseCustomDamageSource.java | 22 + .../world/darkworld/gen/gt/WorldGen_GT_Base.java | 2 +- .../core/world/darkworld/gen/gt/WorldGen_Ores.java | 4 +- .../core/world/darkworld/object/BoxedQuad.java | 2 +- .../core/world/explosions/MiningExplosion.java | 2 +- .../gtPlusPlus/plugin/manager/Core_Manager.java | 2 +- .../transformers/Preloader_ClassTransformer2.java | 4 +- .../GT_MetaTileEntity_DeluxeMachine.java | 2 +- .../gregtech/common/helpers/ChargingHelper.java | 4 +- .../gregtech/common/helpers/TreeFarmHelper.java | 616 +++++++++++---------- .../basic/GregtechMetaTileEntityChunkLoader.java | 11 +- .../basic/GregtechMetaWirelessCharger.java | 2 +- .../machines/multi/GregtechMTE_TeslaTower.java | 2 +- .../multi/GregtechMetaTileEntityTreeFarm.java | 2 +- ...egtechMetaTileEntity_IndustrialFishingPond.java | 2 +- .../GregtechMetaTileEntity_MassFabricator.java | 8 +- .../multi/GregtechMetaTileEntity_MultiTank.java | 2 +- .../xmod/gregtech/loaders/GT_Material_Loader.java | 2 +- .../loaders/RecipeGen_MaterialProcessing.java | 4 +- .../xmod/gregtech/loaders/RecipeGen_Ore.java | 4 +- .../xmod/gregtech/loaders/RecipeGen_Recycling.java | 4 +- 83 files changed, 2147 insertions(+), 2039 deletions(-) delete mode 100644 src/Java/gtPlusPlus/api/analytics/AnalyticsLoggingPlugin.java delete mode 100644 src/Java/gtPlusPlus/api/analytics/BlockingFlush.java delete mode 100644 src/Java/gtPlusPlus/api/analytics/SegmentAnalytics.java delete mode 100644 src/Java/gtPlusPlus/api/analytics/SegmentHelper.java delete mode 100644 src/Java/gtPlusPlus/api/damage/BaseCustomDamageSource.java create mode 100644 src/Java/gtPlusPlus/api/helpers/MaterialHelper.java delete mode 100644 src/Java/gtPlusPlus/api/objects/CSPRNG_DO_NOT_USE.java delete mode 100644 src/Java/gtPlusPlus/api/objects/ChunkManager.java delete mode 100644 src/Java/gtPlusPlus/api/objects/DimChunkPos.java delete mode 100644 src/Java/gtPlusPlus/api/objects/GenericStack.java delete mode 100644 src/Java/gtPlusPlus/api/objects/MaterialHelper.java delete mode 100644 src/Java/gtPlusPlus/api/objects/XSTR.java create mode 100644 src/Java/gtPlusPlus/api/objects/data/AutoMap.java create mode 100644 src/Java/gtPlusPlus/api/objects/data/Pair.java create mode 100644 src/Java/gtPlusPlus/api/objects/data/Quad.java create mode 100644 src/Java/gtPlusPlus/api/objects/data/Triplet.java create mode 100644 src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java create mode 100644 src/Java/gtPlusPlus/api/objects/minecraft/ChunkManager.java create mode 100644 src/Java/gtPlusPlus/api/objects/minecraft/DimChunkPos.java create mode 100644 src/Java/gtPlusPlus/api/objects/minecraft/GenericStack.java create mode 100644 src/Java/gtPlusPlus/api/objects/random/CSPRNG_DO_NOT_USE.java create mode 100644 src/Java/gtPlusPlus/api/objects/random/XSTR.java create mode 100644 src/Java/gtPlusPlus/core/handler/analytics/AnalyticsLoggingPlugin.java create mode 100644 src/Java/gtPlusPlus/core/handler/analytics/BlockingFlush.java create mode 100644 src/Java/gtPlusPlus/core/handler/analytics/SegmentAnalytics.java create mode 100644 src/Java/gtPlusPlus/core/handler/analytics/SegmentHelper.java delete mode 100644 src/Java/gtPlusPlus/core/util/array/AutoMap.java delete mode 100644 src/Java/gtPlusPlus/core/util/array/BlockPos.java delete mode 100644 src/Java/gtPlusPlus/core/util/array/Pair.java delete mode 100644 src/Java/gtPlusPlus/core/util/array/Quad.java delete mode 100644 src/Java/gtPlusPlus/core/util/array/Triplet.java create mode 100644 src/Java/gtPlusPlus/core/world/damage/BaseCustomDamageSource.java (limited to 'src/Java/gtPlusPlus') diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index dedbbb6c11..74b81b63b3 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -1,6 +1,6 @@ package gtPlusPlus; -import static gtPlusPlus.api.objects.ChunkManager.mChunkLoaderManagerMap; +import static gtPlusPlus.api.objects.minecraft.ChunkManager.mChunkLoaderManagerMap; import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableCustomCapes; import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableUpdateChecker; @@ -20,23 +20,23 @@ import gregtech.api.enums.Materials; import gregtech.api.util.GT_Recipe; import gregtech.api.util.Recipe_GT; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gtPlusPlus.api.analytics.SegmentAnalytics; -import gtPlusPlus.api.analytics.SegmentHelper; -import gtPlusPlus.api.objects.ChunkManager; -import gtPlusPlus.api.objects.DimChunkPos; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Triplet; +import gtPlusPlus.api.objects.minecraft.ChunkManager; +import gtPlusPlus.api.objects.minecraft.DimChunkPos; import gtPlusPlus.core.commands.CommandMath; import gtPlusPlus.core.common.CommonProxy; import gtPlusPlus.core.config.ConfigHandler; import gtPlusPlus.core.handler.BookHandler; import gtPlusPlus.core.handler.Recipes.RegistrationHandler; +import gtPlusPlus.core.handler.analytics.SegmentAnalytics; +import gtPlusPlus.core.handler.analytics.SegmentHelper; import gtPlusPlus.core.handler.events.BlockEventHandler; import gtPlusPlus.core.handler.events.LoginEventHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.Triplet; import gtPlusPlus.core.util.geo.GeoUtils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.networking.NetworkUtils; diff --git a/src/Java/gtPlusPlus/api/analytics/AnalyticsLoggingPlugin.java b/src/Java/gtPlusPlus/api/analytics/AnalyticsLoggingPlugin.java deleted file mode 100644 index 2423eaa65c..0000000000 --- a/src/Java/gtPlusPlus/api/analytics/AnalyticsLoggingPlugin.java +++ /dev/null @@ -1,39 +0,0 @@ -package gtPlusPlus.api.analytics; - -import com.segment.analytics.Analytics; -import com.segment.analytics.Callback; -import com.segment.analytics.Log; -import com.segment.analytics.Plugin; -import com.segment.analytics.messages.Message; - -import gtPlusPlus.api.objects.Logger; - -/** - * A {@link Plugin} implementation that redirects client logs to standard output and logs callback - * events. - */ -public class AnalyticsLoggingPlugin implements Plugin { - @Override public void configure(Analytics.Builder builder) { - builder.log(new Log() { - @Override public void print(Level level, String format, Object... args) { - Logger.WARNING(level + ":\t" + String.format(format, args)); - } - - @Override public void print(Level level, Throwable error, String format, Object... args) { - Logger.WARNING(level + ":\t" + String.format(format, args)); - //Utils.LOG_WARNING(error); - } - }); - - builder.callback(new Callback() { - @Override public void success(Message message) { - Logger.WARNING("Uploaded " + message); - } - - @Override public void failure(Message message, Throwable throwable) { - Logger.WARNING("Could not upload " + message); - //Utils.LOG_WARNING(throwable); - } - }); - } -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/api/analytics/BlockingFlush.java b/src/Java/gtPlusPlus/api/analytics/BlockingFlush.java deleted file mode 100644 index dddb37fefb..0000000000 --- a/src/Java/gtPlusPlus/api/analytics/BlockingFlush.java +++ /dev/null @@ -1,67 +0,0 @@ -package gtPlusPlus.api.analytics; - -import com.segment.analytics.Analytics; -import com.segment.analytics.Callback; -import com.segment.analytics.MessageTransformer; -import com.segment.analytics.Plugin; -import com.segment.analytics.messages.Message; -import com.segment.analytics.messages.MessageBuilder; -import java.util.concurrent.Phaser; - -/** - * The {@link Analytics} class doesn't come with a blocking {@link Analytics#flush()} implementation - * out of the box. It's trivial to build one using a {@link Phaser} that monitors requests and is - * able to block until they're uploaded. - * - *

- * BlockingFlush mBlockingFlush = BlockingFlush.create();
- * Analytics mHelper = Analytics.builder(writeKey)
- *      .plugin(mBlockingFlush)
- *      .build();
- *
- * // Do some work.
- *
- * mHelper.flush(); // Trigger a flush.
- * mBlockingFlush.block(); // Block until the flush completes.
- * mHelper.shutdown(); // Shut down after the flush is complete.
- * 
- */ -public class BlockingFlush { - - public static BlockingFlush create() { - return new BlockingFlush(); - } - - BlockingFlush() { - this.phaser = new Phaser(1); - } - - final Phaser phaser; - - public Plugin plugin() { - return new Plugin() { - @Override public void configure(Analytics.Builder builder) { - builder.messageTransformer(new MessageTransformer() { - @Override public boolean transform(MessageBuilder builder) { - phaser.register(); - return true; - } - }); - - builder.callback(new Callback() { - @Override public void success(Message message) { - phaser.arrive(); - } - - @Override public void failure(Message message, Throwable throwable) { - phaser.arrive(); - } - }); - } - }; - } - - public void block() { - phaser.arriveAndAwaitAdvance(); - } -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/api/analytics/SegmentAnalytics.java b/src/Java/gtPlusPlus/api/analytics/SegmentAnalytics.java deleted file mode 100644 index c4ef82b9ef..0000000000 --- a/src/Java/gtPlusPlus/api/analytics/SegmentAnalytics.java +++ /dev/null @@ -1,271 +0,0 @@ -package gtPlusPlus.api.analytics; - -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Timer; -import java.util.TimerTask; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.Phaser; - -import com.mojang.authlib.GameProfile; -import com.segment.analytics.Analytics; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.player.PlayerUtils; -import gtPlusPlus.core.util.uuid.UUIDGenerator; -import gtPlusPlus.core.util.uuid.UUIDUtils; -import ic2.core.IC2; -import net.minecraft.entity.player.EntityPlayer; - -public class SegmentAnalytics { - - //Globally Enabled - public static boolean isEnabled = true; - - //Analytics Map with IDs - public static final Map sAnalyticsMasterList = new ConcurrentHashMap(); - //ID count - private static int sAnalyticsMapID = 0; - - //Analytics Player Mapping - public static final Map sAnalyticsToPlayermap = new ConcurrentHashMap(); - - //Set some Vars - final BlockingFlush mBlockingFlush; - final SegmentHelper mHelper; - final UUIDGenerator mUuidGenerator; - - public final GameProfile mLocalProfile; - public final String mLocalName; - public final UUID mUUID; - public final String mUserName; - public final String mAnonymousId; - protected Map mProperties = new LinkedHashMap<>(); - final protected Phaser mPhaser; - - //Build a new instance of this class - public SegmentAnalytics(EntityPlayer mPlayer){ - LOG("Initializing Segment for "+mPlayer.getDisplayName()); - - //Give this Object an ID - int currentID = sAnalyticsMapID; - sAnalyticsMapID++; - - //Map this Object to it's ID and a Player UUID. - sAnalyticsMasterList.put(currentID, this); - sAnalyticsToPlayermap.put(mPlayer.getUniqueID(), currentID); - - //Create a Phaser - this.mPhaser = new Phaser(1); - - //Set vars for player - this.mLocalProfile = mPlayer.getGameProfile(); - this.mLocalName = mLocalProfile.getName(); - this.mUUID = PlayerUtils.getPlayersUUIDByName(mLocalName); - this.mUserName = mUUID.toString(); - this.mAnonymousId = getStringForm(generateIdForSession()); - - //Create a new UUID generator. - this.mUuidGenerator = new UUIDGenerator(); - - //Use Segment Analytics instead of plain Google Analytics. - this.mBlockingFlush = BlockingFlush.create(); - this.mHelper = SegmentHelper.getInstance(); - initTimer(mPlayer); - } - - //Sets vars and stops Analytics running if the player profile is invalid. - private boolean canProcess(){ - //Invalid Player Profile - if (mLocalProfile == null || !isEnabled){ - return false; - } - if (mLocalName == null || mUUID == null || mUserName == null || mAnonymousId == null){ - //LOG("One player var remained null, returning false."); - return false; - } - if (mLocalName != null && mUUID != null && mUserName != null && mAnonymousId != null){ - //LOG("All player vars are ok, returning true."); - return true; - } - LOG("Something went wrong, returning false."); - return false; - } - - - public void submitInitData(EntityPlayer mPlayer){ - if (!canProcess()){ - return; - } - mProperties = new LinkedHashMap<>(); - mProperties.put("username", mLocalName); - mProperties.put("gt_version", Utils.getGregtechVersionAsString()); - if (LoadedMods.IndustrialCraft2){ - mProperties.put("ic2_version", IC2.VERSION); - } - mProperties.put("country_code", CORE.USER_COUNTRY); - mProperties.put("gtnh", CORE.GTNH); - - LOG("Created new Data packet, queued for submission."); - - //Old Code, now passed to Helper Class - /*mHelper.enqueue(IdentifyMessage.builder() - .userId(mUserName) //Save Username as UUID, for future sessions to attach to. - .traits(mProperties) - //.anonymousId(mAnonymousId) //Save Random Session UUID - );*/ - - mHelper.addUser(this.mUserName, mProperties); - - if (CORE.GTNH){ - mHelper.groupUser("GT:NewHorizons", this.mUserName); - } - else { - mHelper.groupUser("GT:Vanilla", this.mUserName); - } - - } - - public void submitTrackingData(String aActionPerformed){ - submitTrackingData(aActionPerformed, null); - } - - public void submitTrackingData(String aActionPerformed, Object aObject){ - if (!canProcess()){ - return; - } - - Map properties = new LinkedHashMap<>(); - properties.put("blockType", aObject); - String mObjectAsString = "Unknown"; - - if (aObject != null){ - mObjectAsString = aObject.toString(); - } - - LOG("Queued submission of data for event "+aActionPerformed+". This was performed on "+mObjectAsString+"."); - - mHelper.trackUser(this.mUserName, aActionPerformed, properties); - - //Old Code, now passed to Helper Class - /*mHelper.enqueue(TrackMessage.builder(aActionPerformed) // - .userId(mUserName) // Save Username as UUID, for future sessions to attach to. - .properties(mProperties) //Save Stats - //.anonymousId(mAnonymousId) //Save Random Session UUID - ); - flushData(); - */ - } - - public void flushData(){ - getAnalyticObject().flush(); - } - - public void flushDataFinal(){ - LOG("Flushing all data from Queue to Segment Analytics database."); - getAnalyticObject().flush(); - mBlockingFlush.block(); - mPhaser.arriveAndAwaitAdvance(); - getAnalyticObject().shutdown(); - /*try { - this.finalize(); - } - catch (Throwable e) { - Utils.LOG_INFO("Could not finalize Analytics Object."); - }*/ - } - - public UUID generateIdForSession(){ - return UUIDUtils.getUUIDFromBytes(generateUUID()); - } - - private final byte[] generateUUID(){ - byte[] mUUID; - - if (this.mUuidGenerator != null){ - try { - if ((mUUID = mUuidGenerator.next(4)) != null){ - LOG("Generated Type 4 UUID for Session ID."); - return mUUID; - } - else if ((mUUID = mUuidGenerator.next(1)) != null){ - LOG("Generated Type 1 UUID for Session ID."); - return mUUID; - } - } - catch (Throwable t){ - t.printStackTrace(); - } - } - - LOG("Generated Type 3 UUID for Session ID."); - return UUIDUtils.getBytesFromUUID(UUID.randomUUID()); - - } - - public final String getStringForm(UUID mID){ - return mID.toString(); - } - - // Non-Dev Comments - public static void LOG(final String s) { - if (CORE.DEBUG){ - Logger.getLogger().info("[Analytics] "+s); - } - } - - public static SegmentAnalytics getAnalyticsForPlayer(EntityPlayer mPlayer){ - try { - if (mPlayer != null){ - if (SegmentAnalytics.sAnalyticsToPlayermap.containsKey(mPlayer.getUniqueID())){ - int ID = sAnalyticsToPlayermap.get(mPlayer.getUniqueID()); - return SegmentAnalytics.sAnalyticsMasterList.get(ID); - } - else { - LOG("Map does not contain Player."); - } - } - else { - LOG("Invalid Player."); - } - } - catch (Throwable t){ - t.printStackTrace(); - } - return null; - } - - public final Analytics getAnalyticObject() { - return mHelper.getAnalyticsClient(); - } - - public final Map getPlayerProperties(){ - return this.mProperties; - } - - - public Timer initTimer(EntityPlayer mPlayer) { - Timer timer; - timer = new Timer(); - timer.schedule(new initPlayer(mPlayer), 2 * 1000); - return timer; - } - - //Timer Task for notifying the player. - class initPlayer extends TimerTask { - final EntityPlayer aPlayer; - public initPlayer(EntityPlayer mPlayer) { - this.aPlayer = mPlayer; - } - @Override - public void run() { - //Let us submit a doorknock to Segment to let them know who this is. - submitInitData(aPlayer); - } - } - -} diff --git a/src/Java/gtPlusPlus/api/analytics/SegmentHelper.java b/src/Java/gtPlusPlus/api/analytics/SegmentHelper.java deleted file mode 100644 index 6e264fe1d2..0000000000 --- a/src/Java/gtPlusPlus/api/analytics/SegmentHelper.java +++ /dev/null @@ -1,81 +0,0 @@ -package gtPlusPlus.api.analytics; - -import com.segment.analytics.Analytics; -import com.segment.analytics.Callback; -import com.segment.analytics.messages.Message; -import com.segment.analytics.messages.TrackMessage; -import com.segment.analytics.messages.*; -import java.util.Map; - -public class SegmentHelper implements Callback { - - /** - * Credits to Author: FLAMINSAGANAKI/Theodore Mavrakis - * http://domisydev.com/2015/11/05/using-segment-analytics-in-your-java-servlet/ - */ - - private static final String writeKey = "EDOWl9peleGlUqe1ZwTqKDyuTMFhyT4k"; - private static volatile SegmentHelper segment = new SegmentHelper(); - private Analytics analytics; - - public SegmentHelper(){ - try{ - this.analytics = Analytics.builder(writeKey).callback(this).build(); - }catch(Exception e){ - SegmentAnalytics.LOG("exception while creating Analytics : " + e); - } - } - - public static SegmentHelper getInstance(){ - return segment; - } - - public Analytics getAnalyticsClient(){ - return segment.analytics; - } - - public void success(Message message) { - SegmentAnalytics.LOG("Successfully uploaded " + message); - } - - public void failure(Message message, Throwable throwable) { - SegmentAnalytics.LOG("Could not upload " + message); - } - - public void addUser(String user_id, Map properties) { - try { - this.analytics.enqueue(IdentifyMessage.builder().userId(user_id).traits(properties)); - //trackUser(user_id, "Logged In", properties); - } catch (Exception e) { - SegmentAnalytics.LOG("Exception in addUser() - " + e); - } - } - - public void trackUser(String user_id, String description, Map properties) { - try { - this.analytics.enqueue(TrackMessage.builder(description).userId(user_id).properties(properties)); - } catch (Exception e) { - SegmentAnalytics.LOG("Exception in trackUser() - " + e); - } - } - - public void trackUser(String user_id, String description) { - try { - this.analytics.enqueue(TrackMessage.builder(description).userId(user_id)); - } catch (Exception e) { - SegmentAnalytics.LOG("Exception in trackUser() - " + e); - } - } - - public void groupUser(String group_id, String user_id) { - try { - this.analytics.enqueue(GroupMessage.builder(group_id).userId(user_id)); - } catch (Exception e) { - SegmentAnalytics.LOG("Exception in groupUser() - " + e); - } - } - - public static void main(String[] args){ - - } -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/api/damage/BaseCustomDamageSource.java b/src/Java/gtPlusPlus/api/damage/BaseCustomDamageSource.java deleted file mode 100644 index 24348988d6..0000000000 --- a/src/Java/gtPlusPlus/api/damage/BaseCustomDamageSource.java +++ /dev/null @@ -1,22 +0,0 @@ -package gtPlusPlus.api.damage; - -import net.minecraft.entity.Entity; -import net.minecraft.util.EntityDamageSourceIndirect; - -public class BaseCustomDamageSource extends EntityDamageSourceIndirect { - - public BaseCustomDamageSource(String name, Entity transmitter, Entity indirectSource) { - super(name, transmitter, indirectSource); - this.setDifficultyScaled(); - } - - /** - * Return whether this damage source will have its damage amount scaled based on the current difficulty. - */ - public boolean isDifficultyScaled() - { - return true; - } - - -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/api/damage/DamageTeslaTower.java b/src/Java/gtPlusPlus/api/damage/DamageTeslaTower.java index ada2ba5c3d..ecde9fe930 100644 --- a/src/Java/gtPlusPlus/api/damage/DamageTeslaTower.java +++ b/src/Java/gtPlusPlus/api/damage/DamageTeslaTower.java @@ -1,5 +1,6 @@ package gtPlusPlus.api.damage; +import gtPlusPlus.core.world.damage.BaseCustomDamageSource; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.ChatComponentTranslation; diff --git a/src/Java/gtPlusPlus/api/helpers/MaterialHelper.java b/src/Java/gtPlusPlus/api/helpers/MaterialHelper.java new file mode 100644 index 0000000000..bb30727992 --- /dev/null +++ b/src/Java/gtPlusPlus/api/helpers/MaterialHelper.java @@ -0,0 +1,18 @@ +package gtPlusPlus.api.helpers; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.item.ItemUtils; +import net.minecraft.item.ItemStack; + +public class MaterialHelper { + + public static ItemStack getComponentFromMaterial(OrePrefixes oreprefix, Material material, int amount){ + return ItemUtils.getOrePrefixStack(oreprefix, material, amount); + } + public static ItemStack getComponentFromGtMaterial(OrePrefixes oreprefix, Materials material, int amount){ + return ItemUtils.getGregtechOreStack(oreprefix, material, amount); + } + +} diff --git a/src/Java/gtPlusPlus/api/interfaces/IEntityCatcher.java b/src/Java/gtPlusPlus/api/interfaces/IEntityCatcher.java index ca2d80de53..12813e1dd0 100644 --- a/src/Java/gtPlusPlus/api/interfaces/IEntityCatcher.java +++ b/src/Java/gtPlusPlus/api/interfaces/IEntityCatcher.java @@ -1,6 +1,6 @@ package gtPlusPlus.api.interfaces; -import gtPlusPlus.core.util.array.BlockPos; +import gtPlusPlus.api.objects.minecraft.BlockPos; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.world.World; diff --git a/src/Java/gtPlusPlus/api/objects/CSPRNG_DO_NOT_USE.java b/src/Java/gtPlusPlus/api/objects/CSPRNG_DO_NOT_USE.java deleted file mode 100644 index 19200846ca..0000000000 --- a/src/Java/gtPlusPlus/api/objects/CSPRNG_DO_NOT_USE.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright 2005, Nick Galbreath -- nickg [at] modp [dot] com - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the modp.com nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This is the standard "new" BSD license: - * http://www.opensource.org/licenses/bsd-license.php - */ - -package gtPlusPlus.api.objects; -import java.math.BigInteger; -import java.security.SecureRandom; -import java.util.Random; - -import gtPlusPlus.api.interfaces.IRandomGenerator; -import gtPlusPlus.core.util.Utils; - -/** - * The Blum-Blum-Shub random number generator. - * - *

- * The Blum-Blum-Shub is a "cryptographically secure" random number - * generator. It has been proven that predicting the ouput - * is equivalent to factoring n, a large integer generated - * from two prime numbers. - *

- * - *

- * The Algorithm: - *

- *
    - *
  1. - * (setup) generate two secret prime numbers p, q such that - * pq, p ≡ 3 mod 4, q ≡ 3 mod 4. - *
  2. - *
  3. (setup) compute n = pq. n can be re-used, but - * p, and q are secret and should be disposed of.
  4. - *
  5. Generate a (secure) random seed s in the range [1, n -1] - * such that gcd(s, n) = 1. - *
  6. Compute x = s2 mod n
  7. - *
  8. Compute a single random bit with: - *
      - *
    1. x = x2 mod n
    2. - *
    3. return Least-Significant-Bit(x) (i.e. x & 1)
    4. - *
    - * Repeat as necessary. - *
  9. - *
- * - *

- * The code originally appeared in Cryptography for - * Internet and Database Applications , Chapter 4, pages 174-177 - *

- *

- * More details are in the Handbook of Applied Cryptography, - * Section 5.5.2 - *

- * - * @author Nick Galbreath -- nickg [at] modp [dot] com - * @version 3 -- 06-Jul-2005 - * - */ -public class CSPRNG_DO_NOT_USE extends Random implements IRandomGenerator { - - // pre-compute a few values - private static final BigInteger two = BigInteger.valueOf(2L); - - private static final BigInteger three = BigInteger.valueOf(3L); - - private static final BigInteger four = BigInteger.valueOf(4L); - - /** - * main parameter - */ - private BigInteger n; - - private BigInteger state; - - /** - * Generate appropriate prime number for use in Blum-Blum-Shub. - * - * This generates the appropriate primes (p = 3 mod 4) needed to compute the - * "n-value" for Blum-Blum-Shub. - * - * @param bits Number of bits in prime - * @param rand A source of randomness - */ - private static BigInteger getPrime(int bits, Random rand) { - BigInteger p; - while (true) { - p = new BigInteger(bits, 100, rand); - if (p.mod(four).equals(three)) - break; - } - return p; - } - - /** - * This generates the "n value" -- the multiplication of two equally sized - * random prime numbers -- for use in the Blum-Blum-Shub algorithm. - * - * @param bits - * The number of bits of security - * @param rand - * A random instance to aid in generating primes - * @return A BigInteger, the n. - */ - public static BigInteger generateN(int bits, Random rand) { - BigInteger p = getPrime(bits/2, rand); - BigInteger q = getPrime(bits/2, rand); - - // make sure p != q (almost always true, but just in case, check) - while (p.equals(q)) { - q = getPrime(bits, rand); - } - return p.multiply(q); - } - - /** - * Constructor, specifing bits for n - * - * @param bits number of bits - */ - public CSPRNG_DO_NOT_USE(int bits) { - this(bits, new Random()); - } - - /** - * Constructor, generates prime and seed - * - * @param bits - * @param rand - */ - public CSPRNG_DO_NOT_USE(int bits, Random rand) { - this(generateN(bits, rand)); - } - - /** - * A constructor to specify the "n-value" to the Blum-Blum-Shub algorithm. - * The inital seed is computed using Java's internal "true" random number - * generator. - * - * @param n - * The n-value. - */ - public CSPRNG_DO_NOT_USE(BigInteger n) { - this(n, SecureRandom.getSeed(n.bitLength() / 8)); - } - - /** - * A constructor to specify both the n-value and the seed to the - * Blum-Blum-Shub algorithm. - * - * @param n - * The n-value using a BigInteger - * @param seed - * The seed value using a byte[] array. - */ - public CSPRNG_DO_NOT_USE(BigInteger n, byte[] seed) { - this.n = n; - setSeed(seed); - } - - /** - * Sets or resets the seed value and internal state - * - * @param seedBytes - * The new seed. - */ - public void setSeed(byte[] seedBytes) { - // ADD: use hardwired default for n - BigInteger seed = new BigInteger(1, seedBytes); - state = seed.mod(n); - } - - /** - * Returns up to numBit random bits - * - * @return int - */ - @Override - public int next(int numBits) { - // TODO: find out how many LSB one can extract per cycle. - // it is more than one. - int result = 0; - for (int i = numBits; i != 0; --i) { - state = state.modPow(two, n); - result = (result << 1) | (state.testBit(0) == true ? 1 : 0); - } - return result; - } - - - public static CSPRNG_DO_NOT_USE generate(){ - return generate(512); - } - - /** - * @return CSPRNG_DO_NOT_USE - * @Author Draknyte1/Alkalus - */ - public static CSPRNG_DO_NOT_USE generate(int bitsize){ - // First use the internal, stock "true" random number - // generator to get a "true random seed" - SecureRandom r = Utils.generateSecureRandom(); - r.nextInt(); // need to do something for SR to be triggered. - // Use this seed to generate a n-value for Blum-Blum-Shub - // This value can be re-used if desired. - BigInteger nval = CSPRNG_DO_NOT_USE.generateN(bitsize, r); - // now get a seed - byte[] seed = new byte[bitsize/8]; - r.nextBytes(seed); - // now create an instance of BlumBlumShub - CSPRNG_DO_NOT_USE bbs = new CSPRNG_DO_NOT_USE(nval, seed); - return bbs; - } - - - /** - * @return CSPRNG_DO_NOT_USE - * @Author Draknyte1/Alkalus - */ - public static CSPRNG_DO_NOT_USE generate(Random aRandom){ - return generate(512, aRandom); - } - - /** - * @return CSPRNG_DO_NOT_USE - * @Author Draknyte1/Alkalus - */ - public static CSPRNG_DO_NOT_USE generate(int aBitSize, Random aRandom){ - // First use the internal, stock "true" random number - // generator to get a "true random seed" - SecureRandom r = Utils.generateSecureRandom(); - r.nextInt(); // need to do something for SR to be triggered. - // Use this seed to generate a n-value for Blum-Blum-Shub - // This value can be re-used if desired. - int bitsize = aBitSize; - // now create an instance of BlumBlumShub - // do everything almost automatically - CSPRNG_DO_NOT_USE bbs = new CSPRNG_DO_NOT_USE(bitsize, aRandom); - return bbs; - } - -} diff --git a/src/Java/gtPlusPlus/api/objects/ChunkManager.java b/src/Java/gtPlusPlus/api/objects/ChunkManager.java deleted file mode 100644 index 0bace04bf8..0000000000 --- a/src/Java/gtPlusPlus/api/objects/ChunkManager.java +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright (c) CovertJaguar, 2014 http://railcraft.info - * - * This code is the property of CovertJaguar - * and may only be used with explicit written - * permission unless otherwise specified on the - * license page at http://railcraft.info/wiki/info:license. - */ -package gtPlusPlus.api.objects; - -import com.google.common.collect.LinkedListMultimap; -import com.google.common.collect.ListMultimap; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import gtPlusPlus.GTplusplus; -import gtPlusPlus.core.util.array.BlockPos; -import gtPlusPlus.core.util.array.Triplet; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaTileEntityChunkLoader; - -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import java.util.Timer; -import java.util.TimerTask; -import java.util.concurrent.ConcurrentHashMap; - -import net.minecraft.world.ChunkCoordIntPair; -import net.minecraft.entity.Entity; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraftforge.common.ForgeChunkManager; -import net.minecraftforge.common.ForgeChunkManager.LoadingCallback; -import net.minecraftforge.common.ForgeChunkManager.OrderedLoadingCallback; -import net.minecraftforge.common.ForgeChunkManager.Ticket; -import net.minecraftforge.common.ForgeChunkManager.Type; -import net.minecraftforge.event.entity.EntityEvent; - -/** - * @author CovertJaguar - */ -public class ChunkManager implements LoadingCallback, OrderedLoadingCallback, ForgeChunkManager.PlayerOrderedLoadingCallback { - - private static ChunkManager instance; - - public static ConcurrentHashMap> mChunkLoaderManagerMap = new ConcurrentHashMap>(); - - - public static ChunkManager getInstance() { - if (instance == null) { - instance = new ChunkManager(); - } - return instance; - } - - @SubscribeEvent - public void entityEnteredChunk(EntityEvent.EnteringChunk event) { - - } - - /** - * Returns a Set of ChunkCoordIntPair containing the chunks between the - * start and end chunks. - *

- * One of the pairs of start/end coords need to be equal. - *

- * Coordinates are in chunk coordinates, not world coordinates. - * - * @param xChunkA Start Chunk x-Coord - * @param zChunkA Start Chunk z-Coord - * @param xChunkB End Chunk x-Coord - * @param zChunkB End Chunk z-Coord - * @param max Max number of chunks to return - * @return A set of chunks. - */ - public Set getChunksBetween(int xChunkA, int zChunkA, int xChunkB, int zChunkB, int max) { - Set chunkList = new HashSet(); - - if (xChunkA != xChunkB && zChunkA != zChunkB) { - return chunkList; - } - - int xStart = Math.min(xChunkA, xChunkB); - int xEnd = Math.max(xChunkA, xChunkB); - - int zStart = Math.min(zChunkA, zChunkB); - int zEnd = Math.max(zChunkA, zChunkB); - - for (int xx = xStart; xx <= xEnd; xx++) { - for (int zz = zStart; zz <= zEnd; zz++) { - chunkList.add(new ChunkCoordIntPair(xx, zz)); - if (chunkList.size() >= max) { - return chunkList; - } - } - } - return chunkList; - } - - /** - * Returns a Set of ChunkCoordIntPair containing the chunks around point [x, - * z]. Coordinates are in chunk coordinates, not world coordinates. - * - * @param xChunk Chunk x-Coord - * @param zChunk Chunk z-Coord - * @param radius Distance from [x, z] to include, in number of chunks. - * @return A set of chunks. - */ - public Set getChunksAround(int xChunk, int zChunk, int radius) { - Set chunkList = new HashSet(); - for (int xx = xChunk - radius; xx <= xChunk + radius; xx++) { - for (int zz = zChunk - radius; zz <= zChunk + radius; zz++) { - chunkList.add(new ChunkCoordIntPair(xx, zz)); - } - } - return chunkList; - } - - /** - * Returns a Set of ChunkCoordIntPair containing the chunks around point [x, - * z]. Coordinates are in world coordinates, not chunk coordinates. - * - * @param xWorld World x-Coord - * @param zWorld World z-Coord - * @param radius Distance from [x, z] to include, in blocks. - * @return A set of chunks. - */ - public Set getBufferAround(int xWorld, int zWorld, int radius) { - int minX = (xWorld - radius) >> 4; - int maxX = (xWorld + radius) >> 4; - int minZ = (zWorld - radius) >> 4; - int maxZ = (zWorld + radius) >> 4; - - Set chunkList = new HashSet(); - for (int xx = minX; xx <= maxX; xx++) { - for (int zz = minZ; zz <= maxZ; zz++) { - chunkList.add(new ChunkCoordIntPair(xx, zz)); - } - } - return chunkList; - } - - private void printAnchor(String type, int x, int y, int z) { - Logger.INFO("[Chunk Loader] "+type+" @ [x: "+x+"][y: "+y+"][z: "+z+"]"); - } - - @Override - public void ticketsLoaded(List tickets, World world) { - - if (world.isRemote) return; - - // System.out.println("Callback 2"); - for (Ticket ticket : tickets) { - if (ticket.isPlayerTicket()) - continue; - Entity entity = ticket.getEntity(); - if (entity == null) { - int x = ticket.getModData().getInteger("xCoord"); - int y = ticket.getModData().getInteger("yCoord"); - int z = ticket.getModData().getInteger("zCoord"); - - if (y >= 0) { - BlockPos tile = new BlockPos(x, y, z); - - Ticket H = tryForceLoadChunk(new DimChunkPos(world, tile).getChunk()); - - int jhg = 0; - while (jhg < 50) { - jhg++; - } - - if (!mChunkLoaderManagerMap.isEmpty()) { - GregtechMetaTileEntityChunkLoader f = mChunkLoaderManagerMap.get(tile).getValue_2(); - int timeout = 0; - while (f == null) { - if (timeout > 5000) { - Logger.INFO("[Chunk Loader] Timed out"); - break; - } - else { - GregtechMetaTileEntityChunkLoader g; - if (!mChunkLoaderManagerMap.isEmpty()) { - g = mChunkLoaderManagerMap.get(tile).getValue_2(); - if (g == null) { - timeout++; - } - else { - Logger.INFO("[Chunk Loader]Tile became Valid"); - f = g; - break; - } - } - } - } - try { - if (f != null) { - - - if (H != null) { - ForgeChunkManager.releaseTicket(H); - } - - f.forceChunkLoading(ticket); - printAnchor("Force Chunk Loading. Chunk Loader has ID of "+f.getLoaderID()+". ",x,y,z); - } - else { - Logger.INFO("Tile Entity is null."); - } - } - catch (Throwable t) { - t.printStackTrace(); - Logger.INFO("Mild problem with chunk loading, nothing to worry about."); - } - - - if (H != null) { - ForgeChunkManager.releaseTicket(H); - } - - } - - /*if (tile instanceof IGregTechTileEntity) { - final IGregTechTileEntity tGregTechTileEntity = (IGregTechTileEntity) tile; - IGregTechTileEntity anchor = (IGregTechTileEntity) tile; - GregtechMetaTileEntityChunkLoader jun = (GregtechMetaTileEntityChunkLoader) anchor; - jun.forceChunkLoading(ticket); - //printAnchor(anchor.getName(), x, y, z); - }*/ - } - } - } - } - - @Override - public List ticketsLoaded(List tickets, World world, int maxTicketCount) { - // System.out.println("Callback 1"); - Set adminTickets = new HashSet(); - Set worldTickets = new HashSet(); - Set cartTickets = new HashSet(); - for (Ticket ticket : tickets) { - Entity entity = ticket.getEntity(); - if (entity == null) { - int x = ticket.getModData().getInteger("xCoord"); - int y = ticket.getModData().getInteger("yCoord"); - int z = ticket.getModData().getInteger("zCoord"); - if (y >= 0) { - worldTickets.add(ticket); - } - } - } - - List claimedTickets = new LinkedList(); - claimedTickets.addAll(cartTickets); - claimedTickets.addAll(adminTickets); - claimedTickets.addAll(worldTickets); - return claimedTickets; - } - - @Override - public ListMultimap playerTicketsLoaded(ListMultimap tickets, World world) { - return LinkedListMultimap.create(); - } - - - public static Timer createChunkQueue() { - return ChunkTimerLoader(); - } - - public static Ticket tryForceLoadChunk(Chunk c) { - Ticket T = getTicketFromForge(c.worldObj); - ForgeChunkManager.forceChunk(T, c.getChunkCoordIntPair()); - Logger.INFO("[Chunk Loader] Trying to force load a chunk that holds a chunkloader."); - return T; - } - - public static Ticket getTicketFromForge(World world) { - return ForgeChunkManager.requestTicket(GTplusplus.instance, world, Type.NORMAL); - } - - static Timer ChunkTimerLoader() { - Timer timer; - timer = new Timer(); - timer.schedule(new ChunkCache(), 10 * 1000); - return timer; - } - - //Timer Task for notifying the player. - static class ChunkCache extends TimerTask { - public ChunkCache() { - - } - - @Override - public void run() { - if (mChunkLoaderManagerMap.size() > 0) { - for (Triplet j : mChunkLoaderManagerMap.values()) { - Ticket T; - Chunk C; - T = j.getValue_2().getTicketFromForge(); - C = j.getValue_3().getChunk(); - ForgeChunkManager.forceChunk(T, C.getChunkCoordIntPair()); - Logger.INFO("[Chunk Loader] Trying to force load a chunk that holds a chunkloader."); - } - } - else { - Logger.INFO("[Chunk Loader] No chunks to try to force load chunks that hold chunkloaders."); - } - } - } -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/api/objects/DimChunkPos.java b/src/Java/gtPlusPlus/api/objects/DimChunkPos.java deleted file mode 100644 index bea0a4ec3b..0000000000 --- a/src/Java/gtPlusPlus/api/objects/DimChunkPos.java +++ /dev/null @@ -1,53 +0,0 @@ -package gtPlusPlus.api.objects; - -import gtPlusPlus.core.util.array.BlockPos; -import net.minecraft.client.Minecraft; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; - -public class DimChunkPos { - - public final int dimension; - public final int xPos; - public final int zPos; - public final Chunk mainChunk; - - - public DimChunkPos(World world, BlockPos block){ - this.dimension = world.provider.dimensionId; - this.mainChunk = world.getChunkFromBlockCoords(block.xPos, block.zPos); - this.xPos = this.mainChunk.xPosition; - this.zPos = this.mainChunk.zPosition; - } - - - public DimChunkPos(TileEntity tile){ - this.dimension = tile.getWorldObj().provider.dimensionId; - this.mainChunk = tile.getWorldObj().getChunkFromBlockCoords(tile.xCoord, tile.zCoord); - this.xPos = this.mainChunk.xPosition; - this.zPos = this.mainChunk.zPosition; - } - - public DimChunkPos(int dim, int x, int z){ - this.dimension = dim; - this.xPos = x; - this.zPos = z; - Chunk h = Minecraft.getMinecraft().getIntegratedServer().worldServerForDimension(dim).getChunkFromChunkCoords(xPos, zPos); - if (h == null) { - this.mainChunk = null; - } - else { - this.mainChunk = h; - } - } - - public Chunk getChunk() { - if (this.mainChunk != null) { - return this.mainChunk; - } - Chunk h = Minecraft.getMinecraft().getIntegratedServer().worldServerForDimension(this.dimension).getChunkFromChunkCoords(xPos, zPos); - return h; - } - -} diff --git a/src/Java/gtPlusPlus/api/objects/GenericStack.java b/src/Java/gtPlusPlus/api/objects/GenericStack.java deleted file mode 100644 index b3bc94364f..0000000000 --- a/src/Java/gtPlusPlus/api/objects/GenericStack.java +++ /dev/null @@ -1,41 +0,0 @@ -package gtPlusPlus.api.objects; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -public class GenericStack { - - private ItemStack mItemStack; - private FluidStack mFluidStack; - - public GenericStack(ItemStack s){ - this.mItemStack = s; - this.mFluidStack = null; - } - - public GenericStack(FluidStack f){ - this.mItemStack = null; - this.mFluidStack = f; - } - - public GenericStack() { - this.mItemStack = null; - this.mFluidStack = null; - } - - public synchronized final FluidStack getFluidStack() { - return mFluidStack; - } - - public synchronized final ItemStack getItemStack() { - return mItemStack; - } - - public synchronized final void setItemStack(ItemStack mItemStack) { - this.mItemStack = mItemStack; - } - - public synchronized final void setFluidStack(FluidStack mFluidStack) { - this.mFluidStack = mFluidStack; - } -} diff --git a/src/Java/gtPlusPlus/api/objects/MaterialHelper.java b/src/Java/gtPlusPlus/api/objects/MaterialHelper.java deleted file mode 100644 index d63ab7a15a..0000000000 --- a/src/Java/gtPlusPlus/api/objects/MaterialHelper.java +++ /dev/null @@ -1,18 +0,0 @@ -package gtPlusPlus.api.objects; - -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.util.item.ItemUtils; -import net.minecraft.item.ItemStack; - -public class MaterialHelper { - - public static ItemStack getComponentFromMaterial(OrePrefixes oreprefix, Material material, int amount){ - return ItemUtils.getOrePrefixStack(oreprefix, material, amount); - } - public static ItemStack getComponentFromGtMaterial(OrePrefixes oreprefix, Materials material, int amount){ - return ItemUtils.getGregtechOreStack(oreprefix, material, amount); - } - -} diff --git a/src/Java/gtPlusPlus/api/objects/XSTR.java b/src/Java/gtPlusPlus/api/objects/XSTR.java deleted file mode 100644 index 3ff0792f6e..0000000000 --- a/src/Java/gtPlusPlus/api/objects/XSTR.java +++ /dev/null @@ -1,266 +0,0 @@ -package gtPlusPlus.api.objects; -/** - * A subclass of java.util.random that implements the Xorshift random number - * generator - * - * - it is 30% faster than the generator from Java's library - it produces - * random sequences of higher quality than java.util.Random - this class also - * provides a clone() function - * - * Usage: XSRandom rand = new XSRandom(); //Instantiation x = rand.nextInt(); - * //pull a random number - * - * To use the class in legacy code, you may also instantiate an XSRandom object - * and assign it to a java.util.Random object: java.util.Random rand = new - * XSRandom(); - * - * for an explanation of the algorithm, see - * http://demesos.blogspot.com/2011/09/pseudo-random-number-generators.html - * - * @author Wilfried Elmenreich University of Klagenfurt/Lakeside Labs - * http://www.elmenreich.tk - * - * This code is released under the GNU Lesser General Public License Version 3 - * http://www.gnu.org/licenses/lgpl-3.0.txt - */ - -import java.util.Random; -import java.util.concurrent.atomic.AtomicLong; - -/** - * XSTR - Xorshift ThermiteRandom - * Modified by Bogdan-G - * 03.06.2016 - * version 0.0.4 - */ -public class XSTR extends Random { - - private static final long serialVersionUID = 6208727693524452904L; - private long seed; - private long last; - private static final long GAMMA = 0x9e3779b97f4a7c15L; - private static final int PROBE_INCREMENT = 0x9e3779b9; - private static final long SEEDER_INCREMENT = 0xbb67ae8584caa73bL; - private static final double DOUBLE_UNIT = 0x1.0p-53; // 1.0 / (1L << 53) - private static final float FLOAT_UNIT = 0x1.0p-24f; // 1.0f / (1 << 24) - - /* - MODIFIED BY: Robotia - Modification: Implemented Random class seed generator - */ - /** - * Creates a new pseudo random number generator. The seed is initialized to - * the current time, as if by - * setSeed(System.currentTimeMillis());. - */ - public XSTR() { - this(seedUniquifier() ^ System.nanoTime()); - } - private static final AtomicLong seedUniquifier - = new AtomicLong(8682522807148012L); - - private static long seedUniquifier() { - // L'Ecuyer, "Tables of Linear Congruential Generators of - // Different Sizes and Good Lattice Structure", 1999 - for (;;) { - final long current = seedUniquifier.get(); - final long next = current * 181783497276652981L; - if (seedUniquifier.compareAndSet(current, next)) { - return next; - } - } - } - - /** - * Creates a new pseudo random number generator, starting with the specified - * seed, using setSeed(seed);. - * - * @param seed the initial seed - */ - public XSTR(final long seed) { - this.seed = seed; - } - @Override - public boolean nextBoolean() { - return this.next(1) != 0; - } - - @Override - public double nextDouble() { - return (((long)(this.next(26)) << 27) + this.next(27)) * DOUBLE_UNIT; - } - /** - * Returns the current state of the seed, can be used to clone the object - * - * @return the current seed - */ - public synchronized long getSeed() { - return this.seed; - } - - /** - * Sets the seed for this pseudo random number generator. As described - * above, two instances of the same random class, starting with the same - * seed, produce the same results, if the same methods are called. - * - * @param seed the new seed - */ - @Override - public synchronized void setSeed(final long seed) { - this.seed = seed; - } - - /** - * @return Returns an XSRandom object with the same state as the original - */ - @Override - public XSTR clone() { - return new XSTR(this.getSeed()); - } - - /** - * Implementation of George Marsaglia's elegant Xorshift random generator - * 30% faster and better quality than the built-in java.util.random see also - * see http://www.javamex.com/tutorials/random_numbers/xorshift.shtml - * - * @param nbits - * @return - */ - @Override - public int next(final int nbits) { - long x = this.seed; - x ^= (x << 21); - x ^= (x >>> 35); - x ^= (x << 4); - this.seed = x; - x &= ((1L << nbits) - 1); - return (int) x; - } - boolean haveNextNextGaussian = false; - double nextNextGaussian = 0; - @Override - synchronized public double nextGaussian() { - // See Knuth, ACP, Section 3.4.1 Algorithm C. - if (this.haveNextNextGaussian) { - this.haveNextNextGaussian = false; - return this.nextNextGaussian; - } - double v1, v2, s; - do { - v1 = (2 * this.nextDouble()) - 1; // between -1 and 1 - v2 = (2 * this.nextDouble()) - 1; // between -1 and 1 - s = (v1 * v1) + (v2 * v2); - } while ((s >= 1) || (s == 0)); - final double multiplier = StrictMath.sqrt((-2 * StrictMath.log(s))/s); - this.nextNextGaussian = v2 * multiplier; - this.haveNextNextGaussian = true; - return v1 * multiplier; - } - /** - * Returns a pseudorandom, uniformly distributed {@code int} value between 0 - * (inclusive) and the specified value (exclusive), drawn from this random - * number generator's sequence. The general contract of {@code nextInt} is - * that one {@code int} value in the specified range is pseudorandomly - * generated and returned. All {@code bound} possible {@code int} values are - * produced with (approximately) equal probability. The method - * {@code nextInt(int bound)} is implemented by class {@code Random} as if - * by: - *

 {@code
-	 * public int nextInt(int bound) {
-	 *   if (bound <= 0)
-	 *     throw new IllegalArgumentException("bound must be positive");
-	 *
-	 *   if ((bound & -bound) == bound)  // i.e., bound is a power of 2
-	 *     return (int)((bound * (long)next(31)) >> 31);
-	 *
-	 *   int bits, val;
-	 *   do {
-	 *       bits = next(31);
-	 *       val = bits % bound;
-	 *   } while (bits - val + (bound-1) < 0);
-	 *   return val;
-	 * }}
- * - *

The hedge "approx - * imately" is used in the foregoing description only because the next - * method is only approximately an unbiased source of independently chosen - * bits. If it were a perfect source of randomly chosen bits, then the - * algorithm shown would choose {@code int} values from the stated range - * with perfect uniformity. - *

- * The algorithm is slightly tricky. It rejects values that would result in - * an uneven distribution (due to the fact that 2^31 is not divisible by n). - * The probability of a value being rejected depends on n. The worst case is - * n=2^30+1, for which the probability of a reject is 1/2, and the expected - * number of iterations before the loop terminates is 2. - *

- * The algorithm treats the case where n is a power of two specially: it - * returns the correct number of high-order bits from the underlying - * pseudo-random number generator. In the absence of special treatment, the - * correct number of low-order bits would be returned. Linear - * congruential pseudo-random number generators such as the one implemented - * by this class are known to have short periods in the sequence of values - * of their low-order bits. Thus, this special case greatly increases the - * length of the sequence of values returned by successive calls to this - * method if n is a small power of two. - * - * @param bound the upper bound (exclusive). Must be positive. - * @return the next pseudorandom, uniformly distributed {@code int} value - * between zero (inclusive) and {@code bound} (exclusive) from this random - * number generator's sequence - * @throws IllegalArgumentException if bound is not positive - * @since 1.2 - */ - @Override - public int nextInt(final int bound) { - //if (bound <= 0) { - //throw new RuntimeException("BadBound"); - //} - - /*int r = next(31); - int m = bound - 1; - if ((bound & m) == 0) // i.e., bound is a power of 2 - { - r = (int) ((bound * (long) r) >> 31); - } else { - for (int u = r; - u - (r = u % bound) + m < 0; - u = next(31)) - ; - } - return r;*/ - //speedup, new nextInt ~+40% - this.last = this.seed ^ (this.seed << 21); - this.last ^= (this.last >>> 35); - this.last ^= (this.last << 4); - this.seed = this.last; - final int out = (int) this.last % bound; - return (out < 0) ? -out : out; - } - @Override - public int nextInt() { - return this.next(32); - } - - @Override - public float nextFloat() { - return this.next(24) * FLOAT_UNIT; - } - - @Override - public long nextLong() { - // it's okay that the bottom word remains signed. - return ((long)(this.next(32)) << 32) + this.next(32); - } - - @Override - public void nextBytes(final byte[] bytes_arr) { - for (int iba = 0, lenba = bytes_arr.length; iba < lenba; ) { - for (int rndba = this.nextInt(), - nba = Math.min(lenba - iba, Integer.SIZE/Byte.SIZE); - nba-- > 0; rndba >>= Byte.SIZE) { - bytes_arr[iba++] = (byte)rndba; - } - } - } -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java new file mode 100644 index 0000000000..a8d24d36d8 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java @@ -0,0 +1,77 @@ +package gtPlusPlus.api.objects.data; + +import java.io.Serializable; +import java.util.*; + +public class AutoMap implements Iterable, Cloneable, Serializable { + + /** + * The Internal Map + */ + private Map mInternalMap = new HashMap(); + + /** + * The Internal ID + */ + private int mInternalID = 0; + private static final long serialVersionUID = 3771412318075131790L; + + @Override + public Iterator iterator() { + return values().iterator(); + } + + public synchronized boolean setValue(V object){ + int mOriginalID = this.mInternalID; + put(object); + if (this.mInternalMap.get(mOriginalID).equals(object) || mOriginalID > this.mInternalID){ + return true; + } + else { + return false; + } + } + + public synchronized V put(V object){ + return set(object); + } + + public synchronized V set(V object){ + return mInternalMap.put(mInternalID++, object); + } + + public synchronized V get(int id){ + return mInternalMap.get(id); + } + + public synchronized Collection values(){ + return mInternalMap.values(); + } + + public synchronized int size(){ + return mInternalMap.size(); + } + + public synchronized int hashcode(){ + return mInternalMap.hashCode(); + } + + public synchronized boolean containsKey(int key){ + return mInternalMap.containsKey(key); + } + + public synchronized boolean containsValue(V value){ + return mInternalMap.containsValue(value); + } + + public synchronized boolean isEmpty(){ + return mInternalMap.isEmpty(); + } + + public synchronized boolean clear(){ + this.mInternalID = 0; + this.mInternalMap.clear(); + return true; + } + +} diff --git a/src/Java/gtPlusPlus/api/objects/data/Pair.java b/src/Java/gtPlusPlus/api/objects/data/Pair.java new file mode 100644 index 0000000000..6ab781cf1e --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/data/Pair.java @@ -0,0 +1,27 @@ +package gtPlusPlus.api.objects.data; + +import java.io.Serializable; + +public class Pair implements Serializable { + + /** + * SVUID + */ + private static final long serialVersionUID = 1250550491092812443L; + private final K key; + private final V value; + + public Pair(final K key, final V value){ + this.key = key; + this.value = value; + } + + final public K getKey(){ + return this.key; + } + + final public V getValue(){ + return this.value; + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/api/objects/data/Quad.java b/src/Java/gtPlusPlus/api/objects/data/Quad.java new file mode 100644 index 0000000000..01c62e95e6 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/data/Quad.java @@ -0,0 +1,33 @@ +package gtPlusPlus.api.objects.data; + +public class Quad { + + private final K key; + private final V value; + private final C value2; + private final R value3; + + public Quad(final K key, final V value, final C value2, final R value3){ + this.key = key; + this.value = value; + this.value2 = value2; + this.value3 = value3; + } + + final public K getKey(){ + return this.key; + } + + final public V getValue_1(){ + return this.value; + } + + final public C getValue_2(){ + return this.value2; + } + + final public R getValue_3(){ + return this.value3; + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/api/objects/data/Triplet.java b/src/Java/gtPlusPlus/api/objects/data/Triplet.java new file mode 100644 index 0000000000..affb03d868 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/data/Triplet.java @@ -0,0 +1,27 @@ +package gtPlusPlus.api.objects.data; + +public class Triplet { + + private final K key; + private final V value; + private final C count; + + public Triplet(final K key, final V value, final C value2){ + this.key = key; + this.value = value; + this.count = value2; + } + + final public K getValue_1(){ + return this.key; + } + + final public V getValue_2(){ + return this.value; + } + + final public C getValue_3(){ + return this.count; + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java b/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java new file mode 100644 index 0000000000..d258d1fe73 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java @@ -0,0 +1,85 @@ +package gtPlusPlus.api.objects.minecraft; + +import java.io.Serializable; + +public class BlockPos implements Serializable{ + + private static final long serialVersionUID = -7271947491316682006L; + public final int xPos; + public final int yPos; + public final int zPos; + public final int dim; + + public BlockPos(int x, int y, int z){ + this(x, y, z, 0); + } + + public BlockPos(int x, int y, int z, int dim){ + this.xPos = x; + this.yPos = y; + this.zPos = z; + this.dim = dim; + } + + public String getLocationString() { + return "[X: "+this.xPos+"][Y: "+this.yPos+"][Z: "+this.zPos+"][Dim: "+this.dim+"]"; + } + + @Override + public int hashCode() { + int hash = 5; + hash += (13 * this.xPos); + hash += (19 * this.yPos); + hash += (31 * this.zPos); + hash += (17 * this.dim); + return hash; + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other == this) { + return true; + } + if(!(other instanceof BlockPos)) { + return false; + } + BlockPos otherPoint = (BlockPos)other; + return this.xPos == otherPoint.xPos && this.yPos == otherPoint.yPos && this.zPos == otherPoint.zPos && this.dim == otherPoint.dim; + } + + public int distanceFrom(BlockPos target) { + if (target.dim != this.dim) { + return Short.MIN_VALUE; + } + return distanceFrom(target.xPos, target.yPos, target.zPos); + } + + /** + * + * @param x X coordinate of target. + * @param y Y coordinate of target. + * @param z Z coordinate of target. + * @return square of distance + */ + public int distanceFrom(int x, int y, int z) { + int distanceX = this.xPos - x; + int distanceY = this.yPos - y; + int distanceZ = this.zPos - z; + return distanceX * distanceX + distanceY * distanceY + distanceZ * distanceZ; + } + + public boolean isWithinRange(BlockPos target, int range) { + if (target.dim != this.dim) { + return false; + } + return isWithinRange(target.xPos, target.yPos, target.zPos, range); + } + + public boolean isWithinRange(int x, int y, int z, int range) { + return distanceFrom(x, y, z) <= (range * range); + } + +} diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/ChunkManager.java b/src/Java/gtPlusPlus/api/objects/minecraft/ChunkManager.java new file mode 100644 index 0000000000..b411e8875a --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/minecraft/ChunkManager.java @@ -0,0 +1,309 @@ +/* + * Copyright (c) CovertJaguar, 2014 http://railcraft.info + * + * This code is the property of CovertJaguar + * and may only be used with explicit written + * permission unless otherwise specified on the + * license page at http://railcraft.info/wiki/info:license. + */ +package gtPlusPlus.api.objects.minecraft; + +import com.google.common.collect.LinkedListMultimap; +import com.google.common.collect.ListMultimap; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Triplet; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaTileEntityChunkLoader; + +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.ConcurrentHashMap; + +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.entity.Entity; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.common.ForgeChunkManager; +import net.minecraftforge.common.ForgeChunkManager.LoadingCallback; +import net.minecraftforge.common.ForgeChunkManager.OrderedLoadingCallback; +import net.minecraftforge.common.ForgeChunkManager.Ticket; +import net.minecraftforge.common.ForgeChunkManager.Type; +import net.minecraftforge.event.entity.EntityEvent; + +/** + * @author CovertJaguar + */ +public class ChunkManager implements LoadingCallback, OrderedLoadingCallback, ForgeChunkManager.PlayerOrderedLoadingCallback { + + private static ChunkManager instance; + + public static ConcurrentHashMap> mChunkLoaderManagerMap = new ConcurrentHashMap>(); + + + public static ChunkManager getInstance() { + if (instance == null) { + instance = new ChunkManager(); + } + return instance; + } + + @SubscribeEvent + public void entityEnteredChunk(EntityEvent.EnteringChunk event) { + + } + + /** + * Returns a Set of ChunkCoordIntPair containing the chunks between the + * start and end chunks. + *

+ * One of the pairs of start/end coords need to be equal. + *

+ * Coordinates are in chunk coordinates, not world coordinates. + * + * @param xChunkA Start Chunk x-Coord + * @param zChunkA Start Chunk z-Coord + * @param xChunkB End Chunk x-Coord + * @param zChunkB End Chunk z-Coord + * @param max Max number of chunks to return + * @return A set of chunks. + */ + public Set getChunksBetween(int xChunkA, int zChunkA, int xChunkB, int zChunkB, int max) { + Set chunkList = new HashSet(); + + if (xChunkA != xChunkB && zChunkA != zChunkB) { + return chunkList; + } + + int xStart = Math.min(xChunkA, xChunkB); + int xEnd = Math.max(xChunkA, xChunkB); + + int zStart = Math.min(zChunkA, zChunkB); + int zEnd = Math.max(zChunkA, zChunkB); + + for (int xx = xStart; xx <= xEnd; xx++) { + for (int zz = zStart; zz <= zEnd; zz++) { + chunkList.add(new ChunkCoordIntPair(xx, zz)); + if (chunkList.size() >= max) { + return chunkList; + } + } + } + return chunkList; + } + + /** + * Returns a Set of ChunkCoordIntPair containing the chunks around point [x, + * z]. Coordinates are in chunk coordinates, not world coordinates. + * + * @param xChunk Chunk x-Coord + * @param zChunk Chunk z-Coord + * @param radius Distance from [x, z] to include, in number of chunks. + * @return A set of chunks. + */ + public Set getChunksAround(int xChunk, int zChunk, int radius) { + Set chunkList = new HashSet(); + for (int xx = xChunk - radius; xx <= xChunk + radius; xx++) { + for (int zz = zChunk - radius; zz <= zChunk + radius; zz++) { + chunkList.add(new ChunkCoordIntPair(xx, zz)); + } + } + return chunkList; + } + + /** + * Returns a Set of ChunkCoordIntPair containing the chunks around point [x, + * z]. Coordinates are in world coordinates, not chunk coordinates. + * + * @param xWorld World x-Coord + * @param zWorld World z-Coord + * @param radius Distance from [x, z] to include, in blocks. + * @return A set of chunks. + */ + public Set getBufferAround(int xWorld, int zWorld, int radius) { + int minX = (xWorld - radius) >> 4; + int maxX = (xWorld + radius) >> 4; + int minZ = (zWorld - radius) >> 4; + int maxZ = (zWorld + radius) >> 4; + + Set chunkList = new HashSet(); + for (int xx = minX; xx <= maxX; xx++) { + for (int zz = minZ; zz <= maxZ; zz++) { + chunkList.add(new ChunkCoordIntPair(xx, zz)); + } + } + return chunkList; + } + + private void printAnchor(String type, int x, int y, int z) { + Logger.INFO("[Chunk Loader] "+type+" @ [x: "+x+"][y: "+y+"][z: "+z+"]"); + } + + @Override + public void ticketsLoaded(List tickets, World world) { + + if (world.isRemote) return; + + // System.out.println("Callback 2"); + for (Ticket ticket : tickets) { + if (ticket.isPlayerTicket()) + continue; + Entity entity = ticket.getEntity(); + if (entity == null) { + int x = ticket.getModData().getInteger("xCoord"); + int y = ticket.getModData().getInteger("yCoord"); + int z = ticket.getModData().getInteger("zCoord"); + + if (y >= 0) { + BlockPos tile = new BlockPos(x, y, z); + + Ticket H = tryForceLoadChunk(new DimChunkPos(world, tile).getChunk()); + + int jhg = 0; + while (jhg < 50) { + jhg++; + } + + if (!mChunkLoaderManagerMap.isEmpty()) { + GregtechMetaTileEntityChunkLoader f = mChunkLoaderManagerMap.get(tile).getValue_2(); + int timeout = 0; + while (f == null) { + if (timeout > 5000) { + Logger.INFO("[Chunk Loader] Timed out"); + break; + } + else { + GregtechMetaTileEntityChunkLoader g; + if (!mChunkLoaderManagerMap.isEmpty()) { + g = mChunkLoaderManagerMap.get(tile).getValue_2(); + if (g == null) { + timeout++; + } + else { + Logger.INFO("[Chunk Loader]Tile became Valid"); + f = g; + break; + } + } + } + } + try { + if (f != null) { + + + if (H != null) { + ForgeChunkManager.releaseTicket(H); + } + + f.forceChunkLoading(ticket); + printAnchor("Force Chunk Loading. Chunk Loader has ID of "+f.getLoaderID()+". ",x,y,z); + } + else { + Logger.INFO("Tile Entity is null."); + } + } + catch (Throwable t) { + t.printStackTrace(); + Logger.INFO("Mild problem with chunk loading, nothing to worry about."); + } + + + if (H != null) { + ForgeChunkManager.releaseTicket(H); + } + + } + + /*if (tile instanceof IGregTechTileEntity) { + final IGregTechTileEntity tGregTechTileEntity = (IGregTechTileEntity) tile; + IGregTechTileEntity anchor = (IGregTechTileEntity) tile; + GregtechMetaTileEntityChunkLoader jun = (GregtechMetaTileEntityChunkLoader) anchor; + jun.forceChunkLoading(ticket); + //printAnchor(anchor.getName(), x, y, z); + }*/ + } + } + } + } + + @Override + public List ticketsLoaded(List tickets, World world, int maxTicketCount) { + // System.out.println("Callback 1"); + Set adminTickets = new HashSet(); + Set worldTickets = new HashSet(); + Set cartTickets = new HashSet(); + for (Ticket ticket : tickets) { + Entity entity = ticket.getEntity(); + if (entity == null) { + int x = ticket.getModData().getInteger("xCoord"); + int y = ticket.getModData().getInteger("yCoord"); + int z = ticket.getModData().getInteger("zCoord"); + if (y >= 0) { + worldTickets.add(ticket); + } + } + } + + List claimedTickets = new LinkedList(); + claimedTickets.addAll(cartTickets); + claimedTickets.addAll(adminTickets); + claimedTickets.addAll(worldTickets); + return claimedTickets; + } + + @Override + public ListMultimap playerTicketsLoaded(ListMultimap tickets, World world) { + return LinkedListMultimap.create(); + } + + + public static Timer createChunkQueue() { + return ChunkTimerLoader(); + } + + public static Ticket tryForceLoadChunk(Chunk c) { + Ticket T = getTicketFromForge(c.worldObj); + ForgeChunkManager.forceChunk(T, c.getChunkCoordIntPair()); + Logger.INFO("[Chunk Loader] Trying to force load a chunk that holds a chunkloader."); + return T; + } + + public static Ticket getTicketFromForge(World world) { + return ForgeChunkManager.requestTicket(GTplusplus.instance, world, Type.NORMAL); + } + + static Timer ChunkTimerLoader() { + Timer timer; + timer = new Timer(); + timer.schedule(new ChunkCache(), 10 * 1000); + return timer; + } + + //Timer Task for notifying the player. + static class ChunkCache extends TimerTask { + public ChunkCache() { + + } + + @Override + public void run() { + if (mChunkLoaderManagerMap.size() > 0) { + for (Triplet j : mChunkLoaderManagerMap.values()) { + Ticket T; + Chunk C; + T = j.getValue_2().getTicketFromForge(); + C = j.getValue_3().getChunk(); + ForgeChunkManager.forceChunk(T, C.getChunkCoordIntPair()); + Logger.INFO("[Chunk Loader] Trying to force load a chunk that holds a chunkloader."); + } + } + else { + Logger.INFO("[Chunk Loader] No chunks to try to force load chunks that hold chunkloaders."); + } + } + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/DimChunkPos.java b/src/Java/gtPlusPlus/api/objects/minecraft/DimChunkPos.java new file mode 100644 index 0000000000..010e522a14 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/minecraft/DimChunkPos.java @@ -0,0 +1,52 @@ +package gtPlusPlus.api.objects.minecraft; + +import net.minecraft.client.Minecraft; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; + +public class DimChunkPos { + + public final int dimension; + public final int xPos; + public final int zPos; + public final Chunk mainChunk; + + + public DimChunkPos(World world, BlockPos block){ + this.dimension = world.provider.dimensionId; + this.mainChunk = world.getChunkFromBlockCoords(block.xPos, block.zPos); + this.xPos = this.mainChunk.xPosition; + this.zPos = this.mainChunk.zPosition; + } + + + public DimChunkPos(TileEntity tile){ + this.dimension = tile.getWorldObj().provider.dimensionId; + this.mainChunk = tile.getWorldObj().getChunkFromBlockCoords(tile.xCoord, tile.zCoord); + this.xPos = this.mainChunk.xPosition; + this.zPos = this.mainChunk.zPosition; + } + + public DimChunkPos(int dim, int x, int z){ + this.dimension = dim; + this.xPos = x; + this.zPos = z; + Chunk h = Minecraft.getMinecraft().getIntegratedServer().worldServerForDimension(dim).getChunkFromChunkCoords(xPos, zPos); + if (h == null) { + this.mainChunk = null; + } + else { + this.mainChunk = h; + } + } + + public Chunk getChunk() { + if (this.mainChunk != null) { + return this.mainChunk; + } + Chunk h = Minecraft.getMinecraft().getIntegratedServer().worldServerForDimension(this.dimension).getChunkFromChunkCoords(xPos, zPos); + return h; + } + +} diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/GenericStack.java b/src/Java/gtPlusPlus/api/objects/minecraft/GenericStack.java new file mode 100644 index 0000000000..f5db1d9e3a --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/minecraft/GenericStack.java @@ -0,0 +1,41 @@ +package gtPlusPlus.api.objects.minecraft; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class GenericStack { + + private ItemStack mItemStack; + private FluidStack mFluidStack; + + public GenericStack(ItemStack s){ + this.mItemStack = s; + this.mFluidStack = null; + } + + public GenericStack(FluidStack f){ + this.mItemStack = null; + this.mFluidStack = f; + } + + public GenericStack() { + this.mItemStack = null; + this.mFluidStack = null; + } + + public synchronized final FluidStack getFluidStack() { + return mFluidStack; + } + + public synchronized final ItemStack getItemStack() { + return mItemStack; + } + + public synchronized final void setItemStack(ItemStack mItemStack) { + this.mItemStack = mItemStack; + } + + public synchronized final void setFluidStack(FluidStack mFluidStack) { + this.mFluidStack = mFluidStack; + } +} diff --git a/src/Java/gtPlusPlus/api/objects/random/CSPRNG_DO_NOT_USE.java b/src/Java/gtPlusPlus/api/objects/random/CSPRNG_DO_NOT_USE.java new file mode 100644 index 0000000000..b2dc984456 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/random/CSPRNG_DO_NOT_USE.java @@ -0,0 +1,271 @@ +/* + * Copyright 2005, Nick Galbreath -- nickg [at] modp [dot] com + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the modp.com nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This is the standard "new" BSD license: + * http://www.opensource.org/licenses/bsd-license.php + */ + +package gtPlusPlus.api.objects.random; +import java.math.BigInteger; +import java.security.SecureRandom; +import java.util.Random; + +import gtPlusPlus.api.interfaces.IRandomGenerator; +import gtPlusPlus.core.util.Utils; + +/** + * The Blum-Blum-Shub random number generator. + * + *

+ * The Blum-Blum-Shub is a "cryptographically secure" random number + * generator. It has been proven that predicting the ouput + * is equivalent to factoring n, a large integer generated + * from two prime numbers. + *

+ * + *

+ * The Algorithm: + *

+ *
    + *
  1. + * (setup) generate two secret prime numbers p, q such that + * pq, p ≡ 3 mod 4, q ≡ 3 mod 4. + *
  2. + *
  3. (setup) compute n = pq. n can be re-used, but + * p, and q are secret and should be disposed of.
  4. + *
  5. Generate a (secure) random seed s in the range [1, n -1] + * such that gcd(s, n) = 1. + *
  6. Compute x = s2 mod n
  7. + *
  8. Compute a single random bit with: + *
      + *
    1. x = x2 mod n
    2. + *
    3. return Least-Significant-Bit(x) (i.e. x & 1)
    4. + *
    + * Repeat as necessary. + *
  9. + *
+ * + *

+ * The code originally appeared in Cryptography for + * Internet and Database Applications , Chapter 4, pages 174-177 + *

+ *

+ * More details are in the Handbook of Applied Cryptography, + * Section 5.5.2 + *

+ * + * @author Nick Galbreath -- nickg [at] modp [dot] com + * @version 3 -- 06-Jul-2005 + * + */ +public class CSPRNG_DO_NOT_USE extends Random implements IRandomGenerator { + + // pre-compute a few values + private static final BigInteger two = BigInteger.valueOf(2L); + + private static final BigInteger three = BigInteger.valueOf(3L); + + private static final BigInteger four = BigInteger.valueOf(4L); + + /** + * main parameter + */ + private BigInteger n; + + private BigInteger state; + + /** + * Generate appropriate prime number for use in Blum-Blum-Shub. + * + * This generates the appropriate primes (p = 3 mod 4) needed to compute the + * "n-value" for Blum-Blum-Shub. + * + * @param bits Number of bits in prime + * @param rand A source of randomness + */ + private static BigInteger getPrime(int bits, Random rand) { + BigInteger p; + while (true) { + p = new BigInteger(bits, 100, rand); + if (p.mod(four).equals(three)) + break; + } + return p; + } + + /** + * This generates the "n value" -- the multiplication of two equally sized + * random prime numbers -- for use in the Blum-Blum-Shub algorithm. + * + * @param bits + * The number of bits of security + * @param rand + * A random instance to aid in generating primes + * @return A BigInteger, the n. + */ + public static BigInteger generateN(int bits, Random rand) { + BigInteger p = getPrime(bits/2, rand); + BigInteger q = getPrime(bits/2, rand); + + // make sure p != q (almost always true, but just in case, check) + while (p.equals(q)) { + q = getPrime(bits, rand); + } + return p.multiply(q); + } + + /** + * Constructor, specifing bits for n + * + * @param bits number of bits + */ + public CSPRNG_DO_NOT_USE(int bits) { + this(bits, new Random()); + } + + /** + * Constructor, generates prime and seed + * + * @param bits + * @param rand + */ + public CSPRNG_DO_NOT_USE(int bits, Random rand) { + this(generateN(bits, rand)); + } + + /** + * A constructor to specify the "n-value" to the Blum-Blum-Shub algorithm. + * The inital seed is computed using Java's internal "true" random number + * generator. + * + * @param n + * The n-value. + */ + public CSPRNG_DO_NOT_USE(BigInteger n) { + this(n, SecureRandom.getSeed(n.bitLength() / 8)); + } + + /** + * A constructor to specify both the n-value and the seed to the + * Blum-Blum-Shub algorithm. + * + * @param n + * The n-value using a BigInteger + * @param seed + * The seed value using a byte[] array. + */ + public CSPRNG_DO_NOT_USE(BigInteger n, byte[] seed) { + this.n = n; + setSeed(seed); + } + + /** + * Sets or resets the seed value and internal state + * + * @param seedBytes + * The new seed. + */ + public void setSeed(byte[] seedBytes) { + // ADD: use hardwired default for n + BigInteger seed = new BigInteger(1, seedBytes); + state = seed.mod(n); + } + + /** + * Returns up to numBit random bits + * + * @return int + */ + @Override + public int next(int numBits) { + // TODO: find out how many LSB one can extract per cycle. + // it is more than one. + int result = 0; + for (int i = numBits; i != 0; --i) { + state = state.modPow(two, n); + result = (result << 1) | (state.testBit(0) == true ? 1 : 0); + } + return result; + } + + + public static CSPRNG_DO_NOT_USE generate(){ + return generate(512); + } + + /** + * @return CSPRNG_DO_NOT_USE + * @Author Draknyte1/Alkalus + */ + public static CSPRNG_DO_NOT_USE generate(int bitsize){ + // First use the internal, stock "true" random number + // generator to get a "true random seed" + SecureRandom r = Utils.generateSecureRandom(); + r.nextInt(); // need to do something for SR to be triggered. + // Use this seed to generate a n-value for Blum-Blum-Shub + // This value can be re-used if desired. + BigInteger nval = CSPRNG_DO_NOT_USE.generateN(bitsize, r); + // now get a seed + byte[] seed = new byte[bitsize/8]; + r.nextBytes(seed); + // now create an instance of BlumBlumShub + CSPRNG_DO_NOT_USE bbs = new CSPRNG_DO_NOT_USE(nval, seed); + return bbs; + } + + + /** + * @return CSPRNG_DO_NOT_USE + * @Author Draknyte1/Alkalus + */ + public static CSPRNG_DO_NOT_USE generate(Random aRandom){ + return generate(512, aRandom); + } + + /** + * @return CSPRNG_DO_NOT_USE + * @Author Draknyte1/Alkalus + */ + public static CSPRNG_DO_NOT_USE generate(int aBitSize, Random aRandom){ + // First use the internal, stock "true" random number + // generator to get a "true random seed" + SecureRandom r = Utils.generateSecureRandom(); + r.nextInt(); // need to do something for SR to be triggered. + // Use this seed to generate a n-value for Blum-Blum-Shub + // This value can be re-used if desired. + int bitsize = aBitSize; + // now create an instance of BlumBlumShub + // do everything almost automatically + CSPRNG_DO_NOT_USE bbs = new CSPRNG_DO_NOT_USE(bitsize, aRandom); + return bbs; + } + +} diff --git a/src/Java/gtPlusPlus/api/objects/random/XSTR.java b/src/Java/gtPlusPlus/api/objects/random/XSTR.java new file mode 100644 index 0000000000..7f83df52c4 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/random/XSTR.java @@ -0,0 +1,266 @@ +package gtPlusPlus.api.objects.random; +/** + * A subclass of java.util.random that implements the Xorshift random number + * generator + * + * - it is 30% faster than the generator from Java's library - it produces + * random sequences of higher quality than java.util.Random - this class also + * provides a clone() function + * + * Usage: XSRandom rand = new XSRandom(); //Instantiation x = rand.nextInt(); + * //pull a random number + * + * To use the class in legacy code, you may also instantiate an XSRandom object + * and assign it to a java.util.Random object: java.util.Random rand = new + * XSRandom(); + * + * for an explanation of the algorithm, see + * http://demesos.blogspot.com/2011/09/pseudo-random-number-generators.html + * + * @author Wilfried Elmenreich University of Klagenfurt/Lakeside Labs + * http://www.elmenreich.tk + * + * This code is released under the GNU Lesser General Public License Version 3 + * http://www.gnu.org/licenses/lgpl-3.0.txt + */ + +import java.util.Random; +import java.util.concurrent.atomic.AtomicLong; + +/** + * XSTR - Xorshift ThermiteRandom + * Modified by Bogdan-G + * 03.06.2016 + * version 0.0.4 + */ +public class XSTR extends Random { + + private static final long serialVersionUID = 6208727693524452904L; + private long seed; + private long last; + private static final long GAMMA = 0x9e3779b97f4a7c15L; + private static final int PROBE_INCREMENT = 0x9e3779b9; + private static final long SEEDER_INCREMENT = 0xbb67ae8584caa73bL; + private static final double DOUBLE_UNIT = 0x1.0p-53; // 1.0 / (1L << 53) + private static final float FLOAT_UNIT = 0x1.0p-24f; // 1.0f / (1 << 24) + + /* + MODIFIED BY: Robotia + Modification: Implemented Random class seed generator + */ + /** + * Creates a new pseudo random number generator. The seed is initialized to + * the current time, as if by + * setSeed(System.currentTimeMillis());. + */ + public XSTR() { + this(seedUniquifier() ^ System.nanoTime()); + } + private static final AtomicLong seedUniquifier + = new AtomicLong(8682522807148012L); + + private static long seedUniquifier() { + // L'Ecuyer, "Tables of Linear Congruential Generators of + // Different Sizes and Good Lattice Structure", 1999 + for (;;) { + final long current = seedUniquifier.get(); + final long next = current * 181783497276652981L; + if (seedUniquifier.compareAndSet(current, next)) { + return next; + } + } + } + + /** + * Creates a new pseudo random number generator, starting with the specified + * seed, using setSeed(seed);. + * + * @param seed the initial seed + */ + public XSTR(final long seed) { + this.seed = seed; + } + @Override + public boolean nextBoolean() { + return this.next(1) != 0; + } + + @Override + public double nextDouble() { + return (((long)(this.next(26)) << 27) + this.next(27)) * DOUBLE_UNIT; + } + /** + * Returns the current state of the seed, can be used to clone the object + * + * @return the current seed + */ + public synchronized long getSeed() { + return this.seed; + } + + /** + * Sets the seed for this pseudo random number generator. As described + * above, two instances of the same random class, starting with the same + * seed, produce the same results, if the same methods are called. + * + * @param seed the new seed + */ + @Override + public synchronized void setSeed(final long seed) { + this.seed = seed; + } + + /** + * @return Returns an XSRandom object with the same state as the original + */ + @Override + public XSTR clone() { + return new XSTR(this.getSeed()); + } + + /** + * Implementation of George Marsaglia's elegant Xorshift random generator + * 30% faster and better quality than the built-in java.util.random see also + * see http://www.javamex.com/tutorials/random_numbers/xorshift.shtml + * + * @param nbits + * @return + */ + @Override + public int next(final int nbits) { + long x = this.seed; + x ^= (x << 21); + x ^= (x >>> 35); + x ^= (x << 4); + this.seed = x; + x &= ((1L << nbits) - 1); + return (int) x; + } + boolean haveNextNextGaussian = false; + double nextNextGaussian = 0; + @Override + synchronized public double nextGaussian() { + // See Knuth, ACP, Section 3.4.1 Algorithm C. + if (this.haveNextNextGaussian) { + this.haveNextNextGaussian = false; + return this.nextNextGaussian; + } + double v1, v2, s; + do { + v1 = (2 * this.nextDouble()) - 1; // between -1 and 1 + v2 = (2 * this.nextDouble()) - 1; // between -1 and 1 + s = (v1 * v1) + (v2 * v2); + } while ((s >= 1) || (s == 0)); + final double multiplier = StrictMath.sqrt((-2 * StrictMath.log(s))/s); + this.nextNextGaussian = v2 * multiplier; + this.haveNextNextGaussian = true; + return v1 * multiplier; + } + /** + * Returns a pseudorandom, uniformly distributed {@code int} value between 0 + * (inclusive) and the specified value (exclusive), drawn from this random + * number generator's sequence. The general contract of {@code nextInt} is + * that one {@code int} value in the specified range is pseudorandomly + * generated and returned. All {@code bound} possible {@code int} values are + * produced with (approximately) equal probability. The method + * {@code nextInt(int bound)} is implemented by class {@code Random} as if + * by: + *
 {@code
+	 * public int nextInt(int bound) {
+	 *   if (bound <= 0)
+	 *     throw new IllegalArgumentException("bound must be positive");
+	 *
+	 *   if ((bound & -bound) == bound)  // i.e., bound is a power of 2
+	 *     return (int)((bound * (long)next(31)) >> 31);
+	 *
+	 *   int bits, val;
+	 *   do {
+	 *       bits = next(31);
+	 *       val = bits % bound;
+	 *   } while (bits - val + (bound-1) < 0);
+	 *   return val;
+	 * }}
+ * + *

The hedge "approx + * imately" is used in the foregoing description only because the next + * method is only approximately an unbiased source of independently chosen + * bits. If it were a perfect source of randomly chosen bits, then the + * algorithm shown would choose {@code int} values from the stated range + * with perfect uniformity. + *

+ * The algorithm is slightly tricky. It rejects values that would result in + * an uneven distribution (due to the fact that 2^31 is not divisible by n). + * The probability of a value being rejected depends on n. The worst case is + * n=2^30+1, for which the probability of a reject is 1/2, and the expected + * number of iterations before the loop terminates is 2. + *

+ * The algorithm treats the case where n is a power of two specially: it + * returns the correct number of high-order bits from the underlying + * pseudo-random number generator. In the absence of special treatment, the + * correct number of low-order bits would be returned. Linear + * congruential pseudo-random number generators such as the one implemented + * by this class are known to have short periods in the sequence of values + * of their low-order bits. Thus, this special case greatly increases the + * length of the sequence of values returned by successive calls to this + * method if n is a small power of two. + * + * @param bound the upper bound (exclusive). Must be positive. + * @return the next pseudorandom, uniformly distributed {@code int} value + * between zero (inclusive) and {@code bound} (exclusive) from this random + * number generator's sequence + * @throws IllegalArgumentException if bound is not positive + * @since 1.2 + */ + @Override + public int nextInt(final int bound) { + //if (bound <= 0) { + //throw new RuntimeException("BadBound"); + //} + + /*int r = next(31); + int m = bound - 1; + if ((bound & m) == 0) // i.e., bound is a power of 2 + { + r = (int) ((bound * (long) r) >> 31); + } else { + for (int u = r; + u - (r = u % bound) + m < 0; + u = next(31)) + ; + } + return r;*/ + //speedup, new nextInt ~+40% + this.last = this.seed ^ (this.seed << 21); + this.last ^= (this.last >>> 35); + this.last ^= (this.last << 4); + this.seed = this.last; + final int out = (int) this.last % bound; + return (out < 0) ? -out : out; + } + @Override + public int nextInt() { + return this.next(32); + } + + @Override + public float nextFloat() { + return this.next(24) * FLOAT_UNIT; + } + + @Override + public long nextLong() { + // it's okay that the bottom word remains signed. + return ((long)(this.next(32)) << 32) + this.next(32); + } + + @Override + public void nextBytes(final byte[] bytes_arr) { + for (int iba = 0, lenba = bytes_arr.length; iba < lenba; ) { + for (int rndba = this.nextInt(), + nba = Math.min(lenba - iba, Integer.SIZE/Byte.SIZE); + nba-- > 0; rndba >>= Byte.SIZE) { + bytes_arr[iba++] = (byte)rndba; + } + } + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java index ea55a9177d..56ba60a5f3 100644 --- a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java +++ b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java @@ -9,12 +9,12 @@ import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.api.objects.data.Triplet; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.itemblock.ItemBlockEntityBase; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.general.TileEntityXpConverter; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.Triplet; import gtPlusPlus.core.util.enchanting.EnchantingUtils; import gtPlusPlus.core.util.player.PlayerUtils; import net.minecraft.block.BlockContainer; diff --git a/src/Java/gtPlusPlus/core/block/general/HellFire.java b/src/Java/gtPlusPlus/core/block/general/HellFire.java index a682a0d98d..ef15f373ae 100644 --- a/src/Java/gtPlusPlus/core/block/general/HellFire.java +++ b/src/Java/gtPlusPlus/core/block/general/HellFire.java @@ -17,7 +17,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import gtPlusPlus.api.objects.XSTR; +import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; diff --git a/src/Java/gtPlusPlus/core/client/renderer/RenderPlasmaBolt.java b/src/Java/gtPlusPlus/core/client/renderer/RenderPlasmaBolt.java index f505824bc9..cb17793c59 100644 --- a/src/Java/gtPlusPlus/core/client/renderer/RenderPlasmaBolt.java +++ b/src/Java/gtPlusPlus/core/client/renderer/RenderPlasmaBolt.java @@ -3,7 +3,7 @@ package gtPlusPlus.core.client.renderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.XSTR; +import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.entity.EntityTeslaTowerLightning; import java.util.Random; diff --git a/src/Java/gtPlusPlus/core/commands/CommandMath.java b/src/Java/gtPlusPlus/core/commands/CommandMath.java index 27c963bf81..8e8dfbc36c 100644 --- a/src/Java/gtPlusPlus/core/commands/CommandMath.java +++ b/src/Java/gtPlusPlus/core/commands/CommandMath.java @@ -4,10 +4,13 @@ import java.util.ArrayList; import java.util.List; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.player.PlayerUtils; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityXPOrb; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChunkCoordinates; @@ -21,61 +24,82 @@ public class CommandMath implements ICommand protected String fullEntityName; protected Entity conjuredEntity; - public CommandMath() - { + public CommandMath(){ this.aliases = new ArrayList<>(); - - this.aliases.add("hometele"); - - this.aliases.add("warphome"); - + //this.aliases.add("hometele"); + //this.aliases.add("warphome"); } @Override - public int compareTo(final Object o) - { + public int compareTo(final Object o){ return 0; } @Override - public String getCommandName() - { - return "bed"; + public String getCommandName(){ + return "alkalus"; } @Override - public String getCommandUsage(final ICommandSender var1) - { - return "/bed [Teleports you to your bed for XP]"; + public String getCommandUsage(final ICommandSender var1){ + return "/alkalus [Dev Command]"; } @Override - public List getCommandAliases() - { + public List getCommandAliases(){ return this.aliases; } @Override - public void processCommand(final ICommandSender S, final String[] argString) - { + public void processCommand(final ICommandSender S, final String[] argString){ final World W = S.getEntityWorld(); - final CommandUtils C = new CommandUtils(); - final EntityPlayer P = C.getPlayer(S); - //System.out.println(P.getCommandSenderName()); - //System.out.println(P.getDisplayName()); - if (W.isRemote) - - { - - System.out.println("Not processing on Client side"); - + final EntityPlayer P = CommandUtils.getPlayer(S); + if (!W.isRemote){ + if (P.getDisplayName().toLowerCase().equals("draknyte1") || P.getCommandSenderName().toLowerCase().equals("draknyte1")) { + String[] prefixes = new String[] { + "ingot", + "plate", + "dust", + "gearGt", + "block", + "ore" + }; + String[] loots = new String[] { + "Iron", + "Iron", + "Iron", + "Copper", + "Copper", + "Copper", + "Tin", + "Mica", + "Steel", + "Steel", + "Steel", + "Invar", + "Titanium", + "Gold", + "Silver", + "Lead", + "Aluminium" + }; + AutoMap itemEntities = new AutoMap(); + for (String g : prefixes) { + for (String s : loots) { + itemEntities.put(new EntityItem(W, P.posX, P.posY, P.posZ, ItemUtils.getItemStackOfAmountFromOreDictNoBroken(g+s, 64))); + }} + for (EntityItem e : itemEntities.values()) { + e.lifespan = 30000; + } + + } } - else + /*else { @@ -167,36 +191,30 @@ public class CommandMath implements ICommand gregtech.api.util.GT_Utility.sendChatToPlayer(P, "You don't feel you're able to do this yet."); } - } + }*/ } @Override - public boolean canCommandSenderUseCommand(final ICommandSender var1) - { - return true; - + public boolean canCommandSenderUseCommand(final ICommandSender var1){ + final EntityPlayer P = CommandUtils.getPlayer(var1); + if (P.getDisplayName().toLowerCase().equals("draknyte1") || P.getCommandSenderName().toLowerCase().equals("draknyte1")) { + return true; + } + return false; } @Override - public List addTabCompletionOptions(final ICommandSender var1, final String[] var2) - { - // TODO Auto-generated method stub - + public List addTabCompletionOptions(final ICommandSender var1, final String[] var2){ return null; - } @Override - public boolean isUsernameIndex(final String[] var1, final int var2) - { + public boolean isUsernameIndex(final String[] var1, final int var2){ // TODO Auto-generated method stub - return false; - } - public boolean playerUsesCommand(final World W, final EntityPlayer P, final int cost) - { + public boolean playerUsesCommand(final World W, final EntityPlayer P, final int cost){ return true; diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java index d5f4d95aef..421a522945 100644 --- a/src/Java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -5,8 +5,8 @@ import static gtPlusPlus.core.lib.CORE.DEBUG; import cpw.mods.fml.common.event.*; import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.GTplusplus; -import gtPlusPlus.api.objects.ChunkManager; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.ChunkManager; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.entity.InternalEntityRegistry; diff --git a/src/Java/gtPlusPlus/core/entity/EntityTeslaTowerLightning.java b/src/Java/gtPlusPlus/core/entity/EntityTeslaTowerLightning.java index 0cd5bd85bf..d1528747a1 100644 --- a/src/Java/gtPlusPlus/core/entity/EntityTeslaTowerLightning.java +++ b/src/Java/gtPlusPlus/core/entity/EntityTeslaTowerLightning.java @@ -5,7 +5,7 @@ import java.util.UUID; import gtPlusPlus.api.damage.DamageTeslaTower; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.XSTR; +import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.util.entity.EntityUtils; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; diff --git a/src/Java/gtPlusPlus/core/entity/projectile/EntityHydrofluoricAcidPotion.java b/src/Java/gtPlusPlus/core/entity/projectile/EntityHydrofluoricAcidPotion.java index c935409650..7517011673 100644 --- a/src/Java/gtPlusPlus/core/entity/projectile/EntityHydrofluoricAcidPotion.java +++ b/src/Java/gtPlusPlus/core/entity/projectile/EntityHydrofluoricAcidPotion.java @@ -1,7 +1,7 @@ package gtPlusPlus.core.entity.projectile; import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.util.array.BlockPos; +import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.util.entity.EntityUtils; import gtPlusPlus.core.util.math.MathUtils; import net.minecraft.block.Block; diff --git a/src/Java/gtPlusPlus/core/entity/projectile/EntitySulfuricAcidPotion.java b/src/Java/gtPlusPlus/core/entity/projectile/EntitySulfuricAcidPotion.java index cd4bec52bf..dfab6fa8ec 100644 --- a/src/Java/gtPlusPlus/core/entity/projectile/EntitySulfuricAcidPotion.java +++ b/src/Java/gtPlusPlus/core/entity/projectile/EntitySulfuricAcidPotion.java @@ -1,7 +1,7 @@ package gtPlusPlus.core.entity.projectile; import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.util.array.BlockPos; +import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.util.entity.EntityUtils; import gtPlusPlus.core.util.math.MathUtils; import net.minecraft.block.Block; diff --git a/src/Java/gtPlusPlus/core/handler/BurnableFuelHandler.java b/src/Java/gtPlusPlus/core/handler/BurnableFuelHandler.java index 79ca0ad174..8bcdaca6a8 100644 --- a/src/Java/gtPlusPlus/core/handler/BurnableFuelHandler.java +++ b/src/Java/gtPlusPlus/core/handler/BurnableFuelHandler.java @@ -1,8 +1,8 @@ package gtPlusPlus.core.handler; import cpw.mods.fml.common.IFuelHandler; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.item.ItemUtils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; diff --git a/src/Java/gtPlusPlus/core/handler/analytics/AnalyticsLoggingPlugin.java b/src/Java/gtPlusPlus/core/handler/analytics/AnalyticsLoggingPlugin.java new file mode 100644 index 0000000000..808c62d7aa --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/analytics/AnalyticsLoggingPlugin.java @@ -0,0 +1,39 @@ +package gtPlusPlus.core.handler.analytics; + +import com.segment.analytics.Analytics; +import com.segment.analytics.Callback; +import com.segment.analytics.Log; +import com.segment.analytics.Plugin; +import com.segment.analytics.messages.Message; + +import gtPlusPlus.api.objects.Logger; + +/** + * A {@link Plugin} implementation that redirects client logs to standard output and logs callback + * events. + */ +public class AnalyticsLoggingPlugin implements Plugin { + @Override public void configure(Analytics.Builder builder) { + builder.log(new Log() { + @Override public void print(Level level, String format, Object... args) { + Logger.WARNING(level + ":\t" + String.format(format, args)); + } + + @Override public void print(Level level, Throwable error, String format, Object... args) { + Logger.WARNING(level + ":\t" + String.format(format, args)); + //Utils.LOG_WARNING(error); + } + }); + + builder.callback(new Callback() { + @Override public void success(Message message) { + Logger.WARNING("Uploaded " + message); + } + + @Override public void failure(Message message, Throwable throwable) { + Logger.WARNING("Could not upload " + message); + //Utils.LOG_WARNING(throwable); + } + }); + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/handler/analytics/BlockingFlush.java b/src/Java/gtPlusPlus/core/handler/analytics/BlockingFlush.java new file mode 100644 index 0000000000..09d1cd5104 --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/analytics/BlockingFlush.java @@ -0,0 +1,67 @@ +package gtPlusPlus.core.handler.analytics; + +import com.segment.analytics.Analytics; +import com.segment.analytics.Callback; +import com.segment.analytics.MessageTransformer; +import com.segment.analytics.Plugin; +import com.segment.analytics.messages.Message; +import com.segment.analytics.messages.MessageBuilder; +import java.util.concurrent.Phaser; + +/** + * The {@link Analytics} class doesn't come with a blocking {@link Analytics#flush()} implementation + * out of the box. It's trivial to build one using a {@link Phaser} that monitors requests and is + * able to block until they're uploaded. + * + *


+ * BlockingFlush mBlockingFlush = BlockingFlush.create();
+ * Analytics mHelper = Analytics.builder(writeKey)
+ *      .plugin(mBlockingFlush)
+ *      .build();
+ *
+ * // Do some work.
+ *
+ * mHelper.flush(); // Trigger a flush.
+ * mBlockingFlush.block(); // Block until the flush completes.
+ * mHelper.shutdown(); // Shut down after the flush is complete.
+ * 
+ */ +public class BlockingFlush { + + public static BlockingFlush create() { + return new BlockingFlush(); + } + + BlockingFlush() { + this.phaser = new Phaser(1); + } + + final Phaser phaser; + + public Plugin plugin() { + return new Plugin() { + @Override public void configure(Analytics.Builder builder) { + builder.messageTransformer(new MessageTransformer() { + @Override public boolean transform(MessageBuilder builder) { + phaser.register(); + return true; + } + }); + + builder.callback(new Callback() { + @Override public void success(Message message) { + phaser.arrive(); + } + + @Override public void failure(Message message, Throwable throwable) { + phaser.arrive(); + } + }); + } + }; + } + + public void block() { + phaser.arriveAndAwaitAdvance(); + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/handler/analytics/SegmentAnalytics.java b/src/Java/gtPlusPlus/core/handler/analytics/SegmentAnalytics.java new file mode 100644 index 0000000000..a217f896cf --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/analytics/SegmentAnalytics.java @@ -0,0 +1,271 @@ +package gtPlusPlus.core.handler.analytics; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Timer; +import java.util.TimerTask; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Phaser; + +import com.mojang.authlib.GameProfile; +import com.segment.analytics.Analytics; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.player.PlayerUtils; +import gtPlusPlus.core.util.uuid.UUIDGenerator; +import gtPlusPlus.core.util.uuid.UUIDUtils; +import ic2.core.IC2; +import net.minecraft.entity.player.EntityPlayer; + +public class SegmentAnalytics { + + //Globally Enabled + public static boolean isEnabled = true; + + //Analytics Map with IDs + public static final Map sAnalyticsMasterList = new ConcurrentHashMap(); + //ID count + private static int sAnalyticsMapID = 0; + + //Analytics Player Mapping + public static final Map sAnalyticsToPlayermap = new ConcurrentHashMap(); + + //Set some Vars + final BlockingFlush mBlockingFlush; + final SegmentHelper mHelper; + final UUIDGenerator mUuidGenerator; + + public final GameProfile mLocalProfile; + public final String mLocalName; + public final UUID mUUID; + public final String mUserName; + public final String mAnonymousId; + protected Map mProperties = new LinkedHashMap<>(); + final protected Phaser mPhaser; + + //Build a new instance of this class + public SegmentAnalytics(EntityPlayer mPlayer){ + LOG("Initializing Segment for "+mPlayer.getDisplayName()); + + //Give this Object an ID + int currentID = sAnalyticsMapID; + sAnalyticsMapID++; + + //Map this Object to it's ID and a Player UUID. + sAnalyticsMasterList.put(currentID, this); + sAnalyticsToPlayermap.put(mPlayer.getUniqueID(), currentID); + + //Create a Phaser + this.mPhaser = new Phaser(1); + + //Set vars for player + this.mLocalProfile = mPlayer.getGameProfile(); + this.mLocalName = mLocalProfile.getName(); + this.mUUID = PlayerUtils.getPlayersUUIDByName(mLocalName); + this.mUserName = mUUID.toString(); + this.mAnonymousId = getStringForm(generateIdForSession()); + + //Create a new UUID generator. + this.mUuidGenerator = new UUIDGenerator(); + + //Use Segment Analytics instead of plain Google Analytics. + this.mBlockingFlush = BlockingFlush.create(); + this.mHelper = SegmentHelper.getInstance(); + initTimer(mPlayer); + } + + //Sets vars and stops Analytics running if the player profile is invalid. + private boolean canProcess(){ + //Invalid Player Profile + if (mLocalProfile == null || !isEnabled){ + return false; + } + if (mLocalName == null || mUUID == null || mUserName == null || mAnonymousId == null){ + //LOG("One player var remained null, returning false."); + return false; + } + if (mLocalName != null && mUUID != null && mUserName != null && mAnonymousId != null){ + //LOG("All player vars are ok, returning true."); + return true; + } + LOG("Something went wrong, returning false."); + return false; + } + + + public void submitInitData(EntityPlayer mPlayer){ + if (!canProcess()){ + return; + } + mProperties = new LinkedHashMap<>(); + mProperties.put("username", mLocalName); + mProperties.put("gt_version", Utils.getGregtechVersionAsString()); + if (LoadedMods.IndustrialCraft2){ + mProperties.put("ic2_version", IC2.VERSION); + } + mProperties.put("country_code", CORE.USER_COUNTRY); + mProperties.put("gtnh", CORE.GTNH); + + LOG("Created new Data packet, queued for submission."); + + //Old Code, now passed to Helper Class + /*mHelper.enqueue(IdentifyMessage.builder() + .userId(mUserName) //Save Username as UUID, for future sessions to attach to. + .traits(mProperties) + //.anonymousId(mAnonymousId) //Save Random Session UUID + );*/ + + mHelper.addUser(this.mUserName, mProperties); + + if (CORE.GTNH){ + mHelper.groupUser("GT:NewHorizons", this.mUserName); + } + else { + mHelper.groupUser("GT:Vanilla", this.mUserName); + } + + } + + public void submitTrackingData(String aActionPerformed){ + submitTrackingData(aActionPerformed, null); + } + + public void submitTrackingData(String aActionPerformed, Object aObject){ + if (!canProcess()){ + return; + } + + Map properties = new LinkedHashMap<>(); + properties.put("blockType", aObject); + String mObjectAsString = "Unknown"; + + if (aObject != null){ + mObjectAsString = aObject.toString(); + } + + LOG("Queued submission of data for event "+aActionPerformed+". This was performed on "+mObjectAsString+"."); + + mHelper.trackUser(this.mUserName, aActionPerformed, properties); + + //Old Code, now passed to Helper Class + /*mHelper.enqueue(TrackMessage.builder(aActionPerformed) // + .userId(mUserName) // Save Username as UUID, for future sessions to attach to. + .properties(mProperties) //Save Stats + //.anonymousId(mAnonymousId) //Save Random Session UUID + ); + flushData(); + */ + } + + public void flushData(){ + getAnalyticObject().flush(); + } + + public void flushDataFinal(){ + LOG("Flushing all data from Queue to Segment Analytics database."); + getAnalyticObject().flush(); + mBlockingFlush.block(); + mPhaser.arriveAndAwaitAdvance(); + getAnalyticObject().shutdown(); + /*try { + this.finalize(); + } + catch (Throwable e) { + Utils.LOG_INFO("Could not finalize Analytics Object."); + }*/ + } + + public UUID generateIdForSession(){ + return UUIDUtils.getUUIDFromBytes(generateUUID()); + } + + private final byte[] generateUUID(){ + byte[] mUUID; + + if (this.mUuidGenerator != null){ + try { + if ((mUUID = mUuidGenerator.next(4)) != null){ + LOG("Generated Type 4 UUID for Session ID."); + return mUUID; + } + else if ((mUUID = mUuidGenerator.next(1)) != null){ + LOG("Generated Type 1 UUID for Session ID."); + return mUUID; + } + } + catch (Throwable t){ + t.printStackTrace(); + } + } + + LOG("Generated Type 3 UUID for Session ID."); + return UUIDUtils.getBytesFromUUID(UUID.randomUUID()); + + } + + public final String getStringForm(UUID mID){ + return mID.toString(); + } + + // Non-Dev Comments + public static void LOG(final String s) { + if (CORE.DEBUG){ + Logger.getLogger().info("[Analytics] "+s); + } + } + + public static SegmentAnalytics getAnalyticsForPlayer(EntityPlayer mPlayer){ + try { + if (mPlayer != null){ + if (SegmentAnalytics.sAnalyticsToPlayermap.containsKey(mPlayer.getUniqueID())){ + int ID = sAnalyticsToPlayermap.get(mPlayer.getUniqueID()); + return SegmentAnalytics.sAnalyticsMasterList.get(ID); + } + else { + LOG("Map does not contain Player."); + } + } + else { + LOG("Invalid Player."); + } + } + catch (Throwable t){ + t.printStackTrace(); + } + return null; + } + + public final Analytics getAnalyticObject() { + return mHelper.getAnalyticsClient(); + } + + public final Map getPlayerProperties(){ + return this.mProperties; + } + + + public Timer initTimer(EntityPlayer mPlayer) { + Timer timer; + timer = new Timer(); + timer.schedule(new initPlayer(mPlayer), 2 * 1000); + return timer; + } + + //Timer Task for notifying the player. + class initPlayer extends TimerTask { + final EntityPlayer aPlayer; + public initPlayer(EntityPlayer mPlayer) { + this.aPlayer = mPlayer; + } + @Override + public void run() { + //Let us submit a doorknock to Segment to let them know who this is. + submitInitData(aPlayer); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/handler/analytics/SegmentHelper.java b/src/Java/gtPlusPlus/core/handler/analytics/SegmentHelper.java new file mode 100644 index 0000000000..79b95eda24 --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/analytics/SegmentHelper.java @@ -0,0 +1,81 @@ +package gtPlusPlus.core.handler.analytics; + +import com.segment.analytics.Analytics; +import com.segment.analytics.Callback; +import com.segment.analytics.messages.Message; +import com.segment.analytics.messages.TrackMessage; +import com.segment.analytics.messages.*; +import java.util.Map; + +public class SegmentHelper implements Callback { + + /** + * Credits to Author: FLAMINSAGANAKI/Theodore Mavrakis + * http://domisydev.com/2015/11/05/using-segment-analytics-in-your-java-servlet/ + */ + + private static final String writeKey = "EDOWl9peleGlUqe1ZwTqKDyuTMFhyT4k"; + private static volatile SegmentHelper segment = new SegmentHelper(); + private Analytics analytics; + + public SegmentHelper(){ + try{ + this.analytics = Analytics.builder(writeKey).callback(this).build(); + }catch(Exception e){ + SegmentAnalytics.LOG("exception while creating Analytics : " + e); + } + } + + public static SegmentHelper getInstance(){ + return segment; + } + + public Analytics getAnalyticsClient(){ + return segment.analytics; + } + + public void success(Message message) { + SegmentAnalytics.LOG("Successfully uploaded " + message); + } + + public void failure(Message message, Throwable throwable) { + SegmentAnalytics.LOG("Could not upload " + message); + } + + public void addUser(String user_id, Map properties) { + try { + this.analytics.enqueue(IdentifyMessage.builder().userId(user_id).traits(properties)); + //trackUser(user_id, "Logged In", properties); + } catch (Exception e) { + SegmentAnalytics.LOG("Exception in addUser() - " + e); + } + } + + public void trackUser(String user_id, String description, Map properties) { + try { + this.analytics.enqueue(TrackMessage.builder(description).userId(user_id).properties(properties)); + } catch (Exception e) { + SegmentAnalytics.LOG("Exception in trackUser() - " + e); + } + } + + public void trackUser(String user_id, String description) { + try { + this.analytics.enqueue(TrackMessage.builder(description).userId(user_id)); + } catch (Exception e) { + SegmentAnalytics.LOG("Exception in trackUser() - " + e); + } + } + + public void groupUser(String group_id, String user_id) { + try { + this.analytics.enqueue(GroupMessage.builder(group_id).userId(user_id)); + } catch (Exception e) { + SegmentAnalytics.LOG("Exception in groupUser() - " + e); + } + } + + public static void main(String[] args){ + + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java index cd79cf7fe6..0c6e798edd 100644 --- a/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java @@ -9,9 +9,9 @@ import java.util.Map; import java.util.Random; import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import gtPlusPlus.api.analytics.SegmentAnalytics; -import gtPlusPlus.api.analytics.SegmentHelper; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.handler.analytics.SegmentAnalytics; +import gtPlusPlus.core.handler.analytics.SegmentHelper; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; diff --git a/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java index 09365e3caf..c8c6a23bca 100644 --- a/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java @@ -4,9 +4,9 @@ import java.util.*; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent; -import gtPlusPlus.api.analytics.SegmentAnalytics; -import gtPlusPlus.api.analytics.SegmentHelper; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.handler.analytics.SegmentAnalytics; +import gtPlusPlus.core.handler.analytics.SegmentHelper; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.proxy.ClientProxy; diff --git a/src/Java/gtPlusPlus/core/handler/events/ZombieBackupSpawnEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/ZombieBackupSpawnEventHandler.java index 877b0c6ced..572f52124f 100644 --- a/src/Java/gtPlusPlus/core/handler/events/ZombieBackupSpawnEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/ZombieBackupSpawnEventHandler.java @@ -7,8 +7,8 @@ import org.apache.commons.lang3.reflect.FieldUtils; import cpw.mods.fml.common.eventhandler.Event.Result; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import gtPlusPlus.api.analytics.SegmentHelper; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.handler.analytics.SegmentHelper; import net.minecraftforge.event.entity.living.ZombieEvent; public class ZombieBackupSpawnEventHandler { diff --git a/src/Java/gtPlusPlus/core/item/base/BaseEuItem.java b/src/Java/gtPlusPlus/core/item/base/BaseEuItem.java index 8f8d0eed72..a32ff20353 100644 --- a/src/Java/gtPlusPlus/core/item/base/BaseEuItem.java +++ b/src/Java/gtPlusPlus/core/item/base/BaseEuItem.java @@ -16,9 +16,9 @@ import gregtech.api.interfaces.IItemBehaviour; import gregtech.api.interfaces.IItemContainer; import gregtech.api.objects.ItemData; import gregtech.api.util.*; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.array.Pair; import ic2.api.item.*; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemBurnable.java b/src/Java/gtPlusPlus/core/item/base/BaseItemBurnable.java index 42aadfa91d..76d66069f5 100644 --- a/src/Java/gtPlusPlus/core/item/base/BaseItemBurnable.java +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemBurnable.java @@ -1,7 +1,7 @@ package gtPlusPlus.core.item.base; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.item.ItemUtils; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; diff --git a/src/Java/gtPlusPlus/core/item/general/ItemAreaClear.java b/src/Java/gtPlusPlus/core/item/general/ItemAreaClear.java index fc92d5d82c..a3f7b78888 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemAreaClear.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemAreaClear.java @@ -3,11 +3,11 @@ package gtPlusPlus.core.item.general; import java.util.List; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.block.base.BlockBaseOre; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.CoreItem; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.array.BlockPos; import gtPlusPlus.core.util.entity.EntityUtils; import gtPlusPlus.core.util.math.MathUtils; import net.minecraft.client.renderer.texture.IIconRegister; diff --git a/src/Java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java b/src/Java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java index 1b8ab947e5..64f1c4e139 100644 --- a/src/Java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java +++ b/src/Java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java @@ -6,10 +6,10 @@ import java.util.UUID; import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.api.interfaces.IEntityCatcher; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.BlockPos; import gtPlusPlus.core.util.nbt.NBTUtils; import gtPlusPlus.core.util.player.PlayerUtils; import net.minecraft.entity.*; diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java index 45e0bd8fe6..66b4d87511 100644 --- a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java @@ -6,10 +6,10 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.recipe.RecipeUtils; diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index 4cff84d646..ce2f4f4432 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -6,10 +6,10 @@ import java.util.concurrent.ConcurrentHashMap; import com.mojang.authlib.GameProfile; import gregtech.api.GregTech_API; -import gtPlusPlus.api.objects.CSPRNG_DO_NOT_USE; -import gtPlusPlus.api.objects.XSTR; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.api.objects.random.CSPRNG_DO_NOT_USE; +import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.geo.GeoUtils; import gtPlusPlus.core.util.gregtech.recipehandlers.GregtechRecipe; import gtPlusPlus.core.util.networking.NetworkUtils; diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java index eca3c595ec..22c65c5a2b 100644 --- a/src/Java/gtPlusPlus/core/material/Material.java +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -7,13 +7,13 @@ import java.util.Map.Entry; import gregtech.api.enums.*; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.item.base.cell.BaseItemCell; import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.StringUtils; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.array.ArrayUtils; -import gtPlusPlus.core.util.array.AutoMap; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.materials.MaterialUtils; diff --git a/src/Java/gtPlusPlus/core/slots/SlotModularBaubleUpgrades.java b/src/Java/gtPlusPlus/core/slots/SlotModularBaubleUpgrades.java index 85de0df60e..b6930dfe27 100644 --- a/src/Java/gtPlusPlus/core/slots/SlotModularBaubleUpgrades.java +++ b/src/Java/gtPlusPlus/core/slots/SlotModularBaubleUpgrades.java @@ -7,7 +7,7 @@ import java.util.Iterator; import java.util.Map.Entry; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.array.Pair; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.util.nbt.ModularArmourUtils.BT; import gtPlusPlus.core.util.nbt.ModularArmourUtils.Modifiers; import net.minecraft.inventory.IInventory; diff --git a/src/Java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java b/src/Java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java index 72153964e9..8b789f922f 100644 --- a/src/Java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java +++ b/src/Java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java @@ -10,9 +10,9 @@ import gregtech.api.net.GT_Packet_TileEntity; import gregtech.api.net.IGT_NetworkHandler; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.interfaces.IGregtechPower; +import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.AutoMap; import ic2.api.info.Info; import net.minecraft.block.Block; import net.minecraft.block.BlockFire; diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java index 252b92984e..abff5fd755 100644 --- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java @@ -5,12 +5,12 @@ import java.util.Map.Entry; import gregtech.api.enums.ItemList; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.container.Container_ModularityTable; import gtPlusPlus.core.inventories.modulartable.InventoryModularMain; import gtPlusPlus.core.inventories.modulartable.InventoryModularOutput; import gtPlusPlus.core.item.bauble.ModularBauble; import gtPlusPlus.core.tileentities.base.TileEntityBase; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.nbt.ModularArmourUtils; import gtPlusPlus.core.util.nbt.ModularArmourUtils.BT; diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index 0909e4bf2d..e15f8ba202 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -34,10 +34,10 @@ import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; import gtPlusPlus.GTplusplus; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.math.MathUtils; diff --git a/src/Java/gtPlusPlus/core/util/array/AutoMap.java b/src/Java/gtPlusPlus/core/util/array/AutoMap.java deleted file mode 100644 index ea5e1dd25e..0000000000 --- a/src/Java/gtPlusPlus/core/util/array/AutoMap.java +++ /dev/null @@ -1,77 +0,0 @@ -package gtPlusPlus.core.util.array; - -import java.io.Serializable; -import java.util.*; - -public class AutoMap implements Iterable, Cloneable, Serializable { - - /** - * The Internal Map - */ - private Map mInternalMap = new HashMap(); - - /** - * The Internal ID - */ - private int mInternalID = 0; - private static final long serialVersionUID = 3771412318075131790L; - - @Override - public Iterator iterator() { - return values().iterator(); - } - - public synchronized boolean setValue(V object){ - int mOriginalID = this.mInternalID; - put(object); - if (this.mInternalMap.get(mOriginalID).equals(object) || mOriginalID > this.mInternalID){ - return true; - } - else { - return false; - } - } - - public synchronized V put(V object){ - return set(object); - } - - public synchronized V set(V object){ - return mInternalMap.put(mInternalID++, object); - } - - public synchronized V get(int id){ - return mInternalMap.get(id); - } - - public synchronized Collection values(){ - return mInternalMap.values(); - } - - public synchronized int size(){ - return mInternalMap.size(); - } - - public synchronized int hashcode(){ - return mInternalMap.hashCode(); - } - - public synchronized boolean containsKey(int key){ - return mInternalMap.containsKey(key); - } - - public synchronized boolean containsValue(V value){ - return mInternalMap.containsValue(value); - } - - public synchronized boolean isEmpty(){ - return mInternalMap.isEmpty(); - } - - public synchronized boolean clear(){ - this.mInternalID = 0; - this.mInternalMap.clear(); - return true; - } - -} diff --git a/src/Java/gtPlusPlus/core/util/array/BlockPos.java b/src/Java/gtPlusPlus/core/util/array/BlockPos.java deleted file mode 100644 index fbf7676627..0000000000 --- a/src/Java/gtPlusPlus/core/util/array/BlockPos.java +++ /dev/null @@ -1,28 +0,0 @@ -package gtPlusPlus.core.util.array; - -import java.io.Serializable; - -public class BlockPos implements Serializable{ - - private static final long serialVersionUID = -7271947491316682006L; - public final int xPos; - public final int yPos; - public final int zPos; - public final int dim; - - public BlockPos(int x, int y, int z){ - this(x, y, z, 0); - } - - public BlockPos(int x, int y, int z, int dim){ - this.xPos = x; - this.yPos = y; - this.zPos = z; - this.dim = dim; - } - - public String getLocationString() { - return "[X: "+this.xPos+"][Y: "+this.yPos+"][Z: "+this.zPos+"]"; - } - -} diff --git a/src/Java/gtPlusPlus/core/util/array/Pair.java b/src/Java/gtPlusPlus/core/util/array/Pair.java deleted file mode 100644 index 1d2c0ef7cb..0000000000 --- a/src/Java/gtPlusPlus/core/util/array/Pair.java +++ /dev/null @@ -1,27 +0,0 @@ -package gtPlusPlus.core.util.array; - -import java.io.Serializable; - -public class Pair implements Serializable { - - /** - * SVUID - */ - private static final long serialVersionUID = 1250550491092812443L; - private final K key; - private final V value; - - public Pair(final K key, final V value){ - this.key = key; - this.value = value; - } - - final public K getKey(){ - return this.key; - } - - final public V getValue(){ - return this.value; - } - -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/util/array/Quad.java b/src/Java/gtPlusPlus/core/util/array/Quad.java deleted file mode 100644 index 417c3b6ebc..0000000000 --- a/src/Java/gtPlusPlus/core/util/array/Quad.java +++ /dev/null @@ -1,33 +0,0 @@ -package gtPlusPlus.core.util.array; - -public class Quad { - - private final K key; - private final V value; - private final C value2; - private final R value3; - - public Quad(final K key, final V value, final C value2, final R value3){ - this.key = key; - this.value = value; - this.value2 = value2; - this.value3 = value3; - } - - final public K getKey(){ - return this.key; - } - - final public V getValue_1(){ - return this.value; - } - - final public C getValue_2(){ - return this.value2; - } - - final public R getValue_3(){ - return this.value3; - } - -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/util/array/Triplet.java b/src/Java/gtPlusPlus/core/util/array/Triplet.java deleted file mode 100644 index 01f836ae72..0000000000 --- a/src/Java/gtPlusPlus/core/util/array/Triplet.java +++ /dev/null @@ -1,27 +0,0 @@ -package gtPlusPlus.core.util.array; - -public class Triplet { - - private final K key; - private final V value; - private final C count; - - public Triplet(final K key, final V value, final C value2){ - this.key = key; - this.value = value; - this.count = value2; - } - - final public K getValue_1(){ - return this.key; - } - - final public V getValue_2(){ - return this.value; - } - - final public C getValue_3(){ - return this.count; - } - -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/util/entity/EntityUtils.java b/src/Java/gtPlusPlus/core/util/entity/EntityUtils.java index 79c643a95d..27412d647f 100644 --- a/src/Java/gtPlusPlus/core/util/entity/EntityUtils.java +++ b/src/Java/gtPlusPlus/core/util/entity/EntityUtils.java @@ -5,7 +5,7 @@ import java.lang.reflect.Method; import cpw.mods.fml.common.registry.EntityRegistry; import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.util.array.BlockPos; +import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.util.reflect.ReflectionUtils; import ic2.core.IC2Potion; import ic2.core.item.armor.ItemArmorHazmat; diff --git a/src/Java/gtPlusPlus/core/util/item/ItemUtils.java b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java index 367539b49d..d5caad9dee 100644 --- a/src/Java/gtPlusPlus/core/util/item/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java @@ -10,6 +10,7 @@ import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.item.base.BasicSpawnEgg; import gtPlusPlus.core.item.base.dusts.BaseItemDust; @@ -23,7 +24,6 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.materials.MaterialUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.core.util.wrapper.var; diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java index 313d1059ca..6d61335fe8 100644 --- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java @@ -4,8 +4,8 @@ import java.util.Map; import java.util.Random; import gregtech.api.enums.GT_Values; -import gtPlusPlus.api.objects.CSPRNG_DO_NOT_USE; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.random.CSPRNG_DO_NOT_USE; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; diff --git a/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java b/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java index 2e8e29c372..c9ac557fee 100644 --- a/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java +++ b/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java @@ -3,7 +3,7 @@ package gtPlusPlus.core.util.nbt; import baubles.api.BaubleType; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.array.Pair; +import gtPlusPlus.api.objects.data.Pair; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; diff --git a/src/Java/gtPlusPlus/core/util/uuid/UUIDGenerator.java b/src/Java/gtPlusPlus/core/util/uuid/UUIDGenerator.java index 0fd2d8c6a5..bf0ac3d1f5 100644 --- a/src/Java/gtPlusPlus/core/util/uuid/UUIDGenerator.java +++ b/src/Java/gtPlusPlus/core/util/uuid/UUIDGenerator.java @@ -5,7 +5,7 @@ import java.net.InetAddress; import java.util.Random; import java.util.UUID; -import gtPlusPlus.api.objects.CSPRNG_DO_NOT_USE; +import gtPlusPlus.api.objects.random.CSPRNG_DO_NOT_USE; /** * diff --git a/src/Java/gtPlusPlus/core/world/damage/BaseCustomDamageSource.java b/src/Java/gtPlusPlus/core/world/damage/BaseCustomDamageSource.java new file mode 100644 index 0000000000..3778beacfb --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/damage/BaseCustomDamageSource.java @@ -0,0 +1,22 @@ +package gtPlusPlus.core.world.damage; + +import net.minecraft.entity.Entity; +import net.minecraft.util.EntityDamageSourceIndirect; + +public class BaseCustomDamageSource extends EntityDamageSourceIndirect { + + public BaseCustomDamageSource(String name, Entity transmitter, Entity indirectSource) { + super(name, transmitter, indirectSource); + this.setDifficultyScaled(); + } + + /** + * Return whether this damage source will have its damage amount scaled based on the current difficulty. + */ + public boolean isDifficultyScaled() + { + return true; + } + + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_GT_Base.java b/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_GT_Base.java index 6be899e5de..301a2154c2 100644 --- a/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_GT_Base.java +++ b/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_GT_Base.java @@ -6,7 +6,7 @@ import cpw.mods.fml.common.IWorldGenerator; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.util.GT_Log; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.XSTR; +import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.world.darkworld.Dimension_DarkWorld; import gtPlusPlus.xmod.gregtech.HANDLER_GT; diff --git a/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_Ores.java b/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_Ores.java index 4b099ee4cf..8b28e2d4e8 100644 --- a/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_Ores.java +++ b/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_Ores.java @@ -4,12 +4,12 @@ import java.util.Hashtable; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; -import gtPlusPlus.api.objects.MaterialHelper; +import gtPlusPlus.api.helpers.MaterialHelper; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.ORES; import gtPlusPlus.core.material.nuclear.FLUORIDES; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.materials.MaterialUtils; import gtPlusPlus.core.world.darkworld.object.BoxedQuad; import net.minecraft.block.Block; diff --git a/src/Java/gtPlusPlus/core/world/darkworld/object/BoxedQuad.java b/src/Java/gtPlusPlus/core/world/darkworld/object/BoxedQuad.java index d3c400896b..fd3d734e08 100644 --- a/src/Java/gtPlusPlus/core/world/darkworld/object/BoxedQuad.java +++ b/src/Java/gtPlusPlus/core/world/darkworld/object/BoxedQuad.java @@ -1,6 +1,6 @@ package gtPlusPlus.core.world.darkworld.object; -import gtPlusPlus.core.util.array.Pair; +import gtPlusPlus.api.objects.data.Pair; import net.minecraft.block.Block; public class BoxedQuad { diff --git a/src/Java/gtPlusPlus/core/world/explosions/MiningExplosion.java b/src/Java/gtPlusPlus/core/world/explosions/MiningExplosion.java index 50fa08f55f..bcbb16a3b6 100644 --- a/src/Java/gtPlusPlus/core/world/explosions/MiningExplosion.java +++ b/src/Java/gtPlusPlus/core/world/explosions/MiningExplosion.java @@ -2,7 +2,7 @@ package gtPlusPlus.core.world.explosions; import java.util.*; -import gtPlusPlus.api.objects.XSTR; +import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.entity.EntityPrimedMiningExplosive; import gtPlusPlus.core.util.math.MathUtils; import net.minecraft.block.Block; diff --git a/src/Java/gtPlusPlus/plugin/manager/Core_Manager.java b/src/Java/gtPlusPlus/plugin/manager/Core_Manager.java index 2fc6102779..2fd6096d32 100644 --- a/src/Java/gtPlusPlus/plugin/manager/Core_Manager.java +++ b/src/Java/gtPlusPlus/plugin/manager/Core_Manager.java @@ -2,7 +2,7 @@ package gtPlusPlus.plugin.manager; import gtPlusPlus.api.interfaces.IPlugin; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.array.AutoMap; +import gtPlusPlus.api.objects.data.AutoMap; public class Core_Manager { diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java index c6edd94238..4a8a0a1e3c 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java @@ -19,8 +19,8 @@ import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.common.blocks.GT_Block_Machines; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.XSTR; -import gtPlusPlus.core.util.array.BlockPos; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.nbt.NBTUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java index df886220c2..14586a91f8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java @@ -15,7 +15,7 @@ import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.XSTR; +import gtPlusPlus.api.objects.random.XSTR; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java index 210603ec0d..7aaabe6ef1 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java @@ -8,9 +8,9 @@ import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_ModHandler; import gregtech.common.items.*; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.BlockPos; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.nbt.NBTUtils; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaWirelessCharger; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java index 8070c16f4d..7b1da9738b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java @@ -3,6 +3,7 @@ package gtPlusPlus.xmod.gregtech.common.helpers; import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableTreeFarmerParticles; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -29,13 +30,13 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.common.items.GT_MetaGenerated_Item_02; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.players.FakeFarmer; import gtPlusPlus.core.slots.SlotBuzzSaw.SAWTOOL; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.AutoMap; -import gtPlusPlus.core.util.array.BlockPos; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.math.MathUtils; @@ -372,7 +373,7 @@ public class TreeFarmHelper { if (log.getLocalizedName().toLowerCase().contains("leaves")){ return true; } - return OrePrefixes.leaves.contains(new ItemStack(log, 1)) || (log.getMaterial() == Material.leaves); + return OrePrefixes.leaves.contains(new ItemStack(log, 1)) || log.getMaterial() == Material.leaves || OrePrefixes.treeLeaves.contains(new ItemStack(log, 1)) || log.getMaterial() == Material.vine || OrePrefixes.mushroom.contains(new ItemStack(log, 1)) || log.getMaterial() == Material.cactus; } public static boolean isSapling(final Block log){ @@ -397,17 +398,12 @@ public class TreeFarmHelper { } public static boolean isAirBlock(final Block air){ - if (air.getLocalizedName().toLowerCase().contains("air")){ return true; } - if (air.getClass().getName().toLowerCase().contains("residual") || air.getClass().getName().toLowerCase().contains("heat")){ return true; } - - //Utils.LOG_INFO("Found "+air.getLocalizedName()); - return (air == Blocks.air ? true : (air instanceof BlockAir ? true : false)); } @@ -423,9 +419,9 @@ public class TreeFarmHelper { for (int h = 0; h <= 1; h++) { //Farm Floor inner 14x14 if (((i != -7) && (i != 7)) && ((j != -7) && (j != 7))) { - if (h == 1) { - if (!isFenceBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j)) && TreeFarmHelper.isWoodLog(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) { - //Logger.INFO("Found a Log"); + if (h == 1) { + if (TreeFarmHelper.isWoodLog(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) { + Logger.INFO("Found a Log"); return new BlockPos(aBaseMetaTileEntity.getXCoord()+xDir + i, aBaseMetaTileEntity.getYCoord()+h, aBaseMetaTileEntity.getZCoord()+zDir + j); } } @@ -436,142 +432,68 @@ public class TreeFarmHelper { return null; } - - public static ItemStack[] findTreeFromBase(World world, BlockPos h) { - + int HARD_LIMIT = 10000; + int mCount = 0; + Logger.INFO("Finding Rest of Tree."); BlockPos mFirstSpot = h; - Set mFirstSearch = new HashSet(); - Set mSecondSearch = new HashSet(); - Set mThirdSearch = new HashSet(); - Set mAllSearched = new HashSet(); - - Set mTempSearch = new HashSet(); - - mAllSearched.add(mFirstSpot); - - mFirstSearch = findTreeViaBranching(world, h); - - if (mFirstSearch.size() > 0) { - Iterator j = mFirstSearch.iterator(); - while (j.hasNext()){ - BlockPos M = j.next(); - if (!mAllSearched.contains(M)) { - mAllSearched.add(M); - mTempSearch = findTreeViaBranching(world, M); - if (mTempSearch.size() > 0) { - Iterator D = mTempSearch.iterator(); - while (D.hasNext()){ - BlockPos F = D.next(); - onBlockStartBreak(F.xPos, F.yPos, F.zPos, world); - } - } - } - } - } - - - /*if (mFirstSearch.size() > 0) { - Iterator j = mFirstSearch.iterator(); - while (j.hasNext()){ - BlockPos M = j.next(); - if (!mAllSearched.contains(M)) - mAllSearched.add(M); - if (!mSecondSearch.contains(M)) - mSecondSearch.add(M); - } - }*/ - /*if (mSecondSearch.size() > 0) { - Iterator j = mSecondSearch.iterator(); - while (j.hasNext()){ - BlockPos M = j.next(); - if (!mAllSearched.contains(M)) - mAllSearched.add(M); - if (!mThirdSearch.contains(M)) - mThirdSearch.add(M); - } - }*/ - - /*if (mSecondSearch.size() > 0) { - Iterator j = mSecondSearch.iterator(); - while (j.hasNext()){ - BlockPos M = j.next(); - if (!mAllSearched.contains(M)) { - mAllSearched.add(M); - mTempSearch = findTreeViaBranching(world, M); - if (mTempSearch.size() > 0) { - Iterator D = mTempSearch.iterator(); - while (D.hasNext()){ - BlockPos F = D.next(); - if (!mAllSearched.contains(F)) - mAllSearched.add(F); - } - } - if (!mThirdSearch.contains(M)) { - mThirdSearch.add(M); - } - } + Set mSearchedSpaces = new HashSet(); + Set mTreeSet = getConnectedBlocks(world, mFirstSpot, mSearchedSpaces); + Set> mTreeSet2 = new HashSet>(); + Set mFinalTree = new HashSet(); + Iterator it = mTreeSet.iterator(); + + + Logger.INFO("Running first iteration."); + while(it.hasNext()){ + BlockPos G = it.next(); + mSearchedSpaces.add(G); + mTreeSet2.add(getConnectedBlocks(world, G, mSearchedSpaces)); + mCount++; + Logger.INFO("First Search: "+G.getLocationString()); + if (mCount > HARD_LIMIT) { + break; } } - - if (mThirdSearch.size() > 0) { - Iterator j = mThirdSearch.iterator(); - while (j.hasNext()){ - BlockPos M = j.next(); - if (!mAllSearched.contains(M)) { - mAllSearched.add(M); - mTempSearch = findTreeViaBranching(world, M); - if (mTempSearch.size() > 0) { - Iterator D = mTempSearch.iterator(); - while (D.hasNext()){ - BlockPos F = D.next(); - if (!mAllSearched.contains(F)) - mAllSearched.add(F); - } - } - } - } - }*/ - - - /*Set mBaseLayer = new HashSet(); - Set> mAllLayers = new HashSet>(); - Set mFinalSet = new HashSet(); - - mBaseLayer = findTreeViaBranching(world, h); - mAllLayers.add(mBaseLayer); - Logger.INFO("Initial Search found "+mBaseLayer.size()+" blocks to search around."); - for (Iterator flavoursIter = mBaseLayer.iterator(); flavoursIter.hasNext();){ - Set x = findTreeViaBranching(world, flavoursIter.next()); - if (!mAllLayers.contains(x)) { - Logger.INFO("Branching."); - mAllLayers.add(x); - } - }*/ - - - /*if (mAllLayers.size() > 0) { - for (Iterator> flavoursIter = mAllLayers.iterator(); flavoursIter.hasNext();){ - for (Iterator flavoursIter2 = flavoursIter.next().iterator(); flavoursIter2.hasNext();){ - Set x = findTreeViaBranching(world, flavoursIter2.next()); - for (Iterator flavoursIter3 = x.iterator(); flavoursIter3.hasNext();){ - if (!mFinalSet.contains(flavoursIter3.next())) { - Logger.INFO("Branching II."); - mFinalSet.add(flavoursIter3.next()); - } - } + mCount = 0; + Iterator> it2 = mTreeSet2.iterator(); + Iterator it3; + Logger.INFO("Running second iteration."); + while(it2.hasNext()){ + Set G = it2.next(); + it3 = G.iterator(); + while(it3.hasNext()){ + BlockPos G2 = it3.next(); + mSearchedSpaces.add(G2); + mFinalTree.add(G2); + mCount++; + Logger.INFO("Second Search: "+G2.getLocationString()); + if (mCount > HARD_LIMIT) { + break; } + } + if (mCount > HARD_LIMIT) { + break; } - }*/ - - - if (mAllSearched.size() > 0) { - Logger.INFO("Queuing "+mAllSearched.size()+" to Harvest Manager."); + } + + + if (mFinalTree.size() > 0) { + Logger.INFO("Queuing "+mFinalTree.size()+" to Harvest Manager."); TreeCutter harvestManager = new TreeCutter(world); - for (Iterator flavoursIter = mAllSearched.iterator(); flavoursIter.hasNext();){ - harvestManager.queue(flavoursIter.next()); - } + + Iterator ith = mFinalTree.iterator(); + while(ith.hasNext()){ + BlockPos G = ith.next(); + harvestManager.queue(G); + mCount++; + Logger.INFO("Queued: "+G.getLocationString()); + if (mCount > HARD_LIMIT) { + break; + } + } + if (harvestManager.isValid) { ItemStack[] loot = harvestManager.getDrops(); if (loot.length > 0) { @@ -583,50 +505,162 @@ public class TreeFarmHelper { return new ItemStack[] {}; } - public static Set findTreeViaBranching(World world, BlockPos h) { - - Set results = new HashSet(); - - //Map results = new ConcurrentHashMap(); - final Block block = world.getBlock(h.xPos, h.yPos, h.zPos); - - Logger.INFO("--------------------------" + "Searching around "+h.getLocationString() + "--------------------------"); - int xRel = h.xPos, yRel = h.yPos, zRel = h.zPos; - //if (TreeFarmHelper.isWoodLog(block)) { - for (int a=-4;a<5;a++) { - for (int b=-4;b<5;b++) { - for (int c=-4;c<5;c++) { - //Check block - Logger.INFO("Looking at X: "+(xRel+a)+" | Y: "+(yRel+b)+" | Z: "+(zRel+c)); - Block log = world.getBlock(xRel+a, yRel+b, zRel+c); - BlockPos P = new BlockPos(xRel+a, yRel+b, zRel+c); - if ((!isFenceBlock(log)) && (isWoodLog(log) || isLeaves(log))) { - Logger.INFO("Was Logs/leaves. "+P.getLocationString()); - if (!results.contains(P)) { - Logger.INFO("Caching result."); - results.add(P); - } - else { - if (P != null && results.contains(P)) { - Logger.INFO("Results were already cached."); - } - } - } + + public static Set getConnectedBlocks(World W, BlockPos P, Set checkedSpaces) { + int HARD_LIMIT = 1000; + int mCount = 0; + Logger.INFO("Finding blocks connected to "+P.getLocationString()+"."); + Set mCheckedSpaces = checkedSpaces; + Set mStartSearch = searchSixFaces(W, P, mCheckedSpaces, false); + Set mSecondSearch = new HashSet(); + Set mThirdSearch = new HashSet(); + Iterator it = mStartSearch.iterator(); + while(it.hasNext()){ + Logger.INFO("Running first iteration. [II]"); + BlockPos G = it.next(); + mCheckedSpaces.add(G); + Set mBranchSearch = searchSixFaces(W, G, mCheckedSpaces, true); + Iterator it2 = mBranchSearch.iterator(); + while(it2.hasNext()){ + Logger.INFO("Running second iteration. [II]"); + BlockPos G2 = it2.next(); + mCheckedSpaces.add(G2); + mSecondSearch.add(G2); + mCount++; + if (mCount > HARD_LIMIT) { + break; } + } + if (mCount > HARD_LIMIT) { + break; } } + mCount = 0; + Iterator itx = mSecondSearch.iterator(); + while(itx.hasNext()){ + BlockPos G = itx.next(); + mCheckedSpaces.add(G); + Set mBranchSearch = searchSixFaces(W, G, mCheckedSpaces, true); + Iterator it2 = mBranchSearch.iterator(); + while(it2.hasNext()){ + BlockPos G2 = it2.next(); + mCheckedSpaces.add(G2); + mThirdSearch.add(G2); + mCount++; + if (mCount > HARD_LIMIT) { + break; + } + } + if (mCount > HARD_LIMIT) { + break; + } + } + return mThirdSearch; + } - Logger.INFO("----------------------------------------------------------"); - - //} - if (results.isEmpty()) { - Logger.INFO("Returning Empty Branch Iteration."); - return new HashSet(); + public static Set searchSixFaces(World W, BlockPos P, Set checkedSpaces, boolean checkLeaves) { + Set mConnected = new HashSet(); + int x = P.xPos; + int y = P.yPos; + int z = P.zPos; + if (checkLeaves) { + if (isWoodLog(W.getBlock(x-1, y, z)) || isLeaves(W.getBlock(x-1, y, z))) { + BlockPos L = new BlockPos(x-1, y, z); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + if (isWoodLog(W.getBlock(x+1, y, z)) || isLeaves(W.getBlock(x+1, y, z))) { + BlockPos L = new BlockPos(x+1, y, z); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + if (isWoodLog(W.getBlock(x, y-1, z)) || isLeaves(W.getBlock(x, y-1, z))) { + BlockPos L = new BlockPos(x, y-1, z); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + if (isWoodLog(W.getBlock(x, y+1, z)) || isLeaves(W.getBlock(x, y+1, z))) { + BlockPos L = new BlockPos(x, y+1, z); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + if (isWoodLog(W.getBlock(x, y, z-1)) || isLeaves(W.getBlock(x, y, z-1))) { + BlockPos L = new BlockPos(x, y, z-1); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + if (isWoodLog(W.getBlock(x, y, z+1)) || isLeaves(W.getBlock(x, y, z+1))) { + BlockPos L = new BlockPos(x, y, z+1); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } } else { - Logger.INFO("Returning Valid Branch Iteration. "+results.size()); - return results; - } + if (isWoodLog(W.getBlock(x-1, y, z))) { + BlockPos L = new BlockPos(x-1, y, z); + //if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + //} + } + if (isWoodLog(W.getBlock(x+1, y, z))) { + BlockPos L = new BlockPos(x+1, y, z); + //if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + //} + } + if (isWoodLog(W.getBlock(x, y-1, z))) { + BlockPos L = new BlockPos(x, y-1, z); + //if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + //} + } + if (isWoodLog(W.getBlock(x, y+1, z))) { + BlockPos L = new BlockPos(x, y+1, z); + //if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + //} + } + if (isWoodLog(W.getBlock(x, y, z-1))) { + BlockPos L = new BlockPos(x, y, z-1); + //if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + //} + } + if (isWoodLog(W.getBlock(x, y, z+1))) { + BlockPos L = new BlockPos(x, y, z+1); + //if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + //} + } + } + return mConnected; + } + + public static Set combineSetData(Set S, Set J) { + Set mData = new HashSet(); + T[] array1 = (T[]) S.toArray(); + Collections.addAll(mData, array1); + T[] array2 = (T[]) J.toArray(); + Collections.addAll(mData, array2); + return mData; } @@ -734,22 +768,22 @@ public class TreeFarmHelper { } return farmerAI; } - + public static boolean onBlockStartBreak (int x, int y, int z, World world){ - final Block wood = world.getBlock(x, y, z); - if (wood == null){ - return false; - } - if (wood.isWood(world, x, y, z) || wood.getMaterial() == Material.sponge) - if(detectTree(world, x,y,z)) { - TreeChopTask chopper = new TreeChopTask(new ChunkPosition(x, y, z), checkFakePlayer(world), 128); - FMLCommonHandler.instance().bus().register(chopper); - // custom block breaking code, don't call vanilla code - return true; - } - //return onBlockStartBreak(stack, x, y, z, player); - return false; - } + final Block wood = world.getBlock(x, y, z); + if (wood == null){ + return false; + } + if (wood.isWood(world, x, y, z) || wood.getMaterial() == Material.sponge) + if(detectTree(world, x,y,z)) { + TreeChopTask chopper = new TreeChopTask(new ChunkPosition(x, y, z), checkFakePlayer(world), 128); + FMLCommonHandler.instance().bus().register(chopper); + // custom block breaking code, don't call vanilla code + return true; + } + //return onBlockStartBreak(stack, x, y, z, player); + return false; + } public static boolean detectTree(World world, int pX, int pY, int pZ) { ChunkPosition pos = null; @@ -803,14 +837,14 @@ public class TreeFarmHelper { return false; } - public static class TreeChopTask { + public static class TreeChopTask { - public final World world; - public final EntityPlayer player; - public final int blocksPerTick; + public final World world; + public final EntityPlayer player; + public final int blocksPerTick; - public Queue blocks = Lists.newLinkedList(); - public Set visited = new THashSet<>(); + public Queue blocks = Lists.newLinkedList(); + public Set visited = new THashSet<>(); public TreeChopTask(ChunkPosition start, EntityPlayer player, int blocksPerTick) { this.world = player.getEntityWorld(); @@ -888,103 +922,101 @@ public class TreeFarmHelper { // goodbye cruel world FMLCommonHandler.instance().bus().unregister(this); } -} + } + + + public static void breakExtraBlock(World world, int x, int y, int z, int sidehit, EntityPlayer playerEntity, int refX, int refY, int refZ) { + // prevent calling that stuff for air blocks, could lead to unexpected behaviour since it fires events + if (world.isAirBlock(x, y, z)) + return; + + // what? + if(!(playerEntity instanceof EntityPlayerMP)) + return; + EntityPlayerMP player = (EntityPlayerMP) playerEntity; + + // check if the block can be broken, since extra block breaks shouldn't instantly break stuff like obsidian + // or precious ores you can't harvest while mining stone + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + // only effective materials + if (!isWoodLog(block)) + return; - public static void breakExtraBlock(World world, int x, int y, int z, int sidehit, EntityPlayer playerEntity, int refX, int refY, int refZ) { - // prevent calling that stuff for air blocks, could lead to unexpected behaviour since it fires events - if (world.isAirBlock(x, y, z)) - return; - - // what? - if(!(playerEntity instanceof EntityPlayerMP)) - return; - EntityPlayerMP player = (EntityPlayerMP) playerEntity; - - // check if the block can be broken, since extra block breaks shouldn't instantly break stuff like obsidian - // or precious ores you can't harvest while mining stone - Block block = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - - // only effective materials - if (!isWoodLog(block)) - return; - - Block refBlock = world.getBlock(refX, refY, refZ); - float refStrength = ForgeHooks.blockStrength(refBlock, player, world, refX, refY, refZ); - float strength = ForgeHooks.blockStrength(block, player, world, x,y,z); - - // only harvestable blocks that aren't impossibly slow to harvest - if (!ForgeHooks.canHarvestBlock(block, player, meta) || refStrength/strength > 10f) - return; - - // send the blockbreak event - BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x,y,z); - if(event.isCanceled()) - return; - - if (player.capabilities.isCreativeMode) { - block.onBlockHarvested(world, x, y, z, meta, player); - if (block.removedByPlayer(world, player, x, y, z, false)) - block.onBlockDestroyedByPlayer(world, x, y, z, meta); - - // send update to client - if (!world.isRemote) { - player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); - } - return; - } - - // callback to the tool the player uses. Called on both sides. This damages the tool n stuff. - player.getCurrentEquippedItem().func_150999_a(world, block, x, y, z, player); - - // server sided handling - if (!world.isRemote) { - // serverside we reproduce ItemInWorldManager.tryHarvestBlock - - // ItemInWorldManager.removeBlock - block.onBlockHarvested(world, x,y,z, meta, player); - - if(block.removedByPlayer(world, player, x,y,z, true)) // boolean is if block can be harvested, checked above - { - block.onBlockDestroyedByPlayer( world, x,y,z, meta); - block.harvestBlock(world, player, x,y,z, meta); - block.dropXpOnBlockBreak(world, x,y,z, event.getExpToDrop()); - } - - // always send block update to client - player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); - } - // client sided handling - else { - //PlayerControllerMP pcmp = Minecraft.getMinecraft().playerController; - // clientside we do a "this clock has been clicked on long enough to be broken" call. This should not send any new packets - // the code above, executed on the server, sends a block-updates that give us the correct state of the block we destroy. - - // following code can be found in PlayerControllerMP.onPlayerDestroyBlock - world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); - if(block.removedByPlayer(world, player, x,y,z, true)) - { - block.onBlockDestroyedByPlayer(world, x,y,z, meta); - } - // callback to the tool - ItemStack itemstack = player.getCurrentEquippedItem(); - if (itemstack != null) - { - itemstack.func_150999_a(world, block, x, y, z, player); - - if (itemstack.stackSize == 0) - { - player.destroyCurrentEquippedItem(); - } - } - - // send an update to the server, so we get an update back - //if(PHConstruct.extraBlockUpdates) - //Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C07PacketPlayerDigging(2, x,y,z, Minecraft.getMinecraft().objectMouseOver.sideHit)); - } - } + Block refBlock = world.getBlock(refX, refY, refZ); + float refStrength = ForgeHooks.blockStrength(refBlock, player, world, refX, refY, refZ); + float strength = ForgeHooks.blockStrength(block, player, world, x,y,z); + + // only harvestable blocks that aren't impossibly slow to harvest + if (!ForgeHooks.canHarvestBlock(block, player, meta) || refStrength/strength > 10f) + return; + + // send the blockbreak event + BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x,y,z); + if(event.isCanceled()) + return; + + if (player.capabilities.isCreativeMode) { + block.onBlockHarvested(world, x, y, z, meta, player); + if (block.removedByPlayer(world, player, x, y, z, false)) + block.onBlockDestroyedByPlayer(world, x, y, z, meta); + + // send update to client + if (!world.isRemote) { + player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); + } + return; + } + // callback to the tool the player uses. Called on both sides. This damages the tool n stuff. + player.getCurrentEquippedItem().func_150999_a(world, block, x, y, z, player); + // server sided handling + if (!world.isRemote) { + // serverside we reproduce ItemInWorldManager.tryHarvestBlock + + // ItemInWorldManager.removeBlock + block.onBlockHarvested(world, x,y,z, meta, player); + + if(block.removedByPlayer(world, player, x,y,z, true)) // boolean is if block can be harvested, checked above + { + block.onBlockDestroyedByPlayer( world, x,y,z, meta); + block.harvestBlock(world, player, x,y,z, meta); + block.dropXpOnBlockBreak(world, x,y,z, event.getExpToDrop()); + } + + // always send block update to client + player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); + } + // client sided handling + else { + //PlayerControllerMP pcmp = Minecraft.getMinecraft().playerController; + // clientside we do a "this clock has been clicked on long enough to be broken" call. This should not send any new packets + // the code above, executed on the server, sends a block-updates that give us the correct state of the block we destroy. + + // following code can be found in PlayerControllerMP.onPlayerDestroyBlock + world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); + if(block.removedByPlayer(world, player, x,y,z, true)) + { + block.onBlockDestroyedByPlayer(world, x,y,z, meta); + } + // callback to the tool + ItemStack itemstack = player.getCurrentEquippedItem(); + if (itemstack != null) + { + itemstack.func_150999_a(world, block, x, y, z, player); + + if (itemstack.stackSize == 0) + { + player.destroyCurrentEquippedItem(); + } + } + + // send an update to the server, so we get an update back + //if(PHConstruct.extraBlockUpdates) + //Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C07PacketPlayerDigging(2, x,y,z, Minecraft.getMinecraft().objectMouseOver.sideHit)); + } + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java index 7bdc5ae2f2..297db1d7a0 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java @@ -1,7 +1,8 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; import static gregtech.api.enums.GT_Values.V; -import static gtPlusPlus.api.objects.ChunkManager.mChunkLoaderManagerMap; +import static gtPlusPlus.api.objects.minecraft.ChunkManager.mChunkLoaderManagerMap; + import java.io.File; import java.io.IOException; import java.util.Map; @@ -17,11 +18,11 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachi import gregtech.api.objects.GT_RenderedTexture; import gtPlusPlus.GTplusplus; import gtPlusPlus.api.interfaces.IChunkLoader; -import gtPlusPlus.api.objects.ChunkManager; -import gtPlusPlus.api.objects.DimChunkPos; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.array.BlockPos; -import gtPlusPlus.core.util.array.Triplet; +import gtPlusPlus.api.objects.data.Triplet; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.api.objects.minecraft.ChunkManager; +import gtPlusPlus.api.objects.minecraft.DimChunkPos; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java index 7f70712ee9..e88840573d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java @@ -11,8 +11,8 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.array.BlockPos; import gtPlusPlus.core.util.entity.EntityUtils; import gtPlusPlus.core.util.player.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_TeslaTower.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_TeslaTower.java index b2b6b83d0b..4540c41bd5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_TeslaTower.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_TeslaTower.java @@ -19,10 +19,10 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.entity.EntityTeslaTowerLightning; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.materials.MaterialUtils; import gtPlusPlus.core.util.player.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityTreeFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityTreeFarm.java index b6cf3893eb..f0123c2a08 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityTreeFarm.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityTreeFarm.java @@ -11,11 +11,11 @@ import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.*; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.players.FakeFarmer; import gtPlusPlus.core.slots.SlotBuzzSaw.SAWTOOL; -import gtPlusPlus.core.util.array.BlockPos; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_TreeFarmer; import gtPlusPlus.xmod.gregtech.api.gui.GUI_TreeFarmer; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialFishingPond.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialFishingPond.java index 98dc3140bb..62279f0461 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialFishingPond.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialFishingPond.java @@ -17,10 +17,10 @@ import gregtech.api.util.FishPondFakeRecipe; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; -import gtPlusPlus.core.util.array.AutoMap; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.math.MathUtils; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java index a64057f3cc..f5cf674578 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java @@ -24,15 +24,15 @@ import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gregtech.api.util.Recipe_GT; -import gtPlusPlus.api.objects.GenericStack; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.api.objects.data.Triplet; +import gtPlusPlus.api.objects.minecraft.GenericStack; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.AutoMap; -import gtPlusPlus.core.util.array.Pair; -import gtPlusPlus.core.util.array.Triplet; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.math.MathUtils; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java index 7176db5d97..db6b1d9e6a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java @@ -14,9 +14,9 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java index c57ad71fc7..b36ba2f69e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java @@ -7,9 +7,9 @@ import java.util.Map; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.AutoMap; import gtPlusPlus.core.util.materials.MaterialUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MaterialProcessing.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MaterialProcessing.java index 32fa282b0c..590296eee9 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MaterialProcessing.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MaterialProcessing.java @@ -4,12 +4,12 @@ import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_Recipe; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.MaterialStack; import gtPlusPlus.core.material.state.MaterialState; -import gtPlusPlus.core.util.array.AutoMap; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.item.ItemUtils; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java index bdcb30f930..d7fb58366b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java @@ -5,14 +5,14 @@ import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.MaterialStack; import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.recipe.common.CI; -import gtPlusPlus.core.util.array.AutoMap; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.recipe.RecipeUtils; import net.minecraft.item.ItemStack; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java index 72c09eed0a..00feb26ca5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java @@ -11,11 +11,11 @@ import gregtech.api.enums.GT_Values; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.*; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.AutoMap; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.item.ItemStack; -- cgit