diff options
15 files changed, 149 insertions, 189 deletions
diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java index 01c15a6b04..cd51a532d3 100644 --- a/src/main/java/com/github/technus/tectech/TecTech.java +++ b/src/main/java/com/github/technus/tectech/TecTech.java @@ -21,6 +21,7 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.transformations import com.github.technus.tectech.mechanics.enderStorage.EnderWorldSavedData; import com.github.technus.tectech.nei.IMCForNEI; import com.github.technus.tectech.proxy.CommonProxy; +import com.github.technus.tectech.recipe.EyeOfHarmonyRecipeStorage; import com.github.technus.tectech.util.XSTR; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Loader; @@ -233,9 +234,14 @@ public class TecTech { } } + public static EyeOfHarmonyRecipeStorage eyeOfHarmonyRecipeStorage = null; + @Mod.EventHandler public void onServerAboutToStart(FMLServerAboutToStartEvent aEvent) { chunkDataHandler.clearData(); playerPersistence.clearData(); + + // This must be done after game load otherwise it fails. + eyeOfHarmonyRecipeStorage = new EyeOfHarmonyRecipeStorage(); } } diff --git a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/blocks/turretheads/TurretHeadEM.java b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/blocks/turretheads/TurretHeadEM.java index 8a486cb798..0b242505ab 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/blocks/turretheads/TurretHeadEM.java +++ b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/blocks/turretheads/TurretHeadEM.java @@ -1,10 +1,8 @@ package com.github.technus.tectech.compatibility.openmodularturrets.blocks.turretheads; -import static com.github.technus.tectech.Reference.MODID; import static com.github.technus.tectech.TecTech.creativeTabTecTech; import com.github.technus.tectech.compatibility.openmodularturrets.tileentity.turret.TileTurretHeadEM; -import com.github.technus.tectech.thing.block.TileEyeOfHarmony; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; @@ -66,6 +64,5 @@ public class TurretHeadEM extends Block implements ITileEntityProvider { INSTANCE = new TurretHeadEM(); GameRegistry.registerBlock(INSTANCE, TurretHeadItemEM.class, INSTANCE.getUnlocalizedName()); GameRegistry.registerTileEntity(TileTurretHeadEM.class, "TileTurretHeadEM"); - } } diff --git a/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java b/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java index 47a6c52028..f12e756bd6 100644 --- a/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java +++ b/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java @@ -1,6 +1,5 @@ package com.github.technus.tectech.loader; -import com.github.technus.tectech.thing.block.EyeOfHarmonyBlock; import com.github.technus.tectech.thing.block.RenderEyeOfHarmony; import com.github.technus.tectech.thing.block.TileEyeOfHarmony; import cpw.mods.fml.client.registry.ClientRegistry; diff --git a/src/main/java/com/github/technus/tectech/loader/thing/ThingsLoader.java b/src/main/java/com/github/technus/tectech/loader/thing/ThingsLoader.java index 8d1be9f92f..53389d6fa5 100644 --- a/src/main/java/com/github/technus/tectech/loader/thing/ThingsLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/thing/ThingsLoader.java @@ -81,7 +81,5 @@ public class ThingsLoader implements Runnable { ElementalDefinitionContainer_EM.run(); DebugElementalInstanceContainer_EM.run(); TecTech.LOGGER.info("Debug Items registered"); - - } } diff --git a/src/main/java/com/github/technus/tectech/nei/TT_NEI_EyeOfHarmonyHandler.java b/src/main/java/com/github/technus/tectech/nei/TT_NEI_EyeOfHarmonyHandler.java index d82f3f2fa0..fd964c90c4 100644 --- a/src/main/java/com/github/technus/tectech/nei/TT_NEI_EyeOfHarmonyHandler.java +++ b/src/main/java/com/github/technus/tectech/nei/TT_NEI_EyeOfHarmonyHandler.java @@ -3,19 +3,13 @@ package com.github.technus.tectech.nei; import static com.github.technus.tectech.Reference.MODID; import static net.minecraft.util.EnumChatFormatting.*; -import appeng.util.ReadableNumberConverter; -import codechicken.nei.PositionedStack; import codechicken.nei.recipe.GuiCraftingRecipe; import codechicken.nei.recipe.GuiUsageRecipe; import codechicken.nei.recipe.TemplateRecipeHandler; -import com.github.technus.tectech.recipe.EyeOfHarmonyRecipe; import cpw.mods.fml.common.event.FMLInterModComms; import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_Recipe; import gregtech.nei.GT_NEI_DefaultHandler; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import org.lwjgl.opengl.GL11; public class TT_NEI_EyeOfHarmonyHandler extends GT_NEI_DefaultHandler { diff --git a/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java b/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java index a98af27ec0..7a5b322456 100644 --- a/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java +++ b/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java @@ -10,7 +10,6 @@ import com.github.technus.tectech.thing.item.ElementalDefinitionContainer_EM; import com.github.technus.tectech.thing.item.renderElemental.RenderElementalName; import com.gtnewhorizon.structurelib.entity.fx.WeightlessParticleFX; import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.Loader; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; diff --git a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java index 2f2c9ca9aa..8c4324d70d 100644 --- a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java +++ b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java @@ -4,6 +4,7 @@ import static com.github.technus.tectech.recipe.EyeOfHarmonyRecipeStorage.BILLIO import static com.google.common.math.IntMath.pow; import static gregtech.api.GregTech_API.getUnificatedOreDictStack; import static gregtech.api.util.GT_Utility.getPlasmaFuelValueInEUPerLiterFromMaterial; +import static java.lang.Math.min; import com.github.technus.tectech.util.ItemStackLong; import gnu.trove.map.TMap; @@ -62,6 +63,7 @@ public class EyeOfHarmonyRecipe { private final ItemStack recipeTriggerItem; private final long sumOfItems; + private final long rocketTier; public TMap<ItemStack, Double> getItemStackToProbabilityMap() { return itemStackToProbabilityMap; @@ -82,6 +84,10 @@ public class EyeOfHarmonyRecipe { return sumOfItems; } + public long getRocketTier() { + return rocketTier; + } + public EyeOfHarmonyRecipe( ArrayList<Pair<Materials, Long>> materialList, Block block, @@ -89,8 +95,12 @@ public class EyeOfHarmonyRecipe { final long hydrogenRequirement, final long heliumRequirement, final long miningTimeSeconds, - final long spacetimeCasingTierRequired, + final long rocketTierOfRecipe, final double baseSuccessChance) { + + this.rocketTier = rocketTierOfRecipe; + this.spacetimeCasingTierRequired = min(8, rocketTierOfRecipe); + this.recipeTriggerItem = new ItemStack(block); this.outputItems = validDustGenerator(materialList); @@ -113,18 +123,16 @@ public class EyeOfHarmonyRecipe { ArrayList<FluidStack> fluidStackArrayList = validPlasmaGenerator(materialList); for (FluidStack fluidStack : fluidStackArrayList) { - fluidStack.amount = (int) ((spacetimeCasingTierRequired + 1) * 1_000_000L); + fluidStack.amount = (int) ((this.spacetimeCasingTierRequired + 1) * 1_000_000L); } // Add a bonus fluid of compressed star matter. // todo replace with Bonus star matter when added to GT5. - fluidStackArrayList.add(Materials.Infinity.getMolten((spacetimeCasingTierRequired + 1) * 100_000)); + fluidStackArrayList.add(Materials.Infinity.getMolten((this.spacetimeCasingTierRequired + 1) * 100_000)); outputFluids = fluidStackArrayList; // End fluid processing. - this.spacetimeCasingTierRequired = spacetimeCasingTierRequired; - this.hydrogenRequirement = hydrogenRequirement; this.heliumRequirement = heliumRequirement; diff --git a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java index e4a3481e33..091ec4f7f5 100644 --- a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java +++ b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java @@ -49,9 +49,9 @@ public class EyeOfHarmonyRecipeStorage { GT5OreSmallHelper.dimToSmallOreWrapper.get(dimAbbreviation), blockDimensionDisplay, 0.6 + blockDimensionDisplay.getDimensionRocketTier() / 10.0, - BILLION * blockDimensionDisplay.getDimensionRocketTier(), - BILLION * blockDimensionDisplay.getDimensionRocketTier(), - (long) (18_000L * pow(1.4, blockDimensionDisplay.getDimensionRocketTier())), + BILLION * (blockDimensionDisplay.getDimensionRocketTier() + 1), + BILLION * (blockDimensionDisplay.getDimensionRocketTier() + 1), + timeCalculator(blockDimensionDisplay.getDimensionRocketTier()), blockDimensionDisplay.getDimensionRocketTier(), 1.0 - blockDimensionDisplay.getDimensionRocketTier() / 10.0)); } @@ -64,7 +64,7 @@ public class EyeOfHarmonyRecipeStorage { } }; - public EyeOfHarmonyRecipe recipeLookUp(ItemStack aStack) { + public EyeOfHarmonyRecipe recipeLookUp(final ItemStack aStack) { String dimAbbreviation = blocksMapInverted.get(Block.getBlockFromItem(aStack.getItem())); return recipeHashMap.get(dimAbbreviation); } @@ -96,7 +96,7 @@ public class EyeOfHarmonyRecipeStorage { } private void specialDeepDarkRecipe( - HashMap<String, EyeOfHarmonyRecipe> hashMap, final BlockDimensionDisplay planetItem) { + final HashMap<String, EyeOfHarmonyRecipe> hashMap, final BlockDimensionDisplay planetItem) { HashSet<Materials> validMaterialSet = new HashSet<>(); @@ -127,16 +127,20 @@ public class EyeOfHarmonyRecipeStorage { 0.6 + rocketTier / 10.0, BILLION * (rocketTier + 1), BILLION * (rocketTier + 1), - (long) (18_000L * pow(1.4, rocketTier)), - rocketTier - 1, // -1 so that we avoid out of bounds exception on NEI render. + timeCalculator(rocketTier), + rocketTier, // -1 so that we avoid out of bounds exception on NEI render. 1.0 - rocketTier / 10.0)); } - private ArrayList<Pair<Materials, Long>> processDD(ArrayList<Materials> validMaterialList) { + private static long timeCalculator(final long rocketTier) { + return (long) (18_000L * pow(1.4, rocketTier)); + } + + private ArrayList<Pair<Materials, Long>> processDD(final ArrayList<Materials> validMaterialList) { EyeOfHarmonyRecipe.HashMapHelper outputMap = new EyeOfHarmonyRecipe.HashMapHelper(); - // 9 from rocketTier + 1, 6 * 64 = VM3 + Og, 1.4 = time increase per tier. - double mainMultiplier = (18_000L * pow(1.4, 9) * (6 * 64)); + // 10 from rocketTier + 1, 6 * 64 = VM3 + Og, 1.4 = time increase per tier. + double mainMultiplier = (timeCalculator(10) * (6 * 64)); double probability = 1.0 / validMaterialList.size(); validMaterialList.forEach((material) -> { diff --git a/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java b/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java index 07c55b68e4..088c9bf2b0 100644 --- a/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java +++ b/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java @@ -671,7 +671,6 @@ public class TT_recipe extends GT_Recipe { return currentTip; } - @Override public void drawNEIOverlays(GT_NEI_DefaultHandler.CachedDefaultRecipe neiCachedRecipe) { EyeOfHarmonyRecipe EOHRecipe = (EyeOfHarmonyRecipe) neiCachedRecipe.mRecipe.mSpecialItems; diff --git a/src/main/java/com/github/technus/tectech/thing/block/EyeOfHarmonyBlock.java b/src/main/java/com/github/technus/tectech/thing/block/EyeOfHarmonyBlock.java index 5edebe619e..42cb9a45ed 100644 --- a/src/main/java/com/github/technus/tectech/thing/block/EyeOfHarmonyBlock.java +++ b/src/main/java/com/github/technus/tectech/thing/block/EyeOfHarmonyBlock.java @@ -12,12 +12,10 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; - public class EyeOfHarmonyBlock extends Block { public EyeOfHarmonyBlock() { super(Material.iron); - this.setHardness(10F); this.setResistance(20f); this.setCreativeTab(TecTech.creativeTabEM); this.setBlockName("Eye of Harmony Renderer"); @@ -57,7 +55,8 @@ public class EyeOfHarmonyBlock extends Block { } public static void registerOther(Block block) { - String name = block.getUnlocalizedName().substring(block.getUnlocalizedName().indexOf(".") + 1); + String name = + block.getUnlocalizedName().substring(block.getUnlocalizedName().indexOf(".") + 1); GameRegistry.registerBlock(block, name.substring(name.indexOf(":") + 1)); } @@ -87,5 +86,4 @@ public class EyeOfHarmonyBlock extends Block { return true; } - } diff --git a/src/main/java/com/github/technus/tectech/thing/block/RenderEyeOfHarmony.java b/src/main/java/com/github/technus/tectech/thing/block/RenderEyeOfHarmony.java index 2f30d59b2e..6224593a25 100644 --- a/src/main/java/com/github/technus/tectech/thing/block/RenderEyeOfHarmony.java +++ b/src/main/java/com/github/technus/tectech/thing/block/RenderEyeOfHarmony.java @@ -1,80 +1,54 @@ package com.github.technus.tectech.thing.block; +import static com.github.technus.tectech.Reference.MODID; +import static java.lang.Math.*; + +import cpw.mods.fml.client.FMLClientHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.util.IIcon; -import org.lwjgl.opengl.GL11; - -import cpw.mods.fml.client.FMLClientHandler; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.AdvancedModelLoader; import net.minecraftforge.client.model.IModelCustom; -import pers.gwyog.gtneioreplugin.plugin.block.ModBlocks; - -import javax.vecmath.Vector3d; - -import static com.github.technus.tectech.Reference.MODID; -import static gregtech.common.render.GT_Renderer_Block.renderStandardBlock; -import static java.lang.Math.*; +import org.lwjgl.opengl.GL11; public class RenderEyeOfHarmony extends TileEntitySpecialRenderer { - private static final ResourceLocation starLayer0 = new ResourceLocation(MODID ,"models/StarLayer0.png"); - private static final ResourceLocation starLayer1 = new ResourceLocation(MODID ,"models/StarLayer1.png"); - private static final ResourceLocation starLayer2 = new ResourceLocation(MODID ,"models/StarLayer2.png"); + private static final ResourceLocation starLayer0 = new ResourceLocation(MODID, "models/StarLayer0.png"); + private static final ResourceLocation starLayer1 = new ResourceLocation(MODID, "models/StarLayer1.png"); + private static final ResourceLocation starLayer2 = new ResourceLocation(MODID, "models/StarLayer2.png"); private static final ResourceLocation blackHole = new ResourceLocation(MODID, "models/blackHole.png"); public static IModelCustom modelCustom; public RenderEyeOfHarmony() { - modelCustom = - AdvancedModelLoader.loadModel(new ResourceLocation(MODID, "models/Star.obj")); + modelCustom = AdvancedModelLoader.loadModel(new ResourceLocation(MODID, "models/Star.obj")); } @Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float timeSinceLastTick) { if (!(tile instanceof TileEyeOfHarmony)) return; -// System.out.println("NAME " + this.field_147501_a.field_147551_g.getCommandSenderName()); -// EntityPlayer p = Minecraft.getMinecraft().thePlayer; -// System.out.println("TESTING NAME " + p.getCommandSenderName()); -// System.out.println("TESTING X " + p.getLookVec().xCoord); -// System.out.println("TESTING Y " + p.getLookVec().yCoord); -// System.out.println("TESTING Z " + p.getLookVec().zCoord); - -// System.out.println(this.field_147501_a.field_147551_g.get()); - TileEyeOfHarmony EOHRenderTile = (TileEyeOfHarmony) tile; { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); - GL11.glPushMatrix(); - GL11.glRotatef((System.currentTimeMillis() / 32) % 360, 0F, 1F, 0F); - GL11.glTranslated(-3, 0, 0); - GL11.glRotatef((System.currentTimeMillis() / 2) % 360, 0F, 1F, 0F); - renderBlockInWorld(ModBlocks.blocks.get("DD"), 0, 1.0f); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glTranslated(6, 0, 0); - renderBlockInWorld(ModBlocks.blocks.get("Ne"), 0, 0.5f); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glTranslated(0, 0, 6); - renderBlockInWorld(ModBlocks.blocks.get("Mo"), 0, 1.0f); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glTranslated(0, 0, -6); - renderBlockInWorld(ModBlocks.blocks.get("Ow"), 0, 2.0f); - GL11.glPopMatrix(); - + if (EOHRenderTile.getOrbitingBody() != null) { + // Render orbiting body. + GL11.glPushMatrix(); + GL11.glRotatef((System.currentTimeMillis() / 32) % 360, 0F, 1F, 0F); + GL11.glTranslated(-1 - EOHRenderTile.getSize() * pow(1.05f, 2), 0, 0); + GL11.glRotatef((System.currentTimeMillis() / 2) % 360, 0F, 1F, 0F); + renderBlockInWorld(EOHRenderTile.getOrbitingBody(), 0, 0.7f); + GL11.glPopMatrix(); + } + // Render star stuff. + // Render a black hole if the dimension is the deep dark. if (EOHRenderTile.getTier() < 9) { renderStarLayer(EOHRenderTile, 0, starLayer0, 1.0f); renderStarLayer(EOHRenderTile, 1, starLayer1, 0.4f); @@ -82,13 +56,10 @@ public class RenderEyeOfHarmony extends TileEntitySpecialRenderer { } else { renderStarLayer(EOHRenderTile, 0, blackHole, 1.0f); } - GL11.glPopMatrix(); } - } - void renderStarLayer(TileEyeOfHarmony EOHRenderTile, int layer, ResourceLocation texture, float alpha) { // Begin animation. @@ -118,9 +89,6 @@ public class RenderEyeOfHarmony extends TileEntitySpecialRenderer { // Scale the star up in the x, y and z directions. GL11.glScalef(scale, scale, scale); - // Rotate star upright. -// GL11.glRotatef(180, 1F, 1F, 1F); - switch (layer) { case 0: GL11.glRotatef(194, 0F, 1F, 1F); @@ -140,7 +108,7 @@ public class RenderEyeOfHarmony extends TileEntitySpecialRenderer { GL11.glColor4f(starRed, starGreen, starBlue, alpha); // Spin the star around according to the multis time dilation tier. - if (EOHRenderTile.getRotationSpeed() != 0) { + if ((int) EOHRenderTile.getRotationSpeed() != 0) { GL11.glRotatef((System.currentTimeMillis() / (int) EOHRenderTile.getRotationSpeed()) % 360, 0F, 0F, 1F); } @@ -153,47 +121,6 @@ public class RenderEyeOfHarmony extends TileEntitySpecialRenderer { GL11.glPopMatrix(); } - - class SphericalCoord { - - - - } - class RotationInfo { - - float angle; - boolean xEnabled = false; - boolean yEnabled = false; - boolean zEnabled = false; - RotationInfo(float angle) { - this.angle = angle; - } - - void enableXRotation() { - xEnabled = true; - } - - void enableYRotation() { - xEnabled = true; - } - - void enableZRotation() { - xEnabled = true; - } - - -// void performRotation() { -// GL11.glRotatef(-180, xEnabled, 0F, 1F); -// -// } - - - - - } - - - public void renderBlockInWorld(Block block, int meta, float blockSize) { Tessellator tes = Tessellator.instance; @@ -210,18 +137,15 @@ public class RenderEyeOfHarmony extends TileEntitySpecialRenderer { GL11.glEnable(GL11.GL_BLEND); tes.setColorOpaque_F(1f, 1f, 1f); - //Add the rendering calls here (Can and should use helper functions that do the vertex calls) + // Add the rendering calls here (Can and should use helper functions that do the vertex calls) double x = 0; double y = 0; double z = 0; - double[] X = {x - 0.5 , x - 0.5 , x + 0.5 , x + 0.5 , - x + 0.5 , x + 0.5 , x - 0.5 , x - 0.5 }; - double[] Y = {y + 0.5 , y - 0.5 , y - 0.5 , y + 0.5 , - y + 0.5 , y - 0.5 , y - 0.5 , y + 0.5 }; - double[] Z = {z + 0.5 , z + 0.5 , z + 0.5 , z + 0.5 , - z - 0.5 , z - 0.5 , z - 0.5 , z - 0.5 }; + double[] X = {x - 0.5, x - 0.5, x + 0.5, x + 0.5, x + 0.5, x + 0.5, x - 0.5, x - 0.5}; + double[] Y = {y + 0.5, y - 0.5, y - 0.5, y + 0.5, y + 0.5, y - 0.5, y - 0.5, y + 0.5}; + double[] Z = {z + 0.5, z + 0.5, z + 0.5, z + 0.5, z - 0.5, z - 0.5, z - 0.5, z - 0.5}; tes.startDrawingQuads(); @@ -325,19 +249,6 @@ public class RenderEyeOfHarmony extends TileEntitySpecialRenderer { GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_CULL_FACE); - //spotless:on - } - - Vector3d f(int time) { - - final int radius = 4; - final double azimuthalAngle = PI * 0.4; - - final double x = radius * sin(azimuthalAngle) * cos(time); - final double y = radius * sin(azimuthalAngle) * sin(time); - final double z = radius * cos(azimuthalAngle); - - return new Vector3d(x, y, z); + // spotless:on } } - diff --git a/src/main/java/com/github/technus/tectech/thing/block/TileEyeOfHarmony.java b/src/main/java/com/github/technus/tectech/thing/block/TileEyeOfHarmony.java index f584710361..77a4ae5433 100644 --- a/src/main/java/com/github/technus/tectech/thing/block/TileEyeOfHarmony.java +++ b/src/main/java/com/github/technus/tectech/thing/block/TileEyeOfHarmony.java @@ -1,5 +1,9 @@ package com.github.technus.tectech.thing.block; +import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_EyeOfHarmony.errorStar; + +import java.awt.*; +import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; @@ -7,10 +11,6 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; -import java.awt.*; - -import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_EyeOfHarmony.errorStar; - public class TileEyeOfHarmony extends TileEntity { // Prevent culling when block is out of frame so model can remain active. @@ -31,20 +31,30 @@ public class TileEyeOfHarmony extends TileEntity { private float rotationSpeed = 0; private Color colour = errorStar; - public int getTier() { + public Block getOrbitingBody() { + return orbitingBody; + } + + public void setOrbitingBody(Block orbitingBody) { + this.orbitingBody = orbitingBody; + } + + private Block orbitingBody; + + public long getTier() { return tier; } - public void setTier(int tier) { + public void setTier(long tier) { this.tier = tier; } - private int tier = -1; + private long tier = -1; + public void incrementSize() { size += 1.5f; } - public void setColour(Color colour) { this.colour = colour; } @@ -71,7 +81,8 @@ public class TileEyeOfHarmony extends TileEntity { private static final String sizeRedNBTTag = EOHNBTTag + "red"; private static final String sizeGreenNBTTag = EOHNBTTag + "green"; private static final String sizeBlueNBTTag = EOHNBTTag + "blue"; - + private static final String orbitingBodyIDNBTTag = EOHNBTTag + "orbitingBodyID"; + private static final String tierNBTTag = EOHNBTTag + "tier"; @Override public void writeToNBT(NBTTagCompound compound) { @@ -80,11 +91,17 @@ public class TileEyeOfHarmony extends TileEntity { // Save other stats. compound.setFloat(rotationSpeedNBTTag, rotationSpeed); compound.setFloat(sizeNBTTag, size); + compound.setLong(tierNBTTag, tier); // Save colour info. compound.setInteger(sizeRedNBTTag, colour.getRed()); - compound.setInteger(sizeGreenNBTTag, colour.getBlue()); - compound.setInteger(sizeBlueNBTTag, colour.getGreen()); + compound.setInteger(sizeGreenNBTTag, colour.getGreen()); + compound.setInteger(sizeBlueNBTTag, colour.getBlue()); + + if (orbitingBody != null) { + int blockID = Block.getIdFromBlock(orbitingBody); + compound.setInteger(orbitingBodyIDNBTTag, blockID); + } } @Override @@ -94,12 +111,18 @@ public class TileEyeOfHarmony extends TileEntity { // Load other stats. rotationSpeed = compound.getFloat(rotationSpeedNBTTag); size = compound.getFloat(sizeNBTTag); + tier = compound.getLong(tierNBTTag); // Load colour info. int red = compound.getInteger(sizeRedNBTTag); int green = compound.getInteger(sizeGreenNBTTag); int blue = compound.getInteger(sizeBlueNBTTag); colour = new Color(red, green, blue); + + if (compound.hasKey(orbitingBodyIDNBTTag)) { + int blockID = compound.getInteger(orbitingBodyIDNBTTag); + orbitingBody = Block.getBlockById(blockID); + } } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsBA0.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsBA0.java index 3f819dd369..15aeabda4c 100644 --- a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsBA0.java +++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsBA0.java @@ -67,9 +67,12 @@ public class GT_Block_CasingsBA0 extends GT_Block_Casings_Abstract { GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Tesla Toroid Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Tesla Secondary Windings"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Ultimate Temporal Boundary Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Reinforced Spacetime Structure Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Infinite Spacetime Energy Boundary Casing"); + GT_LanguageManager.addStringLocalization( + getUnlocalizedName() + ".10.name", "Ultimate Temporal Boundary Casing"); + GT_LanguageManager.addStringLocalization( + getUnlocalizedName() + ".11.name", "Reinforced Spacetime Structure Casing"); + GT_LanguageManager.addStringLocalization( + getUnlocalizedName() + ".12.name", "Infinite Spacetime Energy Boundary Casing"); CustomItemList.tM_TeslaPrimary_0.set(new ItemStack(this, 1, 0)); CustomItemList.tM_TeslaPrimary_1.set(new ItemStack(this, 1, 1)); diff --git a/src/main/java/com/github/technus/tectech/thing/casing/TT_Container_Casings.java b/src/main/java/com/github/technus/tectech/thing/casing/TT_Container_Casings.java index aba49de5a5..97779cd6ba 100644 --- a/src/main/java/com/github/technus/tectech/thing/casing/TT_Container_Casings.java +++ b/src/main/java/com/github/technus/tectech/thing/casing/TT_Container_Casings.java @@ -13,10 +13,8 @@ public final class TT_Container_Casings { public static Block sBlockCasingsNH; - // Do NOT delete, it will break. The IDE is a liar. public static Block eyeOfHarmonyRenderBlock = new EyeOfHarmonyBlock(); - private TT_Container_Casings() {} } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java index 564d6a8924..10972eb6a4 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java @@ -1,5 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; +import static com.github.technus.tectech.TecTech.eyeOfHarmonyRecipeStorage; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.eyeOfHarmonyRenderBlock; @@ -39,17 +40,15 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Outpu import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_OutputBus_ME; import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_Output_ME; - import java.awt.*; import java.util.*; import java.util.List; - +import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.IIcon; import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.tuple.Pair; import org.spongepowered.libraries.com.google.common.math.LongMath; @@ -61,8 +60,6 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl private static Textures.BlockIcons.CustomIcon ScreenOFF; private static Textures.BlockIcons.CustomIcon ScreenON; - private static EyeOfHarmonyRecipeStorage recipes; - private int spacetimeCompressionFieldMetadata = -1; private int timeAccelerationFieldMetadata = -1; private int stabilisationFieldMetadata = -1; @@ -1513,7 +1510,7 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl } } - // Make sure there is 2 input hatches. + // Make sure there are 2 input hatches. if (mInputHatches.size() != 2) { return false; } @@ -1577,8 +1574,8 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl .addInfo("exotic material that rejects conventional physics.") .addSeparator() .addStructureInfo("Eye of Harmony structure is too complex! See schematic for details.") - .addStructureInfo( - EnumChatFormatting.GOLD + "896" + EnumChatFormatting.GRAY + " Reinforced Spacetime Structure Casing.") + .addStructureInfo(EnumChatFormatting.GOLD + "896" + EnumChatFormatting.GRAY + + " Reinforced Spacetime Structure Casing.") .addStructureInfo(EnumChatFormatting.GOLD + "534" + EnumChatFormatting.GRAY + " Ultimate Temporal Boundary Casing.") .addStructureInfo( @@ -1662,7 +1659,10 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl private EyeOfHarmonyRecipe currentRecipe; + // Counter for lag prevention. private long lagPreventer = 0; + + // Check for recipe every recipeCheckInterval ticks. private final long recipeCheckInterval = 3 * 20; @Override @@ -1676,7 +1676,7 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl lagPreventer = 0; // No item in multi gui slot. - currentRecipe = recipes.recipeLookUp(aStack); + currentRecipe = eyeOfHarmonyRecipeStorage.recipeLookUp(aStack); if (processRecipe(currentRecipe)) { return true; } @@ -1777,27 +1777,38 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl double zOffset = 16 * getExtendedFacing().getRelativeBackInWorld().offsetZ; double yOffset = 16 * getExtendedFacing().getRelativeBackInWorld().offsetZ; - this.getBaseMetaTileEntity().getWorld().setBlock((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset), Blocks.air); - this.getBaseMetaTileEntity().getWorld().setBlock((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset), eyeOfHarmonyRenderBlock); - TileEyeOfHarmony rendererTileEntity = (TileEyeOfHarmony) this.getBaseMetaTileEntity().getWorld().getTileEntity((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset)); + this.getBaseMetaTileEntity() + .getWorld() + .setBlock((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset), Blocks.air); + this.getBaseMetaTileEntity() + .getWorld() + .setBlock((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset), eyeOfHarmonyRenderBlock); + TileEyeOfHarmony rendererTileEntity = (TileEyeOfHarmony) + this.getBaseMetaTileEntity().getWorld().getTileEntity((int) (x + xOffset), (int) (y + yOffset), (int) + (z + zOffset)); int recipeSpacetimeTier = (int) currentRecipe.getSpacetimeCasingTierRequired(); // Star is a larger size depending on the spacetime tier of the recipe. - rendererTileEntity.setSize((1 + recipeSpacetimeTier) * 0.5f); + rendererTileEntity.setSize((1 + recipeSpacetimeTier)); + // Star rotates faster the higher tier time dilation you use in the multi. - rendererTileEntity.setRotationSpeed((float) pow(2, 8-timeAccelerationFieldMetadata)); + // Lower value = faster rotation speed. + rendererTileEntity.setRotationSpeed( + (float) pow(2, currentRecipe.getRocketTier() - timeAccelerationFieldMetadata)); // Colour of tier determined by star tier. - Color colour = getStarColour(recipeSpacetimeTier); + Color colour = getStarColour((int) currentRecipe.getRocketTier()); rendererTileEntity.setColour(colour); // Set recipe spacetime tier for usage elsewhere. - rendererTileEntity.setTier(recipeSpacetimeTier); + rendererTileEntity.setTier(currentRecipe.getRocketTier()); + rendererTileEntity.setOrbitingBody( + Block.getBlockFromItem(currentRecipe.getRecipeTriggerItem().getItem())); } - private static final Color redStar = new Color(255, 0, 50); - private static final Color orangeStar = new Color(255, 102, 0); + private static final Color redStar = new Color(155, 9, 38); + private static final Color orangeStar = new Color(190, 85, 9); private static final Color blueStar = new Color(96, 152, 234); private static final Color whiteStar = new Color(200, 200, 200); private static final Color blackHole = new Color(0, 0, 0); @@ -1841,10 +1852,28 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl recipeRunning = false; } + private void destroyRenderBlock() { + IGregTechTileEntity gregTechTileEntity = this.getBaseMetaTileEntity(); + + int x = gregTechTileEntity.getXCoord(); + int y = gregTechTileEntity.getYCoord(); + int z = gregTechTileEntity.getZCoord(); + + double xOffset = 16 * getExtendedFacing().getRelativeBackInWorld().offsetX; + double zOffset = 16 * getExtendedFacing().getRelativeBackInWorld().offsetZ; + double yOffset = 16 * getExtendedFacing().getRelativeBackInWorld().offsetZ; + + this.getBaseMetaTileEntity() + .getWorld() + .setBlock((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset), Blocks.air); + } + public void outputAfterRecipe_EM() { recipeRunning = false; eRequiredData = 0L; + destroyRenderBlock(); + if (successChance < random()) { outputFailedChance(); outputItems = new ArrayList<>(); @@ -1881,12 +1910,6 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl userUUID = String.valueOf(getBaseMetaTileEntity().getOwnerUuid()); userName = getBaseMetaTileEntity().getOwnerName(); strongCheckOrAddUser(userUUID, userName); - - // If no multi exists this will set the recipe storage. - // This must be done after game load otherwise it fails. - if (recipes == null) { - recipes = new EyeOfHarmonyRecipeStorage(); - } } // Add computation to stack. Prevents small interruptions causing issues. |