Jump to content

Recommended Posts

Posted

Hi, I am testing a code that I did based on a sample that seen in a tuttorial, succeeded in part, the only problem I am having is that the image I'm trying to draw on the screen is not being fully drawn, as if the its resolution is changed when it is loaded by minecraft.

 

look the code:

 

testemod (Main class)

package teste;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod(modid = testemod.MODID, name = testemod.NAME, version = testemod.VERSION)
public class testemod {
public static final String MODID = "testemod";
public static final String NAME = "Testemod";
public static final String VERSION = "1.0";

public static Block myFirstContainerBlock;

@Instance ( "testemod" )
    public static testemod instance;

    @SidedProxy ( clientSide = "teste.ClientProxy", serverSide = "teste.CommonProxy" )
    public static CommonProxy proxy;


@EventHandler
public void preinit(FMLPreInitializationEvent event) {
	myFirstContainerBlock = new MyFirstContainerBlock(Material.rock)
			.setHardness(0.5F).setStepSound(Block.soundTypeStone)
			.setBlockName("myFirstContainerBlock")
			.setBlockTextureName("testemod:OsmiumOre")
			.setCreativeTab(CreativeTabs.tabBlock);
	GameRegistry.registerBlock(myFirstContainerBlock,
			"myFirstContainerBlock");
	NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
}
}

 

GuiBasic (GuiScreen class)

package teste;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.ResourceLocation;

public class GuiBasic extends GuiScreen {
public static final int GUI_ID = 20;

int guiWidth = 140;
int guiHeight = 80;

@Override
public void drawScreen(int x, int y, float ticks) {
	int guiX = (width - guiWidth) / 2;
	int guiY = (height - guiHeight) / 2;
	GL11.glColor4f(1, 1, 1, 1);
	drawDefaultBackground();
	mc.renderEngine.bindTexture(new ResourceLocation(testemod.MODID,
			"textures/gui/Gui2.png"));
	drawTexturedModalRect(guiX, guiY, 0, 0, guiWidth, guiHeight);
	super.drawScreen(x, y, ticks);
}
}

 

CommonProxy (implements IGuiHandler)

package teste;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;

import cpw.mods.fml.common.network.IGuiHandler;

public class CommonProxy implements IGuiHandler {

//public void registerKeyBindings() {
//}

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world,
		int x, int y, int z) {
	return null;
}

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world,
		int x, int y, int z) {
	if (ID == GuiBasic.GUI_ID)
		return new GuiBasic();

	return null;
}
}

 

MyFirstContainerBlock (the block start event)

package teste;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;

public class MyFirstContainerBlock extends Block {

protected MyFirstContainerBlock(Material mat) {
	super(mat);
}

@Override
public boolean onBlockActivated(World p_149727_1_, int p_149727_2_,
		int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_,
		int p_149727_6_, float p_149727_7_, float p_149727_8_,
		float p_149727_9_) {
	Minecraft.getMinecraft().displayGuiScreen(new GuiBasic());

	return super.onBlockActivated(p_149727_1_, p_149727_2_, p_149727_3_,
			p_149727_4_, p_149727_5_, p_149727_6_, p_149727_7_,
			p_149727_8_, p_149727_9_);
}
}

 

my custom screen image (this have 140x80 resolution)

width=140 height=80https://scontent-a-mia.xx.fbcdn.net/hphotos-xap1/v/t1.0-9/10418987_758054787617239_8936067923206037565_n.jpg?oh=833c46c7a3a02b712def870bc859f452&oe=54DB4040[/img]

 

the result screen displayed

width=702 height=395https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-xpa1/t31.0-8/p526x395/10835024_758054930950558_3083716366299205453_o.jpg[/img]

 

tutorial link (what i'm based)

 

then there are any solution?

Posted

I had this same problem. All you have to do is make your texture file to 256 by 256 pixels. Also you have to delete all the white space around it.

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.