mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 14:52:58 +00:00
Merge remote-tracking branch 'upstream/1.11' into 1.12_firstpass
This commit is contained in:
commit
df68b1e36a
299 files changed
+514
-9448
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package mekanism.common.util;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import ic2.api.energy.EnergyNet;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -11,6 +12,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import mekanism.api.Chunk3D;
|
||||
import mekanism.api.Coord4D;
|
||||
@@ -79,18 +81,24 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.world.ChunkCache;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.UsernameCache;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.fluids.BlockFluidBase;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Utilities used by Mekanism. All miscellaneous methods are located here.
|
||||
* @author AidanBrady
|
||||
@@ -102,6 +110,8 @@ public final class MekanismUtils
|
||||
|
||||
public static final Map<String, Class<?>> classesFound = new HashMap<String, Class<?>>();
|
||||
|
||||
private static final List<UUID> warnedFails = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Checks for a new version of Mekanism.
|
||||
*/
|
||||
@@ -164,11 +174,7 @@ public final class MekanismUtils
|
||||
public static void updateDonators()
|
||||
{
|
||||
Mekanism.donators.clear();
|
||||
|
||||
for(String s : getHTML("https://dl.dropbox.com/u/90411166/Donators/Mekanism.txt"))
|
||||
{
|
||||
Mekanism.donators.add(s);
|
||||
}
|
||||
Mekanism.donators.addAll(getHTML("https://dl.dropbox.com/u/90411166/Donators/Mekanism.txt"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1093,6 +1099,19 @@ public final class MekanismUtils
|
||||
|
||||
return "error";
|
||||
}
|
||||
|
||||
public static String getEnergyDisplay(double energy, double max)
|
||||
{
|
||||
if(energy == Double.MAX_VALUE)
|
||||
{
|
||||
return LangUtils.localize("gui.infinite");
|
||||
}
|
||||
|
||||
String energyString = getEnergyDisplay(energy);
|
||||
String maxString = getEnergyDisplay(max);
|
||||
|
||||
return energyString + "/" + maxString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from the unit defined in the configuration to joules.
|
||||
@@ -1498,6 +1517,30 @@ public final class MekanismUtils
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static String getLastKnownUsername(UUID uuid)
|
||||
{
|
||||
String ret = UsernameCache.getLastKnownUsername(uuid);
|
||||
|
||||
if(ret == null && !warnedFails.contains(uuid) && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
|
||||
{ // see if MC/Yggdrasil knows about it?!
|
||||
GameProfile gp = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerProfileCache().getProfileByUUID(uuid);
|
||||
|
||||
if(gp != null)
|
||||
{
|
||||
ret = gp.getName();
|
||||
}
|
||||
}
|
||||
|
||||
if(ret == null && !warnedFails.contains(uuid))
|
||||
{
|
||||
Mekanism.logger.warn("Failed to retrieve username for UUID {}, you might want to add it to the JSON cache", uuid);
|
||||
warnedFails.add(uuid);
|
||||
}
|
||||
|
||||
return ret != null ? ret : "<???>";
|
||||
}
|
||||
|
||||
public static enum ResourceType
|
||||
{
|
||||
GUI("gui"),
|
||||
@@ -1521,4 +1564,9 @@ public final class MekanismUtils
|
||||
return prefix + "/";
|
||||
}
|
||||
}
|
||||
|
||||
public static TileEntity getTileEntitySafe(IBlockAccess worldIn, BlockPos pos)
|
||||
{
|
||||
return worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user