aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core
diff options
context:
space:
mode:
authorJordan Byrne <draknyte1@hotmail.com>2018-02-22 15:46:32 +1000
committerJordan Byrne <draknyte1@hotmail.com>2018-02-22 15:46:32 +1000
commit6ecc76786555e2aaa7b1e9f5c65b9619a9d93239 (patch)
treea4b2c766270fb54ca003e756f26ea8ae94f8a852 /src/Java/gtPlusPlus/core
parent24905c16017decae4ee60ce4128b6d26de66baf5 (diff)
downloadGT5-Unofficial-6ecc76786555e2aaa7b1e9f5c65b9619a9d93239.tar.gz
GT5-Unofficial-6ecc76786555e2aaa7b1e9f5c65b9619a9d93239.tar.bz2
GT5-Unofficial-6ecc76786555e2aaa7b1e9f5c65b9619a9d93239.zip
+ Added a debug item for linking blocks.
% More project clean-up. % Made fish trap 2x slower. $ Fixed issue with fish trap name. $ Fixed .08 issue getting powder barrels.
Diffstat (limited to 'src/Java/gtPlusPlus/core')
-rw-r--r--src/Java/gtPlusPlus/core/handler/analytics/SegmentAnalytics.java2
-rw-r--r--src/Java/gtPlusPlus/core/item/ModItems.java3
-rw-r--r--src/Java/gtPlusPlus/core/item/tool/misc/ConnectedBlockFinder.java150
-rw-r--r--src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java4
-rw-r--r--src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java4
-rw-r--r--src/Java/gtPlusPlus/core/recipe/common/CI.java89
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java8
-rw-r--r--src/Java/gtPlusPlus/core/util/UtilsText.java18
-rw-r--r--src/Java/gtPlusPlus/core/util/data/EnumUtils.java9
-rw-r--r--src/Java/gtPlusPlus/core/util/data/StringUtils.java16
-rw-r--r--src/Java/gtPlusPlus/core/util/data/UUIDGenerator.java451
-rw-r--r--src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java15
-rw-r--r--src/Java/gtPlusPlus/core/util/minecraft/MiningUtils.java (renamed from src/Java/gtPlusPlus/core/util/minecraft/UtilsMining.java)2
13 files changed, 246 insertions, 525 deletions
diff --git a/src/Java/gtPlusPlus/core/handler/analytics/SegmentAnalytics.java b/src/Java/gtPlusPlus/core/handler/analytics/SegmentAnalytics.java
index 4d2d2d4a6e..28d3266407 100644
--- a/src/Java/gtPlusPlus/core/handler/analytics/SegmentAnalytics.java
+++ b/src/Java/gtPlusPlus/core/handler/analytics/SegmentAnalytics.java
@@ -12,10 +12,10 @@ import com.mojang.authlib.GameProfile;
import com.segment.analytics.Analytics;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.random.UUIDGenerator;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.lib.LoadedMods;
import gtPlusPlus.core.util.Utils;
-import gtPlusPlus.core.util.data.UUIDGenerator;
import gtPlusPlus.core.util.data.UUIDUtils;
import gtPlusPlus.core.util.minecraft.PlayerUtils;
import ic2.core.IC2;
diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java
index ce2c49bead..50ff8c061b 100644
--- a/src/Java/gtPlusPlus/core/item/ModItems.java
+++ b/src/Java/gtPlusPlus/core/item/ModItems.java
@@ -50,6 +50,7 @@ import gtPlusPlus.core.item.general.throwables.ItemHydrofluoricAcidPotion;
import gtPlusPlus.core.item.general.throwables.ItemSulfuricAcidPotion;
import gtPlusPlus.core.item.init.ItemsFoods;
import gtPlusPlus.core.item.init.ItemsMultiTools;
+import gtPlusPlus.core.item.tool.misc.ConnectedBlockFinder;
import gtPlusPlus.core.item.tool.misc.SandstoneHammer;
import gtPlusPlus.core.item.tool.staballoy.MultiPickaxeBase;
import gtPlusPlus.core.item.tool.staballoy.MultiSpadeBase;
@@ -699,6 +700,8 @@ public final class ModItems {
//Chemistry
CoalTar.run();
+
+ new ConnectedBlockFinder();
//Misc Items
@SuppressWarnings("unused")
diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/ConnectedBlockFinder.java b/src/Java/gtPlusPlus/core/item/tool/misc/ConnectedBlockFinder.java
new file mode 100644
index 0000000000..f0cc8c7344
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/item/tool/misc/ConnectedBlockFinder.java
@@ -0,0 +1,150 @@
+package gtPlusPlus.core.item.tool.misc;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gtPlusPlus.api.objects.minecraft.BlockPos;
+import gtPlusPlus.core.creative.AddToCreativeTab;
+import gtPlusPlus.core.item.base.BaseItemWithDamageValue;
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.world.World;
+
+public class ConnectedBlockFinder extends BaseItemWithDamageValue{
+
+ public ConnectedBlockFinder() {
+ super("item.test.connector");
+ this.setTextureName("stick");
+ this.setMaxStackSize(1);
+ this.setMaxDamage(10000);
+ setCreativeTab(AddToCreativeTab.tabTools);
+ GameRegistry.registerItem(this, getUnlocalizedName());
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) {
+ list.add(EnumChatFormatting.GRAY+"Finds connected blocks, turns them to Glass once found.");
+ super.addInformation(stack, aPlayer, list, bool);
+ }
+
+ @Override
+ public boolean doesContainerItemLeaveCraftingGrid(final ItemStack itemStack){
+ return false;
+ }
+
+ @Override
+ public boolean getShareTag(){
+ return true;
+ }
+
+ @Override
+ public boolean hasContainerItem(final ItemStack itemStack){
+ return true;
+ }
+ @Override
+ public ItemStack getContainerItem(final ItemStack itemStack){
+ return itemStack;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public EnumRarity getRarity(final ItemStack par1ItemStack){
+ return EnumRarity.uncommon;
+ }
+
+ @Override
+ public boolean hasEffect(final ItemStack par1ItemStack){
+ return false;
+ }
+
+
+ @Override
+ public boolean onItemUse(
+ ItemStack stack, EntityPlayer player, World world,
+ int x, int y, int z, int side,
+ float hitX, float hitY, float hitZ) {
+
+ BlockPos mStartPoint = new BlockPos(x,y,z);
+
+ Block mBlockType = world.getBlock(x, y, z);
+ int mBlockMeta = mBlockType.getDamageValue(world, x, y, z);
+
+ Set<BlockPos> mTotalIndex = new HashSet<BlockPos>();
+ Set<BlockPos> mFirstSearch = new HashSet<BlockPos>();
+ Set<BlockPos> mSearch_A = new HashSet<BlockPos>();
+ Set<BlockPos> mSearch_B = new HashSet<BlockPos>();
+ Set<BlockPos> mSearch_C = new HashSet<BlockPos>();
+
+ for (BlockPos b : mStartPoint.getSurroundingBlocks().values()) {
+ if (world.getBlock(b.xPos, b.yPos, b.zPos) == mBlockType) {
+ if (mBlockType.getDamageValue(world, b.xPos, b.yPos, b.zPos) == mBlockMeta) {
+ if (mFirstSearch.add(b)) {
+ if (mTotalIndex.add(b)) {
+ world.setBlock(b.xPos, b.yPos, b.zPos, Blocks.emerald_ore);
+ }
+ }
+ }
+ }
+ }
+
+ for (BlockPos b : mFirstSearch) {
+ if (world.getBlock(b.xPos, b.yPos, b.zPos) == mBlockType) {
+ if (mBlockType.getDamageValue(world, b.xPos, b.yPos, b.zPos) == mBlockMeta) {
+ if (mSearch_A.add(b)) {
+ if (mTotalIndex.add(b)) {
+ world.setBlock(b.xPos, b.yPos, b.zPos, Blocks.emerald_ore);
+ }
+ }
+ }
+ }
+ }
+
+ for (BlockPos b : mSearch_A) {
+ if (world.getBlock(b.xPos, b.yPos, b.zPos) == mBlockType) {
+ if (mBlockType.getDamageValue(world, b.xPos, b.yPos, b.zPos) == mBlockMeta) {
+ if (mSearch_B.add(b)) {
+ if (mTotalIndex.add(b)) {
+ world.setBlock(b.xPos, b.yPos, b.zPos, Blocks.emerald_ore);
+ }
+ }
+ }
+ }
+ }
+
+ for (BlockPos b : mSearch_B) {
+ if (world.getBlock(b.xPos, b.yPos, b.zPos) == mBlockType) {
+ if (mBlockType.getDamageValue(world, b.xPos, b.yPos, b.zPos) == mBlockMeta) {
+ if (mSearch_C.add(b)) {
+ if (mTotalIndex.add(b)) {
+ world.setBlock(b.xPos, b.yPos, b.zPos, Blocks.emerald_ore);
+ }
+ }
+ }
+ }
+ }
+
+ return super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ);
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) {
+ // TODO Auto-generated method stub
+ return super.onItemRightClick(p_77659_1_, p_77659_2_, p_77659_3_);
+ }
+
+
+
+
+
+
+
+}
diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java
index 5ad027409b..138015b7cd 100644
--- a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java
+++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java
@@ -6,7 +6,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.lib.CORE;
-import gtPlusPlus.core.util.minecraft.UtilsMining;
+import gtPlusPlus.core.util.minecraft.MiningUtils;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -101,7 +101,7 @@ public class StaballoyPickaxe extends ItemPickaxe{
if (!currentWorld.isRemote){
try {
correctTool = currentBlock.getHarvestTool(0);
- if (UtilsMining.getBlockType(currentBlock, currentWorld, xyz, this.miningLevel) || correctTool.equals("pickaxe") || correctTool.equals("null")){
+ if (MiningUtils.getBlockType(currentBlock, currentWorld, xyz, this.miningLevel) || correctTool.equals("pickaxe") || correctTool.equals("null")){
//Utils.LOG_WARNING(correctTool);
return true;}
} catch (final NullPointerException e){
diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java
index 50a2a48588..067a2ea9bd 100644
--- a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java
+++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java
@@ -6,7 +6,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.lib.CORE;
-import gtPlusPlus.core.util.minecraft.UtilsMining;
+import gtPlusPlus.core.util.minecraft.MiningUtils;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -76,7 +76,7 @@ public class StaballoySpade extends ItemSpade{
//Utils.LOG_WARNING(correctTool);
Logger.WARNING("Tool for Block: "+correctTool+" | Current block: "+currentBlock.getLocalizedName());
- if (UtilsMining.getBlockType(currentBlock, currentWorld, xyz, this.miningLevel) || correctTool.equals("shovel")){
+ if (MiningUtils.getBlockType(currentBlock, currentWorld, xyz, this.miningLevel) || correctTool.equals("shovel")){
return true;}
} catch (final NullPointerException e){
return false;}
diff --git a/src/Java/gtPlusPlus/core/recipe/common/CI.java b/src/Java/gtPlusPlus/core/recipe/common/CI.java
index 250a332f2b..4c7e6e3652 100644
--- a/src/Java/gtPlusPlus/core/recipe/common/CI.java
+++ b/src/Java/gtPlusPlus/core/recipe/common/CI.java
@@ -20,7 +20,7 @@ public class CI {
//null
public static ItemStack _NULL = ItemUtils.getSimpleStack(ModItems.AAA_Broken);
-
+
//bits
public static long bits = GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE
| GT_ModHandler.RecipeBits.BUFFERED;
@@ -154,7 +154,7 @@ public class CI {
public static String[] component_Plate;
public static String[] component_Rod;
public static String[] component_Ingot;
-
+
//Crafting Tools
public static String craftingToolWrench = "craftingToolWrench";
public static String craftingToolHammer_Hard = "craftingToolHardHammer";
@@ -165,7 +165,7 @@ public class CI {
public static String craftingToolCrowbar = "craftingToolCrowbar";
public static String craftingToolWireCutter = "craftingToolWirecutter";
public static String craftingToolSolderingIron = "craftingToolSolderingIron";
-
+
//Explosives
public static ItemStack explosivePowderKeg;
public static ItemStack explosiveTNT;
@@ -228,7 +228,7 @@ public class CI {
circuitTier7 = getTieredCircuit(7);
circuitTier8 = getTieredCircuit(8);
circuitTier9 = getTieredCircuit(9);
-
+
}
public static Object getTieredCircuit(int tier){
@@ -272,11 +272,11 @@ public class CI {
}
return _NULL;
}
-
+
public static ItemStack[] getAllCircuitsOfTier(int tier){
return ItemUtils.getStackOfAllOreDictGroup(getTieredCircuitOreDictName(tier));
}
-
+
public static String getTieredCircuitOreDictName(int tier){
if (tier == 0){
return "circuitPrimitive";
@@ -389,7 +389,7 @@ public class CI {
return ItemList.Tool_DataOrb.get(1);
}
}
-
+
public static final ItemStack getTieredMachineHull(int tier){
if (tier == 0){
return machineHull_ULV;
@@ -422,7 +422,7 @@ public class CI {
return machineHull_MAX;
}
}
-
+
public static final ItemStack getTieredMachineCasing(int tier){
if (tier == 0){
return machineCasing_ULV;
@@ -455,50 +455,51 @@ public class CI {
return machineCasing_MAX;
}
}
-
+
public static void init() {
//Set Explosives
- if (ItemList.valueOf("Block_Powderbarrel") != null){
- explosivePowderKeg = ItemList.valueOf("Block_Powderbarrel").get(1);
- }
- else {
- explosivePowderKeg = ItemUtils.getSimpleStack(Items.gunpowder);
+ try {
+ if (ItemList.valueOf("Block_Powderbarrel") != null){
+ explosivePowderKeg = ItemList.valueOf("Block_Powderbarrel").get(1).copy();
+ }
+ } catch (java.lang.IllegalArgumentException Y) {
+ explosivePowderKeg = ItemUtils.getSimpleStack(Items.gunpowder).copy();
}
- explosiveTNT = ItemUtils.getSimpleStack(Blocks.tnt);
+ explosiveTNT = ItemUtils.getSimpleStack(Blocks.tnt).copy();
explosiveITNT = Ic2Items.industrialTnt.copy();
-
+
//Machine Casings
- machineCasing_ULV = ItemList.Casing_ULV.get(1);
- machineCasing_LV = ItemList.Casing_LV.get(1);
- machineCasing_MV = ItemList.Casing_MV.get(1);
- machineCasing_HV = ItemList.Casing_HV.get(1);
- machineCasing_EV = ItemList.Casing_EV.get(1);
- machineCasing_IV = ItemList.Casing_IV.get(1);
- machineCasing_LuV = ItemList.Casing_LuV.get(1);
- machineCasing_ZPM = ItemList.Casing_ZPM.get(1);
- machineCasing_UV = ItemList.Casing_UV.get(1);
- machineCasing_MAX = ItemList.Casing_MAX.get(1);
+ machineCasing_ULV = ItemList.Casing_ULV.get(1);
+ machineCasing_LV = ItemList.Casing_LV.get(1);
+ machineCasing_MV = ItemList.Casing_MV.get(1);
+ machineCasing_HV = ItemList.Casing_HV.get(1);
+ machineCasing_EV = ItemList.Casing_EV.get(1);
+ machineCasing_IV = ItemList.Casing_IV.get(1);
+ machineCasing_LuV = ItemList.Casing_LuV.get(1);
+ machineCasing_ZPM = ItemList.Casing_ZPM.get(1);
+ machineCasing_UV = ItemList.Casing_UV.get(1);
+ machineCasing_MAX = ItemList.Casing_MAX.get(1);
- //Machine Hulls
- machineHull_ULV = ItemList.Hull_ULV.get(1);
- machineHull_LV = ItemList.Hull_LV.get(1);
- machineHull_MV = ItemList.Hull_MV.get(1);
- machineHull_HV = ItemList.Hull_HV.get(1);
- machineHull_EV = ItemList.Hull_EV.get(1);
- machineHull_IV = ItemList.Hull_IV.get(1);
- machineHull_LuV = ItemList.Hull_LuV.get(1);
- machineHull_ZPM = ItemList.Hull_ZPM.get(1);
- machineHull_UV = ItemList.Hull_UV.get(1);
- machineHull_MAX = ItemList.Hull_MAX.get(1);
+ //Machine Hulls
+ machineHull_ULV = ItemList.Hull_ULV.get(1);
+ machineHull_LV = ItemList.Hull_LV.get(1);
+ machineHull_MV = ItemList.Hull_MV.get(1);
+ machineHull_HV = ItemList.Hull_HV.get(1);
+ machineHull_EV = ItemList.Hull_EV.get(1);
+ machineHull_IV = ItemList.Hull_IV.get(1);
+ machineHull_LuV = ItemList.Hull_LuV.get(1);
+ machineHull_ZPM = ItemList.Hull_ZPM.get(1);
+ machineHull_UV = ItemList.Hull_UV.get(1);
+ machineHull_MAX = ItemList.Hull_MAX.get(1);
- //Gear box Casings
- gearboxCasing_Tier_1 = ItemList.Casing_Gearbox_Bronze.get(1);
- gearboxCasing_Tier_2 = ItemList.Casing_Gearbox_Steel.get(1);
- gearboxCasing_Tier_3 = ItemList.Casing_Gearbox_Titanium.get(1);
- gearboxCasing_Tier_4 = ItemList.Casing_Gearbox_TungstenSteel.get(1);
+ //Gear box Casings
+ gearboxCasing_Tier_1 = ItemList.Casing_Gearbox_Bronze.get(1);
+ gearboxCasing_Tier_2 = ItemList.Casing_Gearbox_Steel.get(1);
+ gearboxCasing_Tier_3 = ItemList.Casing_Gearbox_Titanium.get(1);
+ gearboxCasing_Tier_4 = ItemList.Casing_Gearbox_TungstenSteel.get(1);
- //Machine Components
- LOADER_Machine_Components.initialise();
+ //Machine Components
+ LOADER_Machine_Components.initialise();
}
}
diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java
index 3c4a328599..2461eb16a5 100644
--- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java
+++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java
@@ -243,13 +243,13 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory {
calculateTickrate = 0;
}
else if ((this.waterSides > 2) && (this.waterSides < 4)) {
- calculateTickrate = 3600;
+ calculateTickrate = 4800;
}
else if ((this.waterSides >= 4) && (this.waterSides < 6)) {
- calculateTickrate = 2400;
+ calculateTickrate = 3600;
}
else if (this.waterSides == 6) {
- calculateTickrate = 1200;
+ calculateTickrate = 2400;
}
this.baseTickRate = calculateTickrate;
}
@@ -387,7 +387,7 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory {
@Override
public String getInventoryName() {
- return this.hasCustomInventoryName() ? this.customName : "container.fishrap";
+ return this.hasCustomInventoryName() ? this.customName : "container.fishtrap";
}
@Override
diff --git a/src/Java/gtPlusPlus/core/util/UtilsText.java b/src/Java/gtPlusPlus/core/util/UtilsText.java
deleted file mode 100644
index 9896f2be0c..0000000000
--- a/src/Java/gtPlusPlus/core/util/UtilsText.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package gtPlusPlus.core.util;
-
-public enum UtilsText {
-
- blue('1'), green('2'), teal('3'), maroon('4'), purple('5'), orange('6'), lightGray('7'), darkGray('8'), lightBlue(
- '9'), black('0'), lime('a'), aqua('b'), red('c'), pink('d'), yellow('e'), white('f');
-
- private char colourValue;
-
- private UtilsText(final char value) {
- this.colourValue = value;
- }
-
- public String colour() {
- return "§" + this.colourValue;
- }
-
-}
diff --git a/src/Java/gtPlusPlus/core/util/data/EnumUtils.java b/src/Java/gtPlusPlus/core/util/data/EnumUtils.java
index 22ca73be0b..4a29001a28 100644
--- a/src/Java/gtPlusPlus/core/util/data/EnumUtils.java
+++ b/src/Java/gtPlusPlus/core/util/data/EnumUtils.java
@@ -3,6 +3,8 @@ package gtPlusPlus.core.util.data;
import com.google.common.base.Enums;
import com.google.common.base.Optional;
+import gregtech.api.enums.Materials;
+
public class EnumUtils {
/**
@@ -36,6 +38,13 @@ public class EnumUtils {
name, enumeration.getName()
));
}
+
+ public static Object getValue(Class class1, String materialName, boolean bool) {
+ if (Enum.class.isInstance(class1)){
+ return getValue(class1, materialName);
+ }
+ return null;
+ }
}
diff --git a/src/Java/gtPlusPlus/core/util/data/StringUtils.java b/src/Java/gtPlusPlus/core/util/data/StringUtils.java
index 77b1fc8413..3ad5f3bb8b 100644
--- a/src/Java/gtPlusPlus/core/util/data/StringUtils.java
+++ b/src/Java/gtPlusPlus/core/util/data/StringUtils.java
@@ -94,4 +94,20 @@ public class StringUtils {
return false;
}
+ //Can call this Enum for formatting.
+ public static enum TextUtils {
+ blue('1'), green('2'), teal('3'), maroon('4'), purple('5'), orange('6'), lightGray('7'), darkGray('8'), lightBlue(
+ '9'), black('0'), lime('a'), aqua('b'), red('c'), pink('d'), yellow('e'), white('f');
+
+ private char colourValue;
+ private TextUtils(final char value) {
+ this.colourValue = value;
+ }
+ public String colour() {
+ return getFormatter() + this.colourValue;
+ }
+ private String getFormatter() {
+ return "\u00A7"; // Returns §.
+ }
+ }
}
diff --git a/src/Java/gtPlusPlus/core/util/data/UUIDGenerator.java b/src/Java/gtPlusPlus/core/util/data/UUIDGenerator.java
deleted file mode 100644
index 513468a9f6..0000000000
--- a/src/Java/gtPlusPlus/core/util/data/UUIDGenerator.java
+++ /dev/null
@@ -1,451 +0,0 @@
-package gtPlusPlus.core.util.data;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.util.Random;
-import java.util.UUID;
-
-import gtPlusPlus.api.objects.random.CSPRNG_DO_NOT_USE;
-
-/**
- *
- * Implement modified version of Apache's OpenJPA UUID generator.
- * This UUID generator is paired with a Blum-Blum-Shub random number generator
- * which in itself is seeded by custom SecureRandom.
- *
- * The UUID generator class has been converted from a static factory to an instanced factory.
- *
- */
-
-//========================================= APACHE BLOCK =========================================
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * UUID value generator. Type 1 generator is based on the time-based generator
- * in the Apache Commons Id project: http://jakarta.apache.org/commons/sandbox
- * /id/uuid.html The type 4 generator uses the standard Java UUID generator.
- *
- * The type 1 code has been vastly simplified and modified to replace the
- * ethernet address of the host machine with the IP, since we do not want to
- * require native libs and Java cannot access the MAC address directly.
- *
- * In spirit, implements the IETF UUID draft specification, found here:<br />
- * http://www1.ics.uci.edu/~ejw/authoring/uuid-guid/draft-leach-uuids-guids-01
- * .txt
- *
- * @author Abe White, Kevin Sutter
- * @since 0.3.3
- */
-public class UUIDGenerator {
-
- // supported UUID types
- public static final int TYPE1 = 1;
- public static final int TYPE4 = 4;
- // indexes within the uuid array for certain boundaries
- private static final byte IDX_TIME_HI = 6;
- private static final byte IDX_TYPE = 6; // multiplexed
- private static final byte IDX_TIME_MID = 4;
- private static final byte IDX_TIME_LO = 0;
- private static final byte IDX_TIME_SEQ = 8;
- private static final byte IDX_VARIATION = 8; // multiplexed
- // indexes and lengths within the timestamp for certain boundaries
- private static final byte TS_TIME_LO_IDX = 4;
- private static final byte TS_TIME_LO_LEN = 4;
- private static final byte TS_TIME_MID_IDX = 2;
- private static final byte TS_TIME_MID_LEN = 2;
- private static final byte TS_TIME_HI_IDX = 0;
- private static final byte TS_TIME_HI_LEN = 2;
- // offset to move from 1/1/1970, which is 0-time for Java, to gregorian
- // 0-time 10/15/1582, and multiplier to go from 100nsec to msec units
- private static final long GREG_OFFSET = 0xB1D069B5400L;
- private static final long MILLI_MULT = 10000L;
- // type of UUID -- time based
- private final static byte TYPE_TIME_BASED = 0x10;
- // random number generator used to reduce conflicts with other JVMs, and
- // hasher for strings.
- private Random RANDOM;
- // 4-byte IP address + 2 random bytes to compensate for the fact that
- // the MAC address is usually 6 bytes
- private byte[] IP;
- // counter is initialized to 0 and is incremented for each uuid request
- // within the same timestamp window.
- private int _counter;
- // current timestamp (used to detect multiple uuid requests within same
- // timestamp)
- private long _currentMillis;
- // last used millis time, and a semi-random sequence that gets reset
- // when it overflows
- private long _lastMillis = 0L;
- private static final int MAX_14BIT = 0x3FFF;
- private short _seq = 0;
- private boolean type1Initialized = false; /*
- * Initializer for type 1 UUIDs. Creates random generator and genenerates
- * the node portion of the UUID using the IP address.
- */
- private synchronized void initializeForType1() {
- if (type1Initialized == true) {
- return;
- }
- // note that secure random is very slow the first time
- // it is used; consider switching to a standard random
- RANDOM = CSPRNG_DO_NOT_USE.generate();
- _seq = (short) RANDOM.nextInt(MAX_14BIT);
-
- byte[] ip = null;
- try {
- ip = InetAddress.getLocalHost().getAddress();
- } catch (IOException ioe) {
- throw new RuntimeException(ioe);
- }
- IP = new byte[6];
- RANDOM.nextBytes(IP);
- //OPENJPA-2055: account for the fact that 'getAddress'
- //may return an IPv6 address which is 16 bytes wide.
- for( int i = 0 ; i < ip.length; ++i ) {
- IP[2+(i%4)] ^= ip[i];
- }
- type1Initialized = true;
- }
- /**
- * Return a unique UUID value.
- */
- public byte[] next(int type) {
- if (type == TYPE4) {
- return createType4();
- }
- return createType1();
- }
- /*
- * Creates a type 1 UUID
- */
- public byte[] createType1() {
- if (type1Initialized == false) {
- initializeForType1();
- }
- // set ip addr
- byte[] uuid = new byte[16];
- System.arraycopy(IP, 0, uuid, 10, IP.length);
- // Set time info. Have to do this processing within a synchronized
- // block because of the statics...
- long now = 0;
- synchronized (UUIDGenerator.class) {
- // Get the time to use for this uuid. This method has the side
- // effect of modifying the clock sequence, as well.
- now = getTime();
- // Insert the resulting clock sequence into the uuid
- uuid[IDX_TIME_SEQ] = (byte) ((_seq & 0x3F00) >>> 8);
- uuid[IDX_VARIATION] |= 0x80;
- uuid[IDX_TIME_SEQ+1] = (byte) (_seq & 0xFF);
- }
- // have to break up time because bytes are spread through uuid
- byte[] timeBytes = Bytes.toBytes(now);
- // Copy time low
- System.arraycopy(timeBytes, TS_TIME_LO_IDX, uuid, IDX_TIME_LO,
- TS_TIME_LO_LEN);
- // Copy time mid
- System.arraycopy(timeBytes, TS_TIME_MID_IDX, uuid, IDX_TIME_MID,
- TS_TIME_MID_LEN);
- // Copy time hi
- System.arraycopy(timeBytes, TS_TIME_HI_IDX, uuid, IDX_TIME_HI,
- TS_TIME_HI_LEN);
- //Set version (time-based)
- uuid[IDX_TYPE] |= TYPE_TIME_BASED; // 0001 0000
- return uuid;
- }
- /*
- * Creates a type 4 UUID
- */
- private byte[] createType4() {
- UUID type4 = UUID.randomUUID();
- byte[] uuid = new byte[16];
- longToBytes(type4.getMostSignificantBits(), uuid, 0);
- longToBytes(type4.getLeastSignificantBits(), uuid, 8);
- return uuid;
- }
- /*
- * Converts a long to byte values, setting them in a byte array
- * at a given starting position.
- */
- private void longToBytes(long longVal, byte[] buf, int sPos) {
- sPos += 7;
- for(int i = 0; i < 8; i++)
- buf[sPos-i] = (byte)(longVal >>> (i * 8));
- }
-
- /**
- * Return the next unique uuid value as a 16-character string.
- */
- public String nextString(int type) {
- byte[] bytes = next(type);
- try {
- return new String(bytes, "ISO-8859-1");
- } catch (Exception e) {
- return new String(bytes);
- }
- }
- /**
- * Return the next unique uuid value as a 32-character hex string.
- */
- public String nextHex(int type) {
- return Base16Encoder.encode(next(type));
- }
- /**
- * Get the timestamp to be used for this uuid. Must be called from
- * a synchronized block.
- *
- * @return long timestamp
- */
- // package-visibility for testing
- private long getTime() {
- if (RANDOM == null)
- initializeForType1();
- long newTime = getUUIDTime();
- if (newTime <= _lastMillis) {
- incrementSequence();
- newTime = getUUIDTime();
- }
- _lastMillis = newTime;
- return newTime;
- }
- /**
- * Gets the appropriately modified timestamep for the UUID. Must be called
- * from a synchronized block.
- *
- * @return long timestamp in 100ns intervals since the Gregorian change
- * offset
- */
- private long getUUIDTime() {
- if (_currentMillis != System.currentTimeMillis()) {
- _currentMillis = System.currentTimeMillis();
- _counter = 0; // reset counter
- }
- // check to see if we have created too many uuid's for this timestamp
- if (_counter + 1 >= MILLI_MULT) {
- // Original algorithm threw exception. Seemed like overkill.
- // Let's just increment the timestamp instead and start over...
- _currentMillis++;
- _counter = 0;
- }
- // calculate time as current millis plus offset times 100 ns ticks
- long currentTime = (_currentMillis + GREG_OFFSET) * MILLI_MULT;
- // return the uuid time plus the artificial tick counter incremented
- return currentTime + _counter++;
- }
- /**
- * Increments the clock sequence for this uuid. Must be called from a
- * synchronized block.
- */
- private void incrementSequence() {
- // increment, but if it's greater than its 14-bits, reset it
- if (++_seq > MAX_14BIT) {
- _seq = (short) RANDOM.nextInt(MAX_14BIT); // semi-random
- }
- }
-
- //Add Dependant classes internally
-
- /**
- * This class came from the Apache Commons Id sandbox project in support
- * of the UUIDGenerator implementation.
- *
- * <p>Static methods for managing byte arrays (all methods follow Big
- * Endian order where most significant bits are in front).</p>
- */
- public static final class Bytes {
- /**
- * <p>Hide constructor in utility class.</p>
- */
- private Bytes() {
- }
- /**
- * Appends two bytes array into one.
- *
- * @param a A byte[].
- * @param b A byte[].
- * @return A byte[].
- */
- public static byte[] append(byte[] a, byte[] b) {
- byte[] z = new byte[a.length + b.length];
- System.arraycopy(a, 0, z, 0, a.length);
- System.arraycopy(b, 0, z, a.length, b.length);
- return z;
- }
- /**
- * Returns a 8-byte array built from a long.
- *
- * @param n The number to convert.
- * @return A byte[].
- */
- public static byte[] toBytes(long n) {
- return toBytes(n, new byte[8]);
- }
- /**
- * Build a 8-byte array from a long. No check is performed on the
- * array length.
- *
- * @param n The number to convert.
- * @param b The array to fill.
- * @return A byte[].
- */
- public static byte[] toBytes(long n, byte[] b) {
- b[7] = (byte) (n);
- n >>>= 8;
- b[6] = (byte) (n);
- n >>>= 8;
- b[5] = (byte) (n);
- n >>>= 8;
- b[4] = (byte) (n);
- n >>>= 8;
- b[3] = (byte) (n);
- n >>>= 8;
- b[2] = (byte) (n);
- n >>>= 8;
- b[1] = (byte) (n);
- n >>>= 8;
- b[0] = (byte) (n);
-
- return b;
- }
- /**
- * Build a long from first 8 bytes of the array.
- *
- * @param b The byte[] to convert.
- * @return A long.
- */
- public static long toLong(byte[] b) {
- return ((((long) b[7]) & 0xFF)
- + ((((long) b[6]) & 0xFF) << 8)
- + ((((long) b[5]) & 0xFF) << 16)
- + ((((long) b[4]) & 0xFF) << 24)
- + ((((long) b[3]) & 0xFF) << 32)
- + ((((long) b[2]) & 0xFF) << 40)
- + ((((long) b[1]) & 0xFF) << 48)
- + ((((long) b[0]) & 0xFF) << 56));
- }
- /**
- * Compares two byte arrays for equality.
- *
- * @param a A byte[].
- * @param b A byte[].
- * @return True if the arrays have identical contents.
- */
- public static boolean areEqual(byte[] a, byte[] b) {
- int aLength = a.length;
- if (aLength != b.length) {
- return false;
- }
- for (int i = 0; i < aLength; i++) {
- if (a[i] != b[i]) {
- return false;
- }
- }
- return true;
- }
- /**
- * <p>Compares two byte arrays as specified by <code>Comparable</code>.
- *
- * @param lhs - left hand value in the comparison operation.
- * @param rhs - right hand value in the comparison operation.
- * @return a negative integer, zero, or a positive integer as
- * <code>lhs</code> is less than, equal to, or greater than
- * <code>rhs</code>.
- */
- public static int compareTo(byte[] lhs, byte[] rhs) {
- if (lhs == rhs) {
- return 0;
- }
- if (lhs == null) {
- return -1;
- }
- if (rhs == null) {
- return +1;
- }
- if (lhs.length != rhs.length) {
- return ((lhs.length < rhs.length) ? -1 : +1);
- }
- for (int i = 0; i < lhs.length; i++) {
- if (lhs[i] < rhs[i]) {
- return -1;
- } else if (lhs[i] > rhs[i]) {
- return 1;
- }
- }
- return 0;
- }
- /**
- * Build a short from first 2 bytes of the array.
- *
- * @param b The byte[] to convert.
- * @return A short.
- */
- public static short toShort(byte[] b) {
- return (short) ((b[1] & 0xFF) + ((b[0] & 0xFF) << 8));
- }
- }
- /**
- * Base 16 encoder.
- *
- * @author Marc Prud'hommeaux
- */
- public static final class Base16Encoder {
-
- private final static char[] HEX = new char[]{
- '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
- /**
- * Convert bytes to a base16 string.
- */
- public static String encode(byte[] byteArray) {
- StringBuilder hexBuffer = new StringBuilder(byteArray.length * 2);
- for (int i = 0; i < byteArray.length; i++)
- for (int j = 1; j >= 0; j--)
- hexBuffer.append(HEX[(byteArray[i] >> (j * 4)) & 0xF]);
- return hexBuffer.toString();
- }
- /**
- * Convert a base16 string into a byte array.
- */
- public static byte[] decode(String s) {
- int len = s.length();
- byte[] r = new byte[len / 2];
- for (int i = 0; i < r.length; i++) {
- int digit1 = s.charAt(i * 2), digit2 = s.charAt(i * 2 + 1);
- if (digit1 >= '0' && digit1 <= '9')
- digit1 -= '0';
- else if (digit1 >= 'A' && digit1 <= 'F')
- digit1 -= 'A' - 10;
- if (digit2 >= '0' && digit2 <= '9')
- digit2 -= '0';
- else if (digit2 >= 'A' && digit2 <= 'F')
- digit2 -= 'A' - 10;
-
- r[i] = (byte) ((digit1 << 4) + digit2);
- }
- return r;
- }
- }
-
-
-
-}
-
-//========================================= APACHE BLOCK =========================================
-
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java
index 0af72661e9..6c15c06b1d 100644
--- a/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java
+++ b/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java
@@ -10,6 +10,7 @@ import org.apache.commons.lang3.reflect.FieldUtils;
import gregtech.api.enums.*;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.material.Material;
import gtPlusPlus.core.material.state.MaterialState;
import gtPlusPlus.core.util.Utils;
@@ -173,9 +174,19 @@ public class MaterialUtils {
}
}
- static Class<Materials> materialsEnum = Materials.class;
public static Materials getMaterialByName(String materialName) {
- return EnumUtils.getValue(materialsEnum, materialName);
+
+ if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) {
+ return (Materials) EnumUtils.getValue(gregtech.api.enums.Materials.class, materialName, false);
+ }
+ else {
+ for (Materials m : Materials.values()) {
+ if (MaterialUtils.getMaterialName(m).toLowerCase().equals(materialName.toLowerCase())) {
+ return m;
+ }
+ }
+ return null;
+ }
}
@SuppressWarnings("deprecation")
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/UtilsMining.java b/src/Java/gtPlusPlus/core/util/minecraft/MiningUtils.java
index eb6044fcd7..d44bf69253 100644
--- a/src/Java/gtPlusPlus/core/util/minecraft/UtilsMining.java
+++ b/src/Java/gtPlusPlus/core/util/minecraft/MiningUtils.java
@@ -6,7 +6,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
-public class UtilsMining {
+public class MiningUtils {
private static boolean durabilityDamage = false;
private static ItemStack stack;