diff options
Diffstat (limited to 'src/Java/gtPlusPlus/core')
58 files changed, 1998 insertions, 356 deletions
diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java index c2b77ebdae..f8a9eb2b2f 100644 --- a/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java @@ -53,11 +53,11 @@ public class BlockBaseModular extends BasicBlock{ } if (this.thisBlockType.equals(BlockTypes.STANDARD.name().toUpperCase())){ - LanguageRegistry.addName(this, "Block of "+blockMaterial); + //LanguageRegistry.addName(this, "Block of "+blockMaterial); //Utils.LOG_INFO("Registered Block in Language Registry as: "+"Block of "+blockMaterial); } else if (this.thisBlockType.equals(BlockTypes.FRAME.name().toUpperCase())){ - LanguageRegistry.addName(this, blockMaterial+ " Frame Box"); + //LanguageRegistry.addName(this, blockMaterial+ " Frame Box"); //Utils.LOG_INFO("Registered Block in Language Registry as: "+blockMaterial+ " Frame Box"); } diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseNBT.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseNBT.java index da308e270b..7ac07880c9 100644 --- a/src/Java/gtPlusPlus/core/block/base/BlockBaseNBT.java +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseNBT.java @@ -32,7 +32,7 @@ public abstract class BlockBaseNBT extends BlockContainer this.setBlockName(unlocalName); this.setCreativeTab(AddToCreativeTab.tabMachines); GameRegistry.registerBlock(this, ItemBlockNBT.class, unlocalName); - LanguageRegistry.addName(this, displayName); + //LanguageRegistry.addName(this, displayName); } /** diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java index 2bea09d806..2f2050f21b 100644 --- a/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java @@ -53,7 +53,7 @@ public class BlockBaseOre extends BasicBlock implements ITexturedBlock { try { GameRegistry.registerBlock(this, ItemBlockOre.class, Utils.sanitizeString("ore"+Utils.sanitizeString(this.blockMaterial.getLocalizedName()))); GT_OreDictUnificator.registerOre("ore"+Utils.sanitizeString(this.blockMaterial.getLocalizedName()), ItemUtils.getSimpleStack(this)); - LanguageRegistry.addName(this, blockMaterial.getLocalizedName()+ " Ore"); + //LanguageRegistry.addName(this, blockMaterial.getLocalizedName()+ " Ore"); } catch (Throwable t){ t.printStackTrace(); 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/block/general/antigrief/BlockWitherProof.java b/src/Java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java index d093bf2e2f..3d97fb0aa3 100644 --- a/src/Java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java +++ b/src/Java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java @@ -30,9 +30,8 @@ public class BlockWitherProof extends Block{ this.setResistance(5000.0F); this.setHarvestLevel("pickaxe", 3); this.setStepSound(soundTypeMetal); - LanguageRegistry.addName(this, "Wither Cage"); + //LanguageRegistry.addName(this, "Wither Cage"); GameRegistry.registerBlock(this, Utils.sanitizeString("blockBlackGate")); - } public String GetProperName(){ 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<String> getCommandAliases() - { + public List<String> 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<EntityItem> itemEntities = new AutoMap<EntityItem>(); + 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/commands/CommandUtils.java b/src/Java/gtPlusPlus/core/commands/CommandUtils.java index 4e74d53464..175925d40c 100644 --- a/src/Java/gtPlusPlus/core/commands/CommandUtils.java +++ b/src/Java/gtPlusPlus/core/commands/CommandUtils.java @@ -5,7 +5,7 @@ import net.minecraft.entity.player.EntityPlayer; public class CommandUtils { - public EntityPlayer getPlayer(final ICommandSender icommandsender){ + public static EntityPlayer getPlayer(final ICommandSender icommandsender){ EntityPlayer player; if(icommandsender instanceof EntityPlayer){ 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/config/ConfigHandler.java b/src/Java/gtPlusPlus/core/config/ConfigHandler.java index 98c4320ce7..a9fbec55de 100644 --- a/src/Java/gtPlusPlus/core/config/ConfigHandler.java +++ b/src/Java/gtPlusPlus/core/config/ConfigHandler.java @@ -31,6 +31,8 @@ public class ConfigHandler { "Makes many machines display lots of debug logging."); showHiddenNEIItems = config.getBoolean("showHiddenNEIItems", "debug", false, "Makes all items hidden from NEI display."); + dumpItemAndBlockData = config.getBoolean("dumpItemAndBlockData", "debug", false, + "Dumps all GT++ and Toxic Everglade Data to en_US.lang in the config folder. This config option can be used by foreign players to generate blank .lang files, which they can populate with their language of choice."); // Machines 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. + * + * <pre><code> + * 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. + * </code></pre> + */ +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<Integer, SegmentAnalytics> sAnalyticsMasterList = new ConcurrentHashMap<Integer, SegmentAnalytics>(); + //ID count + private static int sAnalyticsMapID = 0; + + //Analytics Player Mapping + public static final Map<UUID, Integer> sAnalyticsToPlayermap = new ConcurrentHashMap<UUID, Integer>(); + + //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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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/PickaxeBlockBreakEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java index aa9155d654..bdc9489f1d 100644 --- a/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java @@ -5,10 +5,8 @@ import java.util.UUID; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.metatileentity.*; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.player.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.machines.GregtechMetaSafeBlockBase; -import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.event.entity.player.PlayerInteractEvent; @@ -20,25 +18,14 @@ public class PickaxeBlockBreakEventHandler { try{ final TileEntity entity = event.world.getTileEntity(event.x, event.y, event.z); if (entity != null){ - final EntityPlayer playerInternal = event.getPlayer(); - Logger.WARNING(entity.getClass().getSimpleName()); - if (entity.getClass().getSimpleName().equals("")){ - - } - if ((entity instanceof BaseTileEntity) && !(entity instanceof BaseMetaPipeEntity)){ + final EntityPlayer playerInternal = event.getPlayer(); + if ((entity instanceof BaseMetaTileEntity) && !(BaseMetaPipeEntity.class.isInstance(entity))){ final IMetaTileEntity X = ((BaseMetaTileEntity)entity).getMetaTileEntity(); - final Block ThisBlock = X.getBaseMetaTileEntity().getBlock(event.x, event.y, event.z); + //final Block ThisBlock = X.getBaseMetaTileEntity().getBlock(event.x, event.y, event.z); if (X instanceof GregtechMetaSafeBlockBase){ - final UUID ownerUUID = ((GregtechMetaSafeBlockBase)X).ownerUUID; final UUID accessorUUID = playerInternal.getUniqueID(); - Logger.WARNING("Owner UUID: "+ownerUUID); - Logger.WARNING("Accessor UUID: "+accessorUUID); - if (((GregtechMetaSafeBlockBase)X).bUnbreakable){ - - Logger.INFO("UUID info. Accessor: "+accessorUUID + " | Owner: "+ownerUUID); - if (accessorUUID == ownerUUID){ PlayerUtils.messagePlayer(playerInternal, "Since you own this block, it has been destroyed."); event.setCanceled(false); @@ -47,15 +34,13 @@ public class PickaxeBlockBreakEventHandler { event.setCanceled(true); PlayerUtils.messagePlayer(playerInternal, "Since you do not own this block, it has not been destroyed."); } - // } } } } - } catch (final NullPointerException e) { - System.out.print("Caught a NullPointerException involving Safe Blocks. Cause: "+e.getCause()); + //System.out.print("Caught a NullPointerException involving Safe Blocks. Cause: "+e.getCause()); } } 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/base/BaseItemComponent.java b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java index 7622838f68..8b68d955e3 100644 --- a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java @@ -86,7 +86,7 @@ public class BaseItemComponent extends Item{ //return "gregtech" + ":" + "materialicons/"+metType+"/" + this.componentType.COMPONENT_NAME.toLowerCase(); } - @Override + /*@Override public String getItemStackDisplayName(final ItemStack p_77653_1_) { if (this.componentType == ComponentTypes.SMALLGEAR){ @@ -97,7 +97,7 @@ public class BaseItemComponent extends Item{ return (this.componentMaterial.getLocalizedName()+this.componentType.DISPLAY_NAME); } return this.materialName+" Cell"; - } + }*/ public final String getMaterialName() { return this.materialName; diff --git a/src/Java/gtPlusPlus/core/item/base/CoreItem.java b/src/Java/gtPlusPlus/core/item/base/CoreItem.java index 3b0fa7b621..d80553de96 100644 --- a/src/Java/gtPlusPlus/core/item/base/CoreItem.java +++ b/src/Java/gtPlusPlus/core/item/base/CoreItem.java @@ -194,11 +194,11 @@ public class CoreItem extends Item } } - @Override +/* @Override public String getItemStackDisplayName(final ItemStack tItem) { if ((this.itemName == null) || this.itemName.equals("")) { return super.getItemStackDisplayName(tItem); } return this.itemName; - } + }*/ }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java index 4ac7c7f5ff..aed0145303 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java @@ -1,6 +1,9 @@ package gtPlusPlus.core.item.base.itemblock; +import java.util.List; + import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.interfaces.ITileTooltip; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.tileentities.base.TileEntityBase; import gtPlusPlus.core.util.player.PlayerUtils; @@ -15,10 +18,29 @@ import net.minecraft.world.World; public class ItemBlockNBT extends ItemBlock { + + protected final int mID; + public ItemBlockNBT(final Block block) { super(block); + this.mID = ((ITileTooltip) block).getTooltipID(); + } + + + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + + //if () + + + + if (this.mID == 0){ //blockDarkWorldPortalFrame + list.add("Assembled in the same shape as the Nether Portal."); + } } + + @Override public void onCreated(ItemStack item, World world, EntityPlayer player) { addNBT(player, item); @@ -59,17 +81,13 @@ public class ItemBlockNBT extends ItemBlock { @Override public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, float hitX, float hitY, float hitZ, int aMeta) { - - - if (!(aWorld.setBlock(aX, aY, aZ, this.field_150939_a, 0, 3))) { return false; } if (aWorld.getBlock(aX, aY, aZ) == this.field_150939_a) { this.field_150939_a.onBlockPlacedBy(aWorld, aX, aY, aZ, aPlayer, aStack); this.field_150939_a.onPostBlockPlaced(aWorld, aX, aY, aZ, aMeta); - } - + } TileEntityBase tTileEntity = (TileEntityBase) aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity != null && aPlayer != null) { if (tTileEntity.isServerSide()){ @@ -78,7 +96,6 @@ public class ItemBlockNBT extends ItemBlock { tTileEntity.setOwnerInformation(aNBT.getString("mOwner"), aNBT.getString("mUUID"), aNBT.getBoolean("mOP")); } } - return true; } diff --git a/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java b/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java index e2de72fa57..d11deecc17 100644 --- a/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java +++ b/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java @@ -57,10 +57,10 @@ public class BaseOreComponent extends Item{ return "gregtech" + ":" + "materialicons/METALLIC/" + this.componentType.COMPONENT_NAME; } - @Override + /*@Override public String getItemStackDisplayName(final ItemStack p_77653_1_) { return (this.componentType.getPrefix()+this.componentMaterial.getLocalizedName()+this.componentType.DISPLAY_NAME); - } + }*/ public final String getMaterialName() { return this.materialName; 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/ItemHalfCompleteCasings.java b/src/Java/gtPlusPlus/core/item/general/ItemHalfCompleteCasings.java index 0463628e46..1ad12b69d4 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemHalfCompleteCasings.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemHalfCompleteCasings.java @@ -32,7 +32,7 @@ public class ItemHalfCompleteCasings extends BaseItemColourable{ } } - @Override + /*@Override public String getItemStackDisplayName(final ItemStack tItem) { String prefix = "Half Complete Casing "; String casingType = ""; @@ -50,7 +50,7 @@ public class ItemHalfCompleteCasings extends BaseItemColourable{ } return (prefix+casingType); - } + }*/ @Override public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { 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 c43c8dd3e7..67de9e64dd 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; @@ -47,7 +47,7 @@ public class CORE { public static final String name = "GT++"; public static final String MODID = "miscutils"; - public static final String VERSION = "1.7.0-prerelease-4"; + public static final String VERSION = "1.7.0-prerelease-5"; public static String MASTER_VERSION = NetworkUtils.getContentFromURL("https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt").toLowerCase(); public static String USER_COUNTRY = GeoUtils.determineUsersCountry(); public static boolean isModUpToDate = Utils.isModUpToDate(); @@ -148,6 +148,7 @@ public class CORE { public static boolean disableEnderIOIngotTooltips = false; public static boolean MACHINE_INFO = true; public static boolean showHiddenNEIItems = false; + public static boolean dumpItemAndBlockData = false; //Tools public static boolean enableSkookumChoochers = true; 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/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index bd53c4f38a..969eb3aed8 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -27,7 +27,6 @@ import gtPlusPlus.core.util.reflect.AddGregtechRecipe; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import net.minecraft.init.Blocks; import net.minecraft.init.Items; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; @@ -1040,16 +1039,53 @@ public class RECIPES_GREGTECH { //LFTR Fuel Related Compounds - //Hydroxide - GT_Values.RA.addChemicalRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("cellOxygen", 1), - ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1), - GT_Values.NF, - FluidUtils.getFluidStack("hydroxide", 2000), - ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 2), - 8*20); - //Ammonia + if(CORE.GTNH){ + //Hydroxide + AddGregtechRecipe.addChemicalRecipeForBasicMachineOnly( + ItemUtils.getItemStackOfAmountFromOreDict("cellOxygen", 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1), + GT_Values.NF, + FluidUtils.getFluidStack("hydroxide", 2000), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 2), + GT_Values.NI, + 8*20, 30); + //Beryllium Hydroxide + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("dustBeryllium", 7), + ItemUtils.getGregtechCircuit(3), + FluidUtils.getFluidStack("hydroxide", 1000), + FluidUtils.getFluidStack("berylliumhydroxide", 2000), + GT_Values.NI, + 8*20); + //Ammonium Bifluoride + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrofluoricAcid", 1), + ItemUtils.getGregtechCircuit(3), + FluidUtils.getFluidStack("ammonium", 1000), + FluidUtils.getFluidStack("ammoniumbifluoride", 2000), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 1), + 26*20); + //Ammonium + AddGregtechRecipe.addChemicalRecipeForBasicMachineOnly( + ItemUtils.getItemStackOfAmountFromOreDict("cellAmmonia", 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1), + GT_Values.NF, + FluidUtils.getFluidStack("ammonium", 2000), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 2), + GT_Values.NI, + 20*20, 30); + } + if (!CORE.GTNH) { + //Hydroxide + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("cellOxygen", 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1), + GT_Values.NF, + FluidUtils.getFluidStack("hydroxide", 2000), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 2), + 8*20); + //Ammonia (moved to GTNH core mod) GT_Values.RA.addChemicalRecipe( ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 3), ItemUtils.getItemStackOfAmountFromOreDict("dustMagnetite", 0), @@ -1057,31 +1093,31 @@ public class RECIPES_GREGTECH { FluidUtils.getFluidStack("ammonia", 1000), ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 3), 14 * 20); - }//moved to GTNH core mod - //Ammonium - GT_Values.RA.addChemicalRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("cellAmmonia", 1), - ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1), - GT_Values.NF, - FluidUtils.getFluidStack("ammonium", 2000), - ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 2), - 20*20); - //Ammonium Bifluoride - GT_Values.RA.addChemicalRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("cellHydrofluoricAcid", 1), - GT_Values.NI, - FluidUtils.getFluidStack("ammonium", 1000), - FluidUtils.getFluidStack("ammoniumbifluoride", 2000), - ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 1), - 26*20); - //Beryllium Hydroxide - GT_Values.RA.addChemicalRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("dustBeryllium", 7), - GT_Values.NI, - FluidUtils.getFluidStack("hydroxide", 1000), - FluidUtils.getFluidStack("berylliumhydroxide", 2000), - GT_Values.NI, - 8*20); + //Beryllium Hydroxide + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("dustBeryllium", 7), + GT_Values.NI, + FluidUtils.getFluidStack("hydroxide", 1000), + FluidUtils.getFluidStack("berylliumhydroxide", 2000), + GT_Values.NI, + 8*20); + //Ammonium Bifluoride + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrofluoricAcid", 1), + GT_Values.NI, + FluidUtils.getFluidStack("ammonium", 1000), + FluidUtils.getFluidStack("ammoniumbifluoride", 2000), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 1), + 26*20); + //Ammonium + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("cellAmmonia", 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1), + GT_Values.NF, + FluidUtils.getFluidStack("ammonium", 2000), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 2), + 20*20); + } } private static void blastFurnaceRecipes(){ 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/TileEntityBase.java b/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java index 81dfb1acf4..f8d4c3074e 100644 --- a/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java +++ b/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java @@ -82,7 +82,6 @@ public abstract class TileEntityBase extends TileEntity implements ISidedInvento } public boolean onPreTick(){ - return true; } @@ -141,10 +140,7 @@ public abstract class TileEntityBase extends TileEntity implements ISidedInvento public boolean isServerSide(){ if (this.hasWorldObj()){ - if (this.getWorldObj().isRemote){ - return false; - } - else { + if (!this.getWorldObj().isRemote){ return true; } } diff --git a/src/Java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java b/src/Java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java new file mode 100644 index 0000000000..8b789f922f --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java @@ -0,0 +1,1171 @@ +package gtPlusPlus.core.tileentities.base; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.interfaces.tileentity.IEnergyConnected; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.net.GT_Packet; +import gregtech.api.net.GT_Packet_Block_Event; +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 ic2.api.info.Info; +import net.minecraft.block.Block; +import net.minecraft.block.BlockFire; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.Packet; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public abstract class TilePoweredGT extends TileEntityBase implements IGregtechPower { + + public static AutoMap<TilePoweredGT> mPoweredEntities = new AutoMap<TilePoweredGT>(); + + //Base Tile Fields + public boolean ignoreUnloadedChunks; + public boolean isDead; + //Meta Tile Fields + private long mAcceptedAmperes; + + private boolean[] mActiveEUInputs; + private boolean[] mActiveEUOutputs; + protected int[] mAverageEUInput; + protected int mAverageEUInputIndex; + protected int[] mAverageEUOutput; + protected int mAverageEUOutputIndex; + private final TileEntity[] mBufferedTileEntities; + private byte mFacing = 0; + private boolean mHasEnoughEnergy; + private boolean mNeedsUpdate; + private boolean mNeedsBlockUpdate; + private boolean mRunningThroughTick; + private boolean mSendClientData; + protected boolean mReleaseEnergy; + private long mTickTimer; + protected long mStoredEnergy; + protected long mStoredSteam; + + public TilePoweredGT() { + super(); + this.mBufferedTileEntities = new TileEntity[6]; + this.ignoreUnloadedChunks = true; + this.isDead = false; + mPoweredEntities.put(this); + } + + @Override + public boolean acceptsRotationalEnergy(byte p0) { + return false; + } + + private boolean canAccessData() { + return this.isInvalid() ? false : true; + } + + private final void clearNullMarkersFromTileEntityBuffer() { + for (int i = 0; i < this.mBufferedTileEntities.length; ++i) { + if (this.mBufferedTileEntities[i] == this) { + this.mBufferedTileEntities[i] = null; + } + } + } + + protected final void clearTileEntityBuffer() { + for (int i = 0; i < this.mBufferedTileEntities.length; ++i) { + this.mBufferedTileEntities[i] = null; + } + } + + private boolean crossedChunkBorder(final int aX, final int aZ) { + return aX >> 4 != this.xCoord >> 4 || aZ >> 4 != this.zCoord >> 4; + } + + @Override + public boolean decreaseStoredEnergyUnits(final long aEnergy, final boolean aIgnoreTooLessEnergy) { + return this.canAccessData() && (this.mHasEnoughEnergy = (this.decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy) + || this.decreaseStoredSteam(aEnergy, false) + || (aIgnoreTooLessEnergy && this.decreaseStoredSteam(aEnergy, true)))); + } + + public boolean decreaseStoredEU(final long aEnergy, final boolean aIgnoreTooLessEnergy) { + if (!this.canAccessData()) { + return false; + } + if (this.getEUVar() - aEnergy < 0L && !aIgnoreTooLessEnergy) { + return false; + } + this.setStoredEU(this.getEUVar() - aEnergy); + if (this.getEUVar() < 0L) { + this.setStoredEU(0L); + return false; + } + return true; + } + + public boolean decreaseStoredSteam(final long aEnergy, final boolean aIgnoreTooLessEnergy) { + if (!this.canAccessData()) { + return false; + } + if (this.getSteamVar() - aEnergy < 0L && !aIgnoreTooLessEnergy) { + return false; + } + this.setStoredSteam(this.getSteamVar() - aEnergy); + if (this.getSteamVar() < 0L) { + this.setStoredSteam(0L); + return false; + } + return true; + } + + public void doExplosion(final long aExplosionPower) { + final float tStrength = (aExplosionPower < GT_Values.V[0]) + ? 1.0f + : ((aExplosionPower < GT_Values.V[1]) + ? 2.0f + : ((aExplosionPower < GT_Values.V[2]) + ? 3.0f + : ((aExplosionPower < GT_Values.V[3]) + ? 4.0f + : ((aExplosionPower < GT_Values.V[4]) + ? 5.0f + : ((aExplosionPower < GT_Values.V[4] * 2L) + ? 6.0f + : ((aExplosionPower < GT_Values.V[5]) + ? 7.0f + : ((aExplosionPower < GT_Values.V[6]) + ? 8.0f + : ((aExplosionPower < GT_Values.V[7]) + ? 9.0f + : 10.0f)))))))); + final int tX = this.getXCoord(); + final int tY = this.getYCoord(); + final int tZ = this.getZCoord(); + final World tWorld = this.getWorld(); + GT_Utility.sendSoundToPlayers(tWorld, (String) GregTech_API.sSoundList.get(209), 1.0f, -1.0f, tX, tY, tZ); + tWorld.setBlock(tX, tY, tZ, Blocks.air); + if (GregTech_API.sMachineExplosions) { + tWorld.createExplosion((Entity) null, tX + 0.5, tY + 0.5, tZ + 0.5, tStrength, true); + } + } + + public boolean drainEnergyUnits(final byte aSide, final long aVoltage, final long aAmperage) { + if (!this.canAccessData() || !this.isElectric() || !this.outputsEnergyTo(aSide) + || this.getStoredEU() - aVoltage * aAmperage < this.getMinimumStoredEU()) { + return false; + } + if (this.decreaseStoredEU(aVoltage * aAmperage, false)) { + final int[] mAverageEUOutput = this.mAverageEUOutput; + final int mAverageEUOutputIndex = this.mAverageEUOutputIndex; + mAverageEUOutput[mAverageEUOutputIndex] += (int) (aVoltage * aAmperage); + return true; + } + return false; + } + + @Override + public final boolean getAir(final int aX, final int aY, final int aZ) { + return (this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ)) + || GT_Utility.isBlockAir(this.worldObj, aX, aY, aZ); + } + + @Override + public final boolean getAirAtSide(final byte aSide) { + return this.getAirAtSideAndDistance(aSide, 1); + } + + @Override + public final boolean getAirAtSideAndDistance(final byte aSide, final int aDistance) { + return this.getAir(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance), + this.getOffsetZ(aSide, aDistance)); + } + + @Override + public final boolean getAirOffset(final int aX, final int aY, final int aZ) { + return this.getAir(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); + } + + @Override + public long getAverageElectricInput() { + int rEU = 0; + for (int i = 0; i < this.mAverageEUInput.length; ++i) { + if (i != this.mAverageEUInputIndex) { + rEU += this.mAverageEUInput[i]; + } + } + return rEU / (this.mAverageEUInput.length - 1); + } + + public long getAverageElectricOutput() { + int rEU = 0; + for (int i = 0; i < this.mAverageEUOutput.length; ++i) { + if (i != this.mAverageEUOutputIndex) { + rEU += this.mAverageEUOutput[i]; + } + } + return rEU / (this.mAverageEUOutput.length - 1); + } + + @Override + public byte getBackFacing() { + return GT_Utility.getOppositeSide((int) this.mFacing); + } + + @Override + public final Block getBlock(final int aX, final int aY, final int aZ) { + if (this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ)) { + return Blocks.air; + } + return this.worldObj.getBlock(aX, aY, aZ); + } + + + @Override + public final Block getBlockAtSide(final byte aSide) { + return this.getBlockAtSideAndDistance(aSide, 1); + } + + @Override + public final Block getBlockAtSideAndDistance(final byte aSide, final int aDistance) { + return this.getBlock(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance), + this.getOffsetZ(aSide, aDistance)); + } + + @Override + public final Block getBlockOffset(final int aX, final int aY, final int aZ) { + return this.getBlock(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); + } + + @Override + public String[] getDescription() { + // TODO Auto-generated method stub + return null; + } + + + + + + + + + @Override + public long getEUCapacity() { + if (this.canAccessData()) { + return this.maxEUStore(); + } + return 0L; + } + + public long getEUVar() { + return mStoredEnergy; + } + + @Override + public byte getFrontFacing() { + return this.mFacing; + } + + @Override + public final IGregTechTileEntity getIGregTechTileEntity(final int aX, final int aY, final int aZ) { + final TileEntity tTileEntity = this.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity) { + return (IGregTechTileEntity) tTileEntity; + } + return null; + } + + @Override + public final IGregTechTileEntity getIGregTechTileEntityAtSide(final byte aSide) { + final TileEntity tTileEntity = this.getTileEntityAtSide(aSide); + if (tTileEntity instanceof IGregTechTileEntity) { + return (IGregTechTileEntity) tTileEntity; + } + return null; + } + + @Override + public final IGregTechTileEntity getIGregTechTileEntityAtSideAndDistance(final byte aSide, final int aDistance) { + final TileEntity tTileEntity = this.getTileEntityAtSideAndDistance(aSide, aDistance); + if (tTileEntity instanceof IGregTechTileEntity) { + return (IGregTechTileEntity) tTileEntity; + } + return null; + } + + @Override + public final IGregTechTileEntity getIGregTechTileEntityOffset(final int aX, final int aY, final int aZ) { + final TileEntity tTileEntity = this.getTileEntityOffset(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity) { + return (IGregTechTileEntity) tTileEntity; + } + return null; + } + + @Override + public final IInventory getIInventory(final int aX, final int aY, final int aZ) { + final TileEntity tTileEntity = this.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IInventory) { + return (IInventory) tTileEntity; + } + return null; + } + + @Override + public final IInventory getIInventoryAtSide(final byte aSide) { + final TileEntity tTileEntity = this.getTileEntityAtSide(aSide); + if (tTileEntity instanceof IInventory) { + return (IInventory) tTileEntity; + } + return null; + } + + @Override + public final IInventory getIInventoryAtSideAndDistance(final byte aSide, final int aDistance) { + final TileEntity tTileEntity = this.getTileEntityAtSideAndDistance(aSide, aDistance); + if (tTileEntity instanceof IInventory) { + return (IInventory) tTileEntity; + } + return null; + } + + @Override + public final IInventory getIInventoryOffset(final int aX, final int aY, final int aZ) { + final TileEntity tTileEntity = this.getTileEntityOffset(aX, aY, aZ); + if (tTileEntity instanceof IInventory) { + return (IInventory) tTileEntity; + } + return null; + } + + @Override + public String[] getInfoData() { + // TODO Auto-generated method stub + return null; + } + + @Override + public long getInputAmperage() { + if (this.canAccessData() && this.isElectric()) { + return this.maxAmperesIn(); + } + return 0L; + } + + public long getInputTier() { + return GT_Utility.getTier(this.getInputVoltage()); + } + + @Override + public long getInputVoltage() { + if (this.canAccessData() && this.isElectric()) { + return this.maxEUInput(); + } + return 2147483647L; + } + + private long getMinimumStoredEU() { + return 0; + } + + @Override + public final int getOffsetX(final byte aSide, final int aMultiplier) { + return this.xCoord + ForgeDirection.getOrientation((int) aSide).offsetX * aMultiplier; + } + + public final short getOffsetY(final byte aSide, final int aMultiplier) { + return (short) (this.yCoord + ForgeDirection.getOrientation((int) aSide).offsetY * aMultiplier); + } + + public final int getOffsetZ(final byte aSide, final int aMultiplier) { + return this.zCoord + ForgeDirection.getOrientation((int) aSide).offsetZ * aMultiplier; + } + + @Override + public long getOutputAmperage() { + if (this.canAccessData() && this.isElectric()) { + return this.maxAmperesOut(); + } + return 0L; + } + + public long getOutputTier() { + return GT_Utility.getTier(this.getOutputVoltage()); + } + + @Override + public long getOutputVoltage() { + if (this.canAccessData() && this.isElectric() && this.isEnetOutput()) { + return this.maxEUOutput(); + } + return 0L; + } + + @Override + public int getRandomNumber(int p0) { + return CORE.RANDOM.nextInt(); + } + + @Override + public long getSteamCapacity() { + if (this.canAccessData()) { + return this.maxSteamStore(); + } + return 0L; + } + + public long getSteamVar() { + return mStoredSteam; + } + + @Override + public long getStoredEU() { + if (this.canAccessData()) { + return Math.min(this.getEUVar(), this.getEUCapacity()); + } + return 0L; + } + + + + + + + + + + @Override + public long getStoredSteam() { + if (this.canAccessData()) { + return Math.min(this.getSteamVar(), this.getSteamCapacity()); + } + return 0L; + } + + @Override + public final TileEntity getTileEntity(final int aX, final int aY, final int aZ) { + if (this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ)) { + return null; + } + return this.worldObj.getTileEntity(aX, aY, aZ); + } + + public final TileEntity getTileEntityAtSide(final byte aSide) { + if (aSide < 0 || aSide >= 6 || this.mBufferedTileEntities[aSide] == this) { + return null; + } + final int tX = this.getOffsetX(aSide, 1); + final int tY = this.getOffsetY(aSide, 1); + final int tZ = this.getOffsetZ(aSide, 1); + if (this.crossedChunkBorder(tX, tZ)) { + this.mBufferedTileEntities[aSide] = null; + if (this.ignoreUnloadedChunks && !this.worldObj.blockExists(tX, tY, tZ)) { + return null; + } + } + if (this.mBufferedTileEntities[aSide] == null) { + this.mBufferedTileEntities[aSide] = this.worldObj.getTileEntity(tX, tY, tZ); + if (this.mBufferedTileEntities[aSide] == null) { + this.mBufferedTileEntities[aSide] = this; + return null; + } + return this.mBufferedTileEntities[aSide]; + } else { + if (this.mBufferedTileEntities[aSide].isInvalid()) { + this.mBufferedTileEntities[aSide] = null; + return this.getTileEntityAtSide(aSide); + } + if (this.mBufferedTileEntities[aSide].xCoord == tX && this.mBufferedTileEntities[aSide].yCoord == tY + && this.mBufferedTileEntities[aSide].zCoord == tZ) { + return this.mBufferedTileEntities[aSide]; + } + return null; + } + } + + @Override + public final TileEntity getTileEntityAtSideAndDistance(final byte aSide, final int aDistance) { + if (aDistance == 1) { + return this.getTileEntityAtSide(aSide); + } + return this.getTileEntity(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance), + this.getOffsetZ(aSide, aDistance)); + } + + + + + + + + + + + @Override + public final TileEntity getTileEntityOffset(final int aX, final int aY, final int aZ) { + return this.getTileEntity(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); + } + + @Override + public long getUniversalEnergyCapacity() { + return 0; + } + + @Override + public long getUniversalEnergyStored() { + return 0; + } + + @Override + public World getWorld() { + return this.getWorldObj(); + } + + + + + + + @Override + public int getXCoord() { + return this.xCoord; + } + + + + + + @Override + public short getYCoord() { + return (short) this.yCoord; + } + + @Override + public int getZCoord() { + return this.zCoord; + } + + public boolean hasEnoughEnergy() { + return (this.getStoredEU() > 0 ? (mHasEnoughEnergy = true) : (mHasEnoughEnergy = false)); + } + + + + + @Override + public boolean increaseStoredEnergyUnits(final long aEnergy, final boolean aIgnoreTooMuchEnergy) { + if (!this.canAccessData()) { + return false; + } + if (this.getStoredEU() < this.getEUCapacity() || aIgnoreTooMuchEnergy) { + this.setStoredEU(this.getEUVar() + aEnergy); + return true; + } + return false; + } + + @Override + public boolean increaseStoredSteam(final long aEnergy, final boolean aIgnoreTooMuchEnergy) { + if (!this.canAccessData()) { + return false; + } + if (this.getSteamVar() < this.getSteamCapacity() || aIgnoreTooMuchEnergy) { + this.setStoredSteam(this.getSteamVar() + aEnergy); + return true; + } + return false; + } + + public long injectEnergyUnits(final byte aSide, final long aVoltage, long aAmperage) { + if (!this.canAccessData() || !this.isElectric() || !this.inputEnergyFrom(aSide) + || aAmperage <= 0L || aVoltage <= 0L || this.getStoredEU() >= this.getEUCapacity() + || this.maxAmperesIn() <= this.mAcceptedAmperes) { + return 0L; + } + if (aVoltage > this.getInputVoltage()) { + this.doExplosion(aVoltage); + return 0L; + } + if (this.increaseStoredEnergyUnits(aVoltage + * (aAmperage = Math.min(aAmperage, Math.min(this.maxAmperesIn() - this.mAcceptedAmperes, + 1L + (this.getEUCapacity() - this.getStoredEU()) / aVoltage))), + true)) { + final int[] mAverageEUInput = this.mAverageEUInput; + final int mAverageEUInputIndex = this.mAverageEUInputIndex; + mAverageEUInput[mAverageEUInputIndex] += (int) (aVoltage * aAmperage); + this.mAcceptedAmperes += aAmperage; + return aAmperage; + } + return 0L; + } + + @Override + public boolean injectRotationalEnergy(byte p0, long p1, long p2) { + return false; + } + + @Override + public boolean inputEnergyFrom(final byte aSide) { + if (aSide == 6) { + return true; + } + if (this.isServerSide()) { + return aSide >= 0 && aSide < 6 && this.mActiveEUInputs[aSide] && !this.mReleaseEnergy; + } + return this.isEnergyInputSide(aSide); + } + + + public final boolean isClientSide() { + return this.worldObj.isRemote; + } + + @Override + public boolean isDead() { + return this.isDead; + } + + private boolean isElectric() { + return true; + } + + private boolean isEnergyInputSide(final byte aSide) { + if (aSide >= 0 && aSide < 6) { + if (this.isInvalid() || this.mReleaseEnergy) { + return false; + } + if (this.canAccessData() && this.isElectric() && this.isEnetInput()) { + return this.isInputFacing(aSide); + } + } + return false; + } + + private boolean isEnergyOutputSide(final byte aSide) { + if (aSide >= 0 && aSide < 6) { + if (this.isInvalid() || this.mReleaseEnergy) { + return this.mReleaseEnergy; + } + if (this.canAccessData() && this.isElectric() && this.isEnetOutput()) { + return this.isOutputFacing(aSide); + } + } + return false; + } + + public boolean isEnetInput() { + return false; + } + + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isGivingInformation() { + return this.canAccessData() && this.isGivingInformation(); + } + + public boolean isInputFacing(final byte aSide) { + return false; + } + + + + + @Override + public boolean isInvalidTileEntity() { + return isDead() ? true : false; + } + + public boolean isOutputFacing(final byte aSide) { + return false; + } + + public final boolean isServerSide() { + return !this.worldObj.isRemote; + } + + public boolean isUniversalEnergyStored(final long aEnergyAmount) { + return this.getUniversalEnergyStored() >= aEnergyAmount || (this.mHasEnoughEnergy = false); + } + + @Override + public boolean isValidFacing(final byte aSide) { + return this.canAccessData(); + } + + public long maxAmperesIn() { + return 1L; + } + + public long maxAmperesOut() { + return 1L; + } + + public long maxEUInput() { + return 0L; + } + + public long maxEUOutput() { + return 0L; + } + + public long maxEUStore() { + return 0L; + } + + public long maxSteamStore() { + return 256000L; + } + + public final void onAdjacentBlockChange(final int aX, final int aY, final int aZ) { + this.clearNullMarkersFromTileEntityBuffer(); + } + + @Override + public boolean outputsEnergyTo(final byte aSide) { + if (aSide == 6) { + return true; + } + if (this.isServerSide()) { + if (aSide < 0 || aSide >= 6 || !this.mActiveEUOutputs[aSide]) { + if (!this.mReleaseEnergy) { + return false; + } + } + return true; + } + return this.isEnergyOutputSide(aSide); + } + + public final void sendBlockEvent(final byte aID, final byte aValue) { + GT_Values.NW.sendPacketToAllPlayersInRange(this.worldObj, + (GT_Packet) new GT_Packet_Block_Event(this.xCoord, (short) this.yCoord, this.zCoord, aID, aValue), + this.xCoord, this.zCoord); + } + + public void setEUVar(final long aEnergy) { + mStoredEnergy = aEnergy; + } + + @Override + public void setFrontFacing(byte aFacing) { + if (this.isValidFacing(aFacing)) { + this.mFacing = aFacing; + //this.onFacingChange(); + //this.onMachineBlockUpdate(); + } + } + + public void setSteamVar(final long aSteam) { + mStoredSteam = aSteam; + } + + public boolean setStoredEU(long aEnergy) { + if (!this.canAccessData()) { + return false; + } + if (aEnergy < 0L) { + aEnergy = 0L; + } + this.setEUVar(aEnergy); + return true; + } + + public boolean setStoredSteam(long aEnergy) { + if (!this.canAccessData()) { + return false; + } + if (aEnergy < 0L) { + aEnergy = 0L; + } + this.setSteamVar(aEnergy); + return true; + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + // TODO Auto-generated method stub + super.writeToNBT(nbt); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + // TODO Auto-generated method stub + super.readFromNBT(nbt); + } + + + + + @Override + public boolean onPreTick() { + return onPreTick(this, this.mTickTimer); + } + + @Override + public boolean onTick() { + return onTick(this, this.mTickTimer); + } + + @Override + public boolean onPostTick() { + return onPostTick(this, this.mTickTimer); + } + + @Override + public boolean onPreTick(TilePoweredGT tilePoweredGT, long mTickTimer2) { + return super.onPreTick(); + } + + @Override + public boolean onTick(TilePoweredGT iGregTechTileEntity, long mTickTimer2) { + return super.onTick(); + } + + @Override + public boolean onPostTick(TilePoweredGT iGregTechTileEntity, long mTickTimer2) { + return super.onPostTick(); + } + + @Override + public void markDirty() { + super.markDirty(); + } + + @Override + public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) { + // TODO Auto-generated method stub + return super.receiveClientEvent(p_145842_1_, p_145842_2_); + } + + @Override + public void onChunkUnload() { + this.clearNullMarkersFromTileEntityBuffer(); + super.onChunkUnload(); + this.isDead = true; + } + + + public void updateEntity() { + super.updateEntity(); + this.isDead = false; + + this.mRunningThroughTick = true; + long tTime = System.currentTimeMillis(); + int tCode = 0; + final boolean aSideServer = this.isServerSide(); + final boolean aSideClient = this.isClientSide(); + /*try { + for (tCode = 0; this.hasValidMetaTileEntity() && tCode >= 0; tCode = -1) { + Label_1743 : { + switch (tCode) { + case 0 : { + ++tCode; + if (this.mTickTimer++ != 0L) { + break Label_1743; + } + this.oX = this.xCoord; + this.oY = this.yCoord; + this.oZ = this.zCoord; + + this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, + (TileEntity) this); + this.onFirstTick(this); + if (!this.hasValidMetaTileEntity()) { + this.mRunningThroughTick = false; + return; + } + break Label_1743; + } + case 1 : { + ++tCode; + if (!aSideClient) { + break Label_1743; + } + if (this.mNeedsUpdate) { + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + this.mNeedsUpdate = false; + } + break Label_1743; + } + case 2 : + case 3 : + case 4 : + case 5 : + case 6 : + case 7 : { + if (aSideServer && this.mTickTimer > 10L) { + for (byte i = (byte) (tCode - 2); i < 6; ++i) { + + } + } + } + case 8 : { + tCode = 9; + if (aSideServer) { + if (++this.mAverageEUInputIndex >= this.mAverageEUInput.length) { + this.mAverageEUInputIndex = 0; + } + if (++this.mAverageEUOutputIndex >= this.mAverageEUOutput.length) { + this.mAverageEUOutputIndex = 0; + } + this.mAverageEUInput[this.mAverageEUInputIndex] = 0; + this.mAverageEUOutput[this.mAverageEUOutputIndex] = 0; + } + } + case 9 : { + ++tCode; + this.onPreTick(this, this.mTickTimer); + if (!this.hasValidMetaTileEntity()) { + this.mRunningThroughTick = false; + return; + } + } + case 10 : { + ++tCode; + if (!aSideServer) { + break Label_1743; + } + + if (this.xCoord != this.oX || this.yCoord != this.oY || this.zCoord != this.oZ) { + this.oX = this.xCoord; + this.oY = this.yCoord; + this.oZ = this.zCoord; + this.issueClientUpdate(); + this.clearTileEntityBuffer(); + } + if (this.mFacing != this.oFacing) { + this.oFacing = this.mFacing; + this.issueBlockUpdate(); + } + if (this.mTickTimer > 20L && this.isElectric()) { + this.mAcceptedAmperes = 0L; + if (this.getOutputVoltage() != this.oOutput) { + this.oOutput = this.getOutputVoltage(); + } + if (this.isEnetOutput() || this.isEnetInput()) { + for (byte i = 0; i < 6; ++i) { + boolean temp = this.isEnergyInputSide(i); + if (temp != this.mActiveEUInputs[i]) { + this.mActiveEUInputs[i] = temp; + } + temp = this.isEnergyOutputSide(i); + if (temp != this.mActiveEUOutputs[i]) { + this.mActiveEUOutputs[i] = temp; + } + } + } + if (this.isEnetOutput() && this.oOutput > 0L) { + final long tOutputVoltage = Math.max(this.oOutput, + this.oOutput + (1 << GT_Utility.getTier(this.oOutput))); + final long tUsableAmperage = Math.min(this.getOutputAmperage(), + (this.getStoredEU() - this.getMinimumStoredEU()) + / tOutputVoltage); + if (tUsableAmperage > 0L) { + final long tEU = tOutputVoltage * IEnergyConnected.Util.emitEnergyToNetwork( + this.oOutput, tUsableAmperage, (IEnergyConnected) this); + final int[] mAverageEUOutput = this.mAverageEUOutput; + final int mAverageEUOutputIndex = this.mAverageEUOutputIndex; + mAverageEUOutput[mAverageEUOutputIndex] += (int) tEU; + this.decreaseStoredEU(tEU, true); + } + } + if (this.getEUCapacity() > 0L) { + if (GregTech_API.sMachineFireExplosions && this.getRandomNumber(1000) == 0) { + final Block tBlock = this.getBlockAtSide((byte) this.getRandomNumber(6)); + if (tBlock instanceof BlockFire) { + this.doEnergyExplosion(); + } + } + if (!this.hasValidMetaTileEntity()) { + this.mRunningThroughTick = false; + return; + } + } + } + if (!this.hasValidMetaTileEntity()) { + this.mRunningThroughTick = false; + return; + } + break Label_1743; + } + case 13 : { + ++tCode; + this.updateStatus(); + if (!this.hasValidMetaTileEntity()) { + this.mRunningThroughTick = false; + return; + } + } + case 14 : { + ++tCode; + this.onPostTick((IGregTechTileEntity) this, this.mTickTimer); + if (!this.hasValidMetaTileEntity()) { + this.mRunningThroughTick = false; + return; + } + } + case 15 : { + ++tCode; + if (!aSideServer) { + break; + } + if (this.mTickTimer % 10L == 0L && this.mSendClientData) { + final IGT_NetworkHandler nw = GT_Values.NW; + final World worldObj = this.worldObj; + final int xCoord = this.xCoord; + final short n = (short) this.yCoord; + final int zCoord = this.zCoord; + final short mid = this.mID; + final int n2 = this.mCoverSides[0]; + final int n3 = this.mCoverSides[1]; + final int n4 = this.mCoverSides[2]; + final int n5 = this.mCoverSides[3]; + final int n6 = this.mCoverSides[4]; + final int n7 = this.mCoverSides[5]; + final byte oTextureData = (byte) ((this.mFacing & 0x7) | (this.mActive ? 8 : 0) + | (this.mRedstone ? 16 : 0) | (this.mLockUpgrade ? 32 : 0)); + this.oTextureData = oTextureData; + final byte oTexturePage = (byte) ((this.hasValidMetaTileEntity() + && this.mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) + ? ((GT_MetaTileEntity_Hatch) this.mMetaTileEntity).getTexturePage() + : 0); + this.oTexturePage = oTexturePage; + final byte oUpdateData = (byte) (this.hasValidMetaTileEntity() + ? this.mMetaTileEntity.getUpdateData() + : 0); + this.oUpdateData = oUpdateData; + final byte oRedstoneData = (byte) (((this.mSidedRedstone[0] > 0) ? 1 : 0) + | ((this.mSidedRedstone[1] > 0) ? 2 : 0) + | ((this.mSidedRedstone[2] > 0) ? 4 : 0) + | ((this.mSidedRedstone[3] > 0) ? 8 : 0) + | ((this.mSidedRedstone[4] > 0) ? 16 : 0) + | ((this.mSidedRedstone[5] > 0) ? 32 : 0)); + this.oRedstoneData = oRedstoneData; + final byte mColor = this.mColor; + this.oColor = mColor; + nw.sendPacketToAllPlayersInRange(worldObj, + (GT_Packet) new GT_Packet_TileEntity(xCoord, n, zCoord, mid, n2, n3, n4, n5, n6, + n7, oTextureData, oTexturePage, oUpdateData, oRedstoneData, mColor), + this.xCoord, this.zCoord); + this.mSendClientData = false; + } + if (this.mTickTimer > 10L) { + byte tData = (byte) ((this.mFacing & 0x7) | (this.mActive ? 8 : 0) + | (this.mRedstone ? 16 : 0) | (this.mLockUpgrade ? 32 : 0)); + if (tData != this.oTextureData) { + this.sendBlockEvent((byte) 0, this.oTextureData = tData); + } + tData = this.mMetaTileEntity.getUpdateData(); + if (tData != this.oUpdateData) { + this.sendBlockEvent((byte) 1, this.oUpdateData = tData); + } + if (this.mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { + tData = ((GT_MetaTileEntity_Hatch) this.mMetaTileEntity).getTexturePage(); + if (tData != this.oTexturePage) { + final byte b = 1; + final byte oTexturePage2 = tData; + this.oTexturePage = oTexturePage2; + this.sendBlockEvent(b, (byte) (oTexturePage2 | 0x80)); + } + } + if (this.mColor != this.oColor) { + this.sendBlockEvent((byte) 2, this.oColor = this.mColor); + } + tData = (byte) (((this.mSidedRedstone[0] > 0) ? 1 : 0) + | ((this.mSidedRedstone[1] > 0) ? 2 : 0) + | ((this.mSidedRedstone[2] > 0) ? 4 : 0) + | ((this.mSidedRedstone[3] > 0) ? 8 : 0) + | ((this.mSidedRedstone[4] > 0) ? 16 : 0) + | ((this.mSidedRedstone[5] > 0) ? 32 : 0)); + if (tData != this.oRedstoneData) { + this.sendBlockEvent((byte) 3, this.oRedstoneData = tData); + } + if (this.mLightValue != this.oLightValue) { + this.worldObj.setLightValue(EnumSkyBlock.Block, this.xCoord, this.yCoord, + this.zCoord, (int) this.mLightValue); + this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, + this.zCoord); + this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord + 1, this.yCoord, + this.zCoord); + this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord - 1, this.yCoord, + this.zCoord); + this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord + 1, + this.zCoord); + this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord - 1, + this.zCoord); + this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, + this.zCoord + 1); + this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, + this.zCoord - 1); + this.issueTextureUpdate(); + this.sendBlockEvent((byte) 7, this.oLightValue = this.mLightValue); + } + } + if (this.mNeedsBlockUpdate) { + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, + this.getBlockOffset(0, 0, 0)); + this.mNeedsBlockUpdate = false; + break; + } + break; + } + } + } + } + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); + } + if (aSideServer && this.hasValidMetaTileEntity()) { + tTime = System.currentTimeMillis() - tTime; + if (this.mTimeStatistics.length > 0) { + this.mTimeStatistics[this.mTimeStatisticsIndex = (this.mTimeStatisticsIndex + 1) + % this.mTimeStatistics.length] = (int) tTime; + } + if (tTime > 0L && tTime > GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING && this.mTickTimer > 1000L + && this.getMetaTileEntity().doTickProfilingMessageDuringThisTick() + && this.mLagWarningCount++ < 10) { + System.out.println("WARNING: Possible Lag Source at [" + this.xCoord + ", " + this.yCoord + ", " + + this.zCoord + "] in Dimension " + this.worldObj.provider.dimensionId + " with " + tTime + + "ms caused by an instance of " + this.getMetaTileEntity().getClass()); + } + } + final boolean mWorkUpdate = false; + this.mRunningThroughTick = mWorkUpdate; + this.mInventoryChanged = mWorkUpdate; + this.mWorkUpdate = mWorkUpdate;*/ + } + + private void onFirstTick(TilePoweredGT tilePoweredGT) { + // TODO Auto-generated method stub + + } + + private boolean hasValidMetaTileEntity() { + return Utils.invertBoolean(isDead()); + } + + public void issueBlockUpdate() { + this.mNeedsBlockUpdate = true; + } + + public void issueClientUpdate() { + this.mSendClientData = true; + } + + public Packet getDescriptionPacket() { + this.issueClientUpdate(); + return null; + } + +} 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<V> implements Iterable<V>, Cloneable, Serializable { - - /** - * The Internal Map - */ - private Map<Integer, V> mInternalMap = new HashMap<Integer, V>(); - - /** - * The Internal ID - */ - private int mInternalID = 0; - private static final long serialVersionUID = 3771412318075131790L; - - @Override - public Iterator<V> 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<V> 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 b625ebec54..0000000000 --- a/src/Java/gtPlusPlus/core/util/array/BlockPos.java +++ /dev/null @@ -1,25 +0,0 @@ -package gtPlusPlus.core.util.array; - -public class BlockPos { - - 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<K,V> 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<K,V,C,R> { - - 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<K,V,C> { - - 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/locale/LocaleUtils.java b/src/Java/gtPlusPlus/core/util/locale/LocaleUtils.java new file mode 100644 index 0000000000..aea38d341e --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/locale/LocaleUtils.java @@ -0,0 +1,91 @@ +package gtPlusPlus.core.util.locale; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.registry.GameData; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.ItemUtils; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class LocaleUtils { + + public static boolean GenerateFakeLocaleFile() { + for (ModContainer modcontainer : Loader.instance().getModList()){ + if (modcontainer.getModId().toLowerCase().equals("miscutils")) { + String S = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; + writeToFile(S); + dumpItemsAndBlocksForModContainer(modcontainer); + } + } + return true; + } + + public static boolean dumpItemsAndBlocksForModContainer(ModContainer mod) { + writeToFile("Dumping Items from "+mod.getModId()+"."); + for (Object C : GameData.getItemRegistry()) { + + try { + + if (C != null) { + if (C instanceof Item) { + Item R = (Item) C; + ItemStack IS = ItemUtils.getSimpleStack(R); + String modid = ItemUtils.getModId(IS); + if (modid.equals("miscutils") || modid.equals("ToxicEverglades")) { + String S = "["+modid+"] "+IS.getUnlocalizedName()+".name="; + writeToFile(S); + } + } + } + + } + catch (Throwable T) {} + + } + writeToFile("Dumping Blocks from "+mod.getModId()+"."); + for (Object B : GameData.getBlockRegistry()) { + + try { + + if (B != null) { + if (B instanceof Block) { + Block R = (Block) B; + ItemStack IS = ItemUtils.getSimpleStack(R); + String modid = ItemUtils.getModId(IS); + if (modid.equals("miscutils") || modid.equals("ToxicEverglades")) { + String S = "["+modid+"] "+IS.getUnlocalizedName()+".name="; + writeToFile(S); + } + } + } + + } + catch (Throwable T) {} + + } + + + return true; + } + + public static void writeToFile(String S) { + try { + File F = new File(Utils.getMcDir(), "config/GTplusplus/en_US.lang"); + BufferedWriter writer; + writer = new BufferedWriter(new FileWriter(F, true)); + writer.write(S); + writer.newLine(); + writer.close(); + } + catch (IOException e) {} + } + + +} 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/reflect/AddGregtechRecipe.java b/src/Java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java index 04a59e7f7d..cabd1f086c 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java +++ b/src/Java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java @@ -78,7 +78,7 @@ public final class AddGregtechRecipe { FluidStack[] aFluidInputs, ItemStack aOutput, int aDuration, int aEUt){ -/* + /* try { IGT_RecipeAdder IGT_RecipeAdder = GT_Values.RA; if (IGT_RecipeAdder != null){ @@ -95,7 +95,7 @@ public final class AddGregtechRecipe { } //Utils.LOG_INFO("==============================================="); } - + try { Method testRA = GT_Values.RA.getClass().getMethod("addAssemblylineRecipe", GT_Values.RA.getClass(), aResearchItem.getClass(), int.class, aInputs.getClass(), aFluidInputs.getClass(), aOutput.getClass(), int.class, int.class); testRA.invoke(aResearchItem, aResearchTime, aInputs, aFluidInputs, aOutput, aDuration, aEUt); @@ -103,7 +103,7 @@ public final class AddGregtechRecipe { catch (Throwable masndj){ masndj.printStackTrace(); } - + Method addRecipe = classRA.getDeclaredMethod( "addAssemblylineRecipe", @@ -125,7 +125,7 @@ public final class AddGregtechRecipe { return false; } Utils.LOG_INFO("[Assembly Line] - Failed to add recipe. Research: "+aResearchItem.getDisplayName()+" | Result: "+aOutput.getDisplayName()); - */return false; + */return false; } public static boolean addCircuitAssemblerRecipe( @@ -203,4 +203,39 @@ public final class AddGregtechRecipe { return false; } + + public static boolean addChemicalRecipeForBasicMachineOnly(final ItemStack p0, final ItemStack p1, final FluidStack p2, final FluidStack p3, final ItemStack p4, final ItemStack p5, final int p6, final int p7){ + + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + try { + IGT_RecipeAdder IGT_RecipeAdder = GT_Values.RA; + if (IGT_RecipeAdder != null){ + Class<? extends IGT_RecipeAdder> classRA = IGT_RecipeAdder.getClass(); + //final ItemStack p0, final ItemStack p1, final FluidStack p2, final FluidStack p3, final ItemStack p4, final ItemStack p5, final int p6, final int p7 + Method addRecipe = classRA.getMethod("addChemicalRecipeForBasicMachineOnly", ItemStack.class, ItemStack.class, FluidStack.class, FluidStack.class, ItemStack.class, ItemStack.class, int.class, int.class); + if (addRecipe != null){ + return (boolean) addRecipe.invoke(IGT_RecipeAdder, p0, p1, p2, p3, p4, p5, p6, p7); + } + } + } + catch (SecurityException | NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + + } + } + + return GT_Values.RA.addChemicalRecipe( + p0, + p1, + p2, + p3, + p4, + p5, + p6, + p7); + + } + + + + }
\ No newline at end of file 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<K,V,C,R> { 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; |