mirror of
https://github.com/GTNewHorizons/Hardcore-Ender-Expansion.git
synced 2026-10-25 20:22:31 +00:00
Bunch of speed improvements
This commit is contained in:
1 parent
07364d9849
commit
353f8597be
13 files changed
+108
-73
No files matched your search
+1
-1
@@ -25,7 +25,7 @@ sourceCompatibility = 1.7
|
||||
targetCompatibility = 1.7
|
||||
|
||||
minecraft {
|
||||
version = "1.7.10-10.13.0.1208"
|
||||
version = "1.7.10-10.13.2.1258"
|
||||
assetDir = "eclipse/assets"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package chylex.hee;
|
||||
import java.io.File;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -129,6 +130,7 @@ public class HardcoreEnderExpansion{
|
||||
|
||||
public static String modVersion;
|
||||
public static String configPath;
|
||||
public static File sourceFile;
|
||||
|
||||
@EventHandler
|
||||
public void onPreInit(FMLPreInitializationEvent e){
|
||||
@@ -137,6 +139,7 @@ public class HardcoreEnderExpansion{
|
||||
ReflectionPublicizer.load();
|
||||
modVersion = e.getModMetadata().version;
|
||||
configPath = e.getSuggestedConfigurationFile().getParentFile().getName();
|
||||
sourceFile = e.getSourceFile();
|
||||
|
||||
// CONFIGURATION LOAD
|
||||
|
||||
@@ -148,12 +151,12 @@ public class HardcoreEnderExpansion{
|
||||
|
||||
// BASIC SETUP
|
||||
|
||||
CompendiumTranslations.load(e.getSourceFile());
|
||||
CompendiumTranslations.load();
|
||||
DimensionOverride.setup();
|
||||
|
||||
// BLOCKS
|
||||
|
||||
BlockReplaceHelper.replaceBlock(Blocks.dragon_egg, BlockDragonEggCustom.class, ItemBlockDragonEgg.class);
|
||||
BlockReplaceHelper.replaceBlock(Blocks.dragon_egg, new BlockDragonEggCustom(), ItemBlockDragonEgg.class);
|
||||
BlockList.registerBlocks();
|
||||
|
||||
BlockList.obsidian_falling.setHarvestLevel("pickaxe", 3);
|
||||
|
||||
@@ -27,6 +27,7 @@ import chylex.hee.item.block.ItemBlockSoulCharm;
|
||||
import chylex.hee.item.block.ItemBlockWithSubtypes;
|
||||
import chylex.hee.system.creativetab.ModCreativeTab;
|
||||
import chylex.hee.system.logging.Log;
|
||||
import chylex.hee.system.logging.Stopwatch;
|
||||
import chylex.hee.system.util.GameRegistryUtil;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -190,10 +191,14 @@ public final class BlockList{
|
||||
}
|
||||
|
||||
public static void registerBlocks(){
|
||||
Stopwatch.time("BlockList - register");
|
||||
|
||||
for(Entry<String,BlockData> entry:BlockList.blocks.entrySet()){
|
||||
GameRegistryUtil.registerBlock(entry.getValue().block,entry.getKey(),entry.getValue().itemBlockClass);
|
||||
}
|
||||
|
||||
Stopwatch.finish("BlockList - register");
|
||||
|
||||
ModCreativeTab.tabMain.list.addBlocks(
|
||||
Blocks.dragon_egg,obsidian_falling,obsidian_special,obsidian_special_glow,obsidian_stairs,
|
||||
essence_altar,void_chest,decomposition_table,energy_extraction_table,
|
||||
|
||||
@@ -1,30 +1,23 @@
|
||||
package chylex.hee.block;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Map;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.util.ObjectIntIdentityMap;
|
||||
import net.minecraft.util.RegistryNamespaced;
|
||||
import net.minecraft.util.RegistrySimple;
|
||||
import chylex.hee.system.logging.Log;
|
||||
import chylex.hee.system.logging.Stopwatch;
|
||||
import chylex.hee.system.util.Unfinalizer;
|
||||
import cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
|
||||
public class BlockReplaceHelper{
|
||||
public static void replaceBlock(Block toReplace, Class<? extends Block> blockClass, Class<? extends ItemBlock> itemBlockClass){
|
||||
public static void replaceBlock(Block toReplace, Block replacement, Class<? extends ItemBlock> itemBlockClass){
|
||||
Stopwatch.time("BlockReplace");
|
||||
|
||||
Class<?>[] classTest = new Class<?>[4];
|
||||
Exception exception = null;
|
||||
|
||||
try{
|
||||
Field modifiersField = Field.class.getDeclaredField("modifiers");
|
||||
modifiersField.setAccessible(true);
|
||||
|
||||
for(Field blockField:Blocks.class.getDeclaredFields()){
|
||||
if (Block.class.isAssignableFrom(blockField.getType())){
|
||||
Block block = (Block)blockField.get(null);
|
||||
@@ -35,29 +28,23 @@ public class BlockReplaceHelper{
|
||||
|
||||
Log.debug("Replacing block - $0/$1",id,registryName);
|
||||
|
||||
Block newBlock = blockClass.newInstance();
|
||||
FMLControlledNamespacedRegistry<Block> registryBlocks = GameData.getBlockRegistry();
|
||||
Field map1 = RegistrySimple.class.getDeclaredFields()[1];
|
||||
map1.setAccessible(true);
|
||||
((Map)map1.get(registryBlocks)).put(registryName,newBlock);
|
||||
|
||||
Field map2 = RegistryNamespaced.class.getDeclaredFields()[0];
|
||||
map2.setAccessible(true);
|
||||
((ObjectIntIdentityMap)map2.get(registryBlocks)).func_148746_a(newBlock,id); // OBFUSCATED put object
|
||||
registryBlocks.registryObjects.put(registryName,replacement);
|
||||
registryBlocks.underlyingIntegerMap.func_148746_a(replacement,id); // OBFUSCATED put object
|
||||
|
||||
blockField.setAccessible(true);
|
||||
modifiersField.setInt(blockField,blockField.getModifiers() & ~Modifier.FINAL);
|
||||
blockField.set(null,newBlock);
|
||||
Unfinalizer.unfinalizeField(blockField);
|
||||
blockField.set(null,replacement);
|
||||
|
||||
ItemBlock itemBlock = itemBlockClass.getConstructor(Block.class).newInstance(newBlock);
|
||||
ItemBlock itemBlock = itemBlockClass.getConstructor(Block.class).newInstance(replacement);
|
||||
FMLControlledNamespacedRegistry<Item> registryItems = GameData.getItemRegistry();
|
||||
((Map)map1.get(registryItems)).put(registryName,itemBlock);
|
||||
((ObjectIntIdentityMap)map2.get(registryItems)).func_148746_a(itemBlock,id); // OBFUSCATED put object
|
||||
registryItems.registryObjects.put(registryName,itemBlock);
|
||||
registryItems.underlyingIntegerMap.func_148746_a(itemBlock,id); // OBFUSCATED put object
|
||||
|
||||
classTest[0] = blockField.get(null).getClass();
|
||||
classTest[1] = Block.blockRegistry.getObjectById(id).getClass();
|
||||
classTest[2] = ((ItemBlock)Item.getItemFromBlock(newBlock)).field_150939_a.getClass();
|
||||
classTest[3] = Item.getItemFromBlock(newBlock).getClass();
|
||||
classTest[2] = ((ItemBlock)Item.getItemFromBlock(replacement)).field_150939_a.getClass();
|
||||
classTest[3] = Item.getItemFromBlock(replacement).getClass();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ public class EntityMiniBossFireFiend extends EntityFlying implements IBossDispla
|
||||
}
|
||||
}
|
||||
|
||||
for(EntityLivingBase e:(List<EntityLivingBase>)worldObj.getEntitiesWithinAABB(EntityLivingBase.class,boundingBox.expand(0.6D,1.65D,0.6D))){
|
||||
for(EntityLivingBase e:(List<EntityLivingBase>)worldObj.getEntitiesWithinAABB(EntityLivingBase.class,boundingBox.expand(0.8D,1.65D,0.8D))){
|
||||
if (e == this || e.isImmuneToFire())continue;
|
||||
e.setFire(2+rand.nextInt(4));
|
||||
e.hurtResistantTime = 0;
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.item.ItemBucket;
|
||||
import net.minecraft.item.ItemReed;
|
||||
import chylex.hee.block.BlockList;
|
||||
import chylex.hee.system.creativetab.ModCreativeTab;
|
||||
import chylex.hee.system.logging.Stopwatch;
|
||||
import chylex.hee.system.util.GameRegistryUtil;
|
||||
|
||||
public final class ItemList{
|
||||
@@ -128,10 +129,14 @@ public final class ItemList{
|
||||
}
|
||||
|
||||
public static void registerItems(){
|
||||
Stopwatch.time("ItemList - register");
|
||||
|
||||
for(Entry<String,Item> entry:ItemList.items.entrySet()){
|
||||
GameRegistryUtil.registerItem(entry.getValue(),entry.getKey());
|
||||
}
|
||||
|
||||
Stopwatch.finish("ItemList - register");
|
||||
|
||||
ModCreativeTab.tabMain.list.addItems(
|
||||
adventurers_diary,altar_nexus,essence,enhanced_brewing_stand,
|
||||
end_powder,endium_ingot,stardust,igneous_rock,instability_orb,potion_of_instability,
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package chylex.hee.mechanics.compendium;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Collections;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
import net.minecraft.util.StringTranslate;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import chylex.hee.HardcoreEnderExpansion;
|
||||
import chylex.hee.system.logging.Log;
|
||||
import chylex.hee.system.logging.Stopwatch;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
@@ -15,19 +17,17 @@ import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
public final class CompendiumTranslations{
|
||||
private static final Pattern ecLangPattern = Pattern.compile("assets/hardcoreenderexpansion/lang_ec/(.*?)\\.lang");
|
||||
|
||||
public static void load(File sourceFile){
|
||||
public static void load(){
|
||||
Stopwatch.time("CompendiumTranslations - load");
|
||||
|
||||
File sourceFile = HardcoreEnderExpansion.sourceFile;
|
||||
|
||||
if (sourceFile.isDirectory()){
|
||||
sourceFile = Paths.get(sourceFile.getPath(),"assets","hardcoreenderexpansion","lang_ec").toFile();
|
||||
|
||||
try{
|
||||
for(File file:FileUtils.listFiles(sourceFile,new String[]{ "lang" },true)){
|
||||
String path = file.getAbsolutePath().replace('\\','/');
|
||||
|
||||
int index = path.indexOf("assets/hardcoreenderexpansion/lang_ec/");
|
||||
if (index == -1)continue;
|
||||
|
||||
Matcher match = ecLangPattern.matcher(path.substring(index));
|
||||
if (match.matches())LanguageRegistry.instance().injectLanguage(match.group(1),StringTranslate.parseLangFile(new FileInputStream(file)));
|
||||
for(File file:sourceFile.listFiles()){
|
||||
LanguageRegistry.instance().injectLanguage(FilenameUtils.removeExtension(file.getName()),StringTranslate.parseLangFile(new FileInputStream(file)));
|
||||
}
|
||||
}
|
||||
catch(Exception e){
|
||||
|
||||
@@ -4,17 +4,22 @@ import gnu.trove.map.hash.TObjectByteHashMap;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import chylex.hee.HardcoreEnderExpansion;
|
||||
import chylex.hee.system.logging.Stopwatch;
|
||||
import com.google.common.reflect.ClassPath;
|
||||
import com.google.common.reflect.ClassPath.ClassInfo;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.network.FMLEmbeddedChannel;
|
||||
import cpw.mods.fml.common.network.FMLEventChannel;
|
||||
@@ -59,15 +64,35 @@ public class PacketPipeline{
|
||||
|
||||
int id = -1;
|
||||
|
||||
for(ClassInfo clsInfo:ClassPath.from(PacketPipeline.class.getClassLoader()).getTopLevelClassesRecursive("chylex.hee.packets")){
|
||||
String name = clsInfo.getName();
|
||||
File sourceFile = HardcoreEnderExpansion.sourceFile;
|
||||
|
||||
if (sourceFile.isDirectory()){
|
||||
File root = Paths.get(sourceFile.getPath(),"chylex","hee","packets").toFile();
|
||||
|
||||
if (name.startsWith("chylex.hee.packets.client.C") || name.startsWith("chylex.hee.packets.server.S")){
|
||||
Class cls = clsInfo.load();
|
||||
registerPacket(++id,cls);
|
||||
for(String name:new File(root,"client").list()){
|
||||
if (name.startsWith("C"))registerPacket(++id,(Class<? extends AbstractPacket>)Class.forName("chylex.hee.packets.client."+FilenameUtils.removeExtension(name)));
|
||||
}
|
||||
|
||||
for(String name:new File(root,"server").list()){
|
||||
if (name.startsWith("S"))registerPacket(++id,(Class<? extends AbstractPacket>)Class.forName("chylex.hee.packets.server."+FilenameUtils.removeExtension(name)));
|
||||
}
|
||||
}
|
||||
}catch(NoSuchFieldException | IllegalArgumentException | IllegalAccessException | IOException e){
|
||||
else{
|
||||
try(ZipFile zip = new ZipFile(sourceFile)){
|
||||
for(ZipEntry entry:Collections.list(zip.entries())){
|
||||
String name = entry.getName();
|
||||
|
||||
if (name.startsWith("chylex/hee/packets/")){
|
||||
if (name.startsWith("chylex/hee/packets/client/C") || name.startsWith("chylex/hee/packets/client/S")){
|
||||
registerPacket(++id,(Class<? extends AbstractPacket>)Class.forName(FilenameUtils.removeExtension(name.replace('/','.'))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch(IOException e){
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}catch(NoSuchFieldException | IllegalArgumentException | IllegalAccessException | IOException | ClassNotFoundException e){
|
||||
throw new RuntimeException("Unable to load the Packet system!",e);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,13 @@ import chylex.hee.system.integration.handlers.MineFactoryReloadedIntegration;
|
||||
import chylex.hee.system.integration.handlers.NotEnoughItemsIntegration;
|
||||
import chylex.hee.system.integration.handlers.ThaumcraftIntegration;
|
||||
import chylex.hee.system.logging.Log;
|
||||
import chylex.hee.system.logging.Stopwatch;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
public final class ModIntegrationManager{
|
||||
public static final void integrateMods(){
|
||||
Stopwatch.time("ModIntegrationManager - integrateMods");
|
||||
|
||||
Class[] handlerClasses = new Class[]{
|
||||
NotEnoughItemsIntegration.class,
|
||||
ThaumcraftIntegration.class,
|
||||
@@ -23,5 +26,7 @@ public final class ModIntegrationManager{
|
||||
Log.throwable(e,"Unable to integrate with mod $0.",cls.getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
Stopwatch.finish("ModIntegrationManager - integrateMods");
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package chylex.hee.system.sound;
|
||||
import java.lang.reflect.Field;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.MusicTicker;
|
||||
import net.minecraftforge.client.event.sound.SoundLoadEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import chylex.hee.system.logging.Log;
|
||||
@@ -28,24 +26,10 @@ public final class MusicManager{
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
try{
|
||||
Field[] fields = Minecraft.class.getDeclaredFields();
|
||||
|
||||
for(int a = 0; a < fields.length; a++){
|
||||
if (MusicTicker.class.isAssignableFrom(fields[a].getType())){
|
||||
fields[a].setAccessible(true);
|
||||
|
||||
if (fields[a].get(mc) != null){
|
||||
fields[a].set(mc,CustomMusicTicker.getInstance());
|
||||
hasLoaded = true;
|
||||
Log.debug("Successfully replaced MusicTicker.");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}catch(SecurityException | IllegalArgumentException | IllegalAccessException ex){
|
||||
Log.throwable(ex,"Could not replace MusicTicker, custom music will not be present.");
|
||||
if (mc.mcMusicTicker != null){
|
||||
mc.mcMusicTicker = CustomMusicTicker.getInstance();
|
||||
hasLoaded = true;
|
||||
Log.debug("Successfully replaced MusicTicker.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package chylex.hee.system.util;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
public final class Unfinalizer{
|
||||
private static Field modifiersField;
|
||||
|
||||
public static void unfinalizeField(Field field) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException{
|
||||
try{
|
||||
if (modifiersField == null){
|
||||
modifiersField = Field.class.getDeclaredField("modifiers");
|
||||
modifiersField.setAccessible(true);
|
||||
}
|
||||
|
||||
modifiersField.setInt(field,field.getModifiers() & ~Modifier.FINAL);
|
||||
}catch(NoSuchFieldException | IllegalArgumentException | IllegalAccessException e){
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private Unfinalizer(){}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
package chylex.hee.world;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Hashtable;
|
||||
import net.minecraft.world.WorldProvider;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.biome.BiomeGenEnd;
|
||||
import net.minecraft.world.gen.structure.MapGenStructureIO;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import chylex.hee.system.logging.Stopwatch;
|
||||
import chylex.hee.system.util.Unfinalizer;
|
||||
import chylex.hee.world.biome.BiomeGenHardcoreEnd;
|
||||
import chylex.hee.world.structure.island.ComponentIsland;
|
||||
import chylex.hee.world.structure.island.StructureIsland;
|
||||
@@ -55,17 +54,14 @@ public final class DimensionOverride{
|
||||
try{
|
||||
BiomeGenBase sky = new BiomeGenHardcoreEnd(9).setColor(8421631).setBiomeName("Sky").setDisableRain();
|
||||
BiomeGenBase.getBiomeGenArray()[9] = sky;
|
||||
|
||||
Field modifiersField = Field.class.getDeclaredField("modifiers");
|
||||
modifiersField.setAccessible(true);
|
||||
|
||||
for(Field field:BiomeGenBase.class.getDeclaredFields()){
|
||||
if (!BiomeGenBase.class.isAssignableFrom(field.getType()))continue;
|
||||
|
||||
field.setAccessible(true);
|
||||
modifiersField.setInt(field,field.getModifiers() & ~Modifier.FINAL);
|
||||
Unfinalizer.unfinalizeField(field);
|
||||
|
||||
if (field.get(null) instanceof BiomeGenEnd){
|
||||
if (((BiomeGenBase)field.get(null)).biomeID == 9){
|
||||
field.set(null,sky);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# C:\Gradle\caches\minecraft\net\minecraftforge\forge\1.7.10-10.13.0.1208\unpacked\conf
|
||||
|
||||
public net.minecraft.util.RegistrySimple field_82596_a # registryObjects
|
||||
public net.minecraft.util.RegistryNamespaced field_148759_a # underlyingIntegerMap
|
||||
public net.minecraft.entity.EntityLivingBase field_110153_bc # lastDamage
|
||||
public net.minecraft.entity.Entity field_70151_c # fire
|
||||
public net.minecraft.entity.monster.EntityGhast field_70792_g # targetedEntity
|
||||
@@ -9,6 +11,7 @@ public net.minecraft.network.NetHandlerPlayServer field_147382_p # lastPosY
|
||||
public net.minecraft.network.NetHandlerPlayServer field_147381_q # lastPosZ
|
||||
public net.minecraft.world.gen.ChunkProviderEnd field_73204_i # endRNG
|
||||
|
||||
public net.minecraft.client.Minecraft field_147126_aw # mcMusicTicker
|
||||
public net.minecraft.client.gui.inventory.GuiContainer field_146999_f # xSize
|
||||
public net.minecraft.client.gui.inventory.GuiContainer field_147000_g # ySize
|
||||
public net.minecraft.client.renderer.RenderGlobal field_147593_P # mapSoundPositions
|
||||
Reference in new issue
Block a user