Search in sources :

Example 1 with EntityTier1Rocket

use of micdoodle8.mods.galacticraft.core.entities.EntityTier1Rocket in project Galacticraft by micdoodle8.

the class OverlayRocket method renderSpaceshipOverlay.

/**
 * Render the GUI when player is in inventory
 */
public static void renderSpaceshipOverlay(ResourceLocation guiTexture) {
    if (guiTexture == null) {
        return;
    }
    final ScaledResolution scaledresolution = ClientUtil.getScaledRes(OverlayRocket.minecraft, OverlayRocket.minecraft.displayWidth, OverlayRocket.minecraft.displayHeight);
    scaledresolution.getScaledWidth();
    final int height = scaledresolution.getScaledHeight();
    OverlayRocket.minecraft.entityRenderer.setupOverlayRendering();
    GlStateManager.depthMask(true);
    GlStateManager.enableTexture2D();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(guiTexture);
    float var1 = 0F;
    float var2 = height / 2 - 170 / 2;
    float var3 = 0.0F;
    float var3b = 0.0F;
    float var4 = 0.0F;
    float var5 = 1.0F;
    float var6 = 1.0F;
    float var7 = 1.0F;
    float var8 = 1.0F;
    float sizeScale = 0.65F;
    final Tessellator tess = Tessellator.getInstance();
    WorldRenderer worldRenderer = tess.getWorldRenderer();
    worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
    worldRenderer.pos(var1 + 0, var2 + 242.0F * sizeScale, 0.0).tex((var3 + 0) * var7, (var4 + var6) * var8).endVertex();
    worldRenderer.pos(var1 + 20.0F * sizeScale, var2 + 242.0F * sizeScale, 0.0).tex((var3 + var5) * var7, (var4 + var6) * var8).endVertex();
    worldRenderer.pos(var1 + 20.0F * sizeScale, var2 + 0, 0.0).tex((var3 + var5) * var7, (var4 + 0) * var8).endVertex();
    worldRenderer.pos(var1 + 0, var2 + 0, 0.0).tex((var3 + 0) * var7, (var4 + 0) * var8).endVertex();
    tess.draw();
    GlStateManager.color(1.0F, 1.0F, 1.0F);
    Entity rocket = OverlayRocket.minecraft.thePlayer.ridingEntity;
    float headOffset = 0;
    if (rocket instanceof EntityTier1Rocket) {
        headOffset = 5F;
    }
    Render spaceshipRender = (Render) minecraft.getRenderManager().entityRenderMap.get(rocket.getClass());
    final int y1 = height / 2 + 60 - (int) Math.floor(Overlay.getPlayerPositionY(OverlayRocket.minecraft.thePlayer) / 10.5F);
    var1 = 2.5F;
    var2 = y1;
    var3 = 8;
    var3b = 40;
    var4 = 8;
    var5 = 8;
    var6 = 8;
    var7 = 1.0F / 64.0F;
    var8 = 1.0F / 64.0F;
    GlStateManager.pushMatrix();
    final int i = rocket.getBrightnessForRender(1);
    final int j = i % 65536;
    final int k = i / 65536;
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.enableColorMaterial();
    GlStateManager.translate(var1 + 4, var2 + 6, 50F);
    GlStateManager.scale(5F, 5F, 5F);
    GlStateManager.rotate(180F, 1, 0, 0);
    GlStateManager.rotate(90F, 0, 1, 0);
    try {
        spaceshipRender.doRender(rocket.getClass().getConstructor(World.class).newInstance(OverlayRocket.minecraft.thePlayer.worldObj), 0, 0, 0, 0, 0);
    } catch (Exception e) {
        e.printStackTrace();
    }
    GlStateManager.popMatrix();
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(ClientProxyCore.playerHead);
    GlStateManager.disableLighting();
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(770, 771);
    GlStateManager.translate(0F, -12F + headOffset, 60F);
    worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
    worldRenderer.pos(var1 + 0, var2 + var6, 0.0).tex((var3 + 0) * var7, (var4 + var6) * var8).endVertex();
    worldRenderer.pos(var1 + var5, var2 + var6, 0.0).tex((var3 + var5) * var7, (var4 + var6) * var8).endVertex();
    worldRenderer.pos(var1 + var5, var2 + 0, 0.0).tex((var3 + var5) * var7, (var4 + 0) * var8).endVertex();
    worldRenderer.pos(var1 + 0, var2 + 0, 0.0).tex((var3 + 0) * var7, (var4 + 0) * var8).endVertex();
    tess.draw();
    worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
    worldRenderer.pos(var1 + 0, var2 + var6, 0.0).tex((var3b + 0) * var7, (var4 + var6) * var8).endVertex();
    worldRenderer.pos(var1 + var5, var2 + var6, 0.0).tex((var3b + var5) * var7, (var4 + var6) * var8).endVertex();
    worldRenderer.pos(var1 + var5, var2 + 0, 0.0).tex((var3b + var5) * var7, (var4 + 0) * var8).endVertex();
    worldRenderer.pos(var1 + 0, var2 + 0, 0.0).tex((var3b + 0) * var7, (var4 + 0) * var8).endVertex();
    tess.draw();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.enableLighting();
    GlStateManager.disableBlend();
}
Also used : Entity(net.minecraft.entity.Entity) ScaledResolution(net.minecraft.client.gui.ScaledResolution) Tessellator(net.minecraft.client.renderer.Tessellator) Render(net.minecraft.client.renderer.entity.Render) EntityTier1Rocket(micdoodle8.mods.galacticraft.core.entities.EntityTier1Rocket) WorldRenderer(net.minecraft.client.renderer.WorldRenderer)

Example 2 with EntityTier1Rocket

use of micdoodle8.mods.galacticraft.core.entities.EntityTier1Rocket in project Galacticraft by micdoodle8.

the class ItemTier1Rocket method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack par1ItemStack, EntityPlayer player, List<String> tooltip, boolean b) {
    EnumRocketType type = EnumRocketType.values()[par1ItemStack.getItemDamage()];
    if (!type.getTooltip().isEmpty()) {
        tooltip.add(type.getTooltip());
    }
    if (type.getPreFueled()) {
        tooltip.add(EnumColor.RED + "\u00a7o" + GCCoreUtil.translate("gui.creative_only.desc"));
    }
    if (par1ItemStack.hasTagCompound() && par1ItemStack.getTagCompound().hasKey("RocketFuel")) {
        EntityTier1Rocket rocket = new EntityTier1Rocket(FMLClientHandler.instance().getWorldClient(), 0, 0, 0, EnumRocketType.values()[par1ItemStack.getItemDamage()]);
        tooltip.add(GCCoreUtil.translate("gui.message.fuel.name") + ": " + par1ItemStack.getTagCompound().getInteger("RocketFuel") + " / " + rocket.fuelTank.getCapacity());
    }
}
Also used : EnumRocketType(micdoodle8.mods.galacticraft.api.entity.IRocketType.EnumRocketType) EntityTier1Rocket(micdoodle8.mods.galacticraft.core.entities.EntityTier1Rocket) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with EntityTier1Rocket

use of micdoodle8.mods.galacticraft.core.entities.EntityTier1Rocket in project Galacticraft by micdoodle8.

the class ItemTier1Rocket method placeRocketOnPad.

public static boolean placeRocketOnPad(ItemStack stack, World worldIn, TileEntity tile, float centerX, float centerY, float centerZ) {
    // Check whether there is already a rocket on the pad
    if (tile instanceof TileEntityLandingPad) {
        if (((TileEntityLandingPad) tile).getDockedEntity() != null) {
            return false;
        }
    } else {
        return false;
    }
    final EntityTier1Rocket spaceship = new EntityTier1Rocket(worldIn, centerX, centerY, centerZ, EnumRocketType.values()[stack.getItemDamage()]);
    spaceship.setPosition(spaceship.posX, spaceship.posY + spaceship.getOnPadYOffset(), spaceship.posZ);
    worldIn.spawnEntityInWorld(spaceship);
    if (spaceship.rocketType.getPreFueled()) {
        spaceship.fuelTank.fill(new FluidStack(GCFluids.fluidFuel, spaceship.getMaxFuel()), true);
    } else if (stack.hasTagCompound() && stack.getTagCompound().hasKey("RocketFuel")) {
        spaceship.fuelTank.fill(new FluidStack(GCFluids.fluidFuel, stack.getTagCompound().getInteger("RocketFuel")), true);
    }
    return true;
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) EntityTier1Rocket(micdoodle8.mods.galacticraft.core.entities.EntityTier1Rocket) TileEntityLandingPad(micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad)

Aggregations

EntityTier1Rocket (micdoodle8.mods.galacticraft.core.entities.EntityTier1Rocket)3 EnumRocketType (micdoodle8.mods.galacticraft.api.entity.IRocketType.EnumRocketType)1 TileEntityLandingPad (micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad)1 ScaledResolution (net.minecraft.client.gui.ScaledResolution)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 WorldRenderer (net.minecraft.client.renderer.WorldRenderer)1 Render (net.minecraft.client.renderer.entity.Render)1 Entity (net.minecraft.entity.Entity)1 FluidStack (net.minecraftforge.fluids.FluidStack)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1