
joaopms
Members-
Posts
36 -
Joined
-
Last visited
Everything posted by joaopms
-
I have a block and I need to color it based on the biome he is in, like a block of grass. I'm currently using the grass' methods, but it colors all sides.
-
[Solved] Getting block's textures - Sided and Metadata textures
joaopms replied to joaopms's topic in Modder Support
Yes, yes it is! Thank you very much! -
I have a block that set's it's textures when someone right clicks it with a block on theur wand. I'm saving it's ID and metadata to the block's tile entity's NBT data. Now I need a way to get a block's metadata and sided textures. I'm already doing it using "getBlockTexture" and "Block.blocksList[tile.blockCamouflageID].getBlockTexture(block, x, y, z, side);", but now, how can I do it with metadata? Thank you!
-
[Solved] Tile Entity returns wrong data to Block
joaopms replied to joaopms's topic in Modder Support
That worked! Thank you very much! -
I have a block that let's you change it's texture by right clicking it with a block in your wand. I'm saving a boolean called "isPersonalized" (if the block was a custom texture, then is true) and an integer called "blockCamouflageID" (if the block was a custum texture, then is the block's ID you chosed) on the block's tile entity's NBT data. Everything is getting saved, but when I call the tile entity and get the data from it, on my "getBlockTexture()" method, it returns "false" for the "isPersonalized" variable and "0" for the "blockCamouflageID" variable (I'm invoking the entity using "TileEntityIluminator tile = (TileEntityIluminator) world.getBlockTileEntity(x, y, z)" and getting the variables by using "tile.isPersonalized" and "tile.blockCamouflageID"). Now, if I output the "this.isPersonalized" and "this.blockCamouflageID" from the tile entity's "readFromNBT()" method, it is correct. Resuming: it is correct on the tile entity but not on the block. I'm not sure if I need to use a packet, they are confusing to me.
-
First of all, what are you trying to do? Second, what is at the line 68 at BetterMinecraftMod.java?
-
Wow, I'm so stupid! -.- Thank you very much, you just saved me from a huge rage.
-
Eval() is evil. Do not use. So, do you have any idea on what I can do?
-
Yes I know, it returns an Icon. And I want to like build a string and the run the string like it was an argument.
-
Yes, but I want to use the "tile.blockName" like I'm building a string, so it should be like this (I know this isn't going to work): Block. + tile.blockName + .getBlockTextureFromSide(0); I don't know if it is possible, but still.
-
Look at GuiSelectWorld.java, it may help you
-
On my onBlockActivated I have this method to have access to my tile entity: TileEntityIluminator tile = (TileEntityIluminator) world.getBlockTileEntity(x, y, z); Then I have a string variable on my tile entity called blockName. I can read/write to it by doing "tile.blockName = "[blockName]". Now I want to replace the "stone" part with my variable, "tile.blockName".
-
I'm trying to get a texture from a block when you right click my block with a block in your wand. That works and it is writing the block name to my block's Tile Entity's NBT Data. Now I want to get the texture from the block from the NBT Data, and for that I'm using this piece of code: Block.blocksList[stone.itemID].getBlockTextureFromSide(0); Now I want to replace the "stone" with the block name from my NBT Data. Is that possible? Is there a easiest way to do it? Thanks!
-
Since Mac OS is based on Linux, it should be "bash install.sh" or "sh install.sh"
-
Yes, you just need to modify the hex color. For example, red is 0xFF0000, blue is 0x0000FF, green is 0x006400, purple is 0x6A5ACD and black is 0x000000. Source: http://www.minecraftforum.net/topic/1412300-147forgeblaueseichoerns-gui-tutorial/
-
Argh, packets are so complicated! I will do Vswe's Courses before I continue to code.
-
Yes, I've changed the static value. Do something to the tile entity? I think I already have that: the identificationName string is used to read the packet and then send save it to NBT.
-
Yeah, I will need to do that. Checking it when I need it isn't enought. Thanks!
-
Hmm... didn't know about that. But I've changed it and it persists: public class TileEntityIdentification extends TileEntity { public String name; public TileEntityIdentification() { } public void setName(String s) { name = s; //called from the packethandler via the gui System.out.println("setName: " + name); // this works } public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); name = nbt.getString("name"); // returns null - should return the name on the block (get) PacketHandler.setIdentificationName(name); // returns null - should return the name on the block (get) || to be used on the gui System.out.println("Read NBT: " + name); // this doesn't work because it doesn't have any data, yet } public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); System.out.println("NBT Write: " + name); // this fails nbt.setString("name", name); // is null - should be the name on the block (set) || set from the gui via packet } public String getName() { System.out.println("getName: " + name); // this fails return name; // returns null - should return the name on the block (get) } }
-
Go to %appdata%/.minecraft and search for the mods folder. I'm not sure how is the folder structure for Forge 1.6, but it should be on the .minecraft
-
I have another problem: my variables aren't working as they should (check the code): public class TileEntityIdentification extends TileEntity { public String setName; public String getName; public TileEntityIdentification() { } public void setName(String s) { setName = s; //called from the packethandler via the gui System.out.println("setName: " + setName); // this works } public String getName() { //System.out.println("getName: " + getName); return getName; // returns null - should return the name on the block (get) } public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); getName = nbt.getString("name"); // returns null - should return the name on the block (get) PacketHandler.setIdentificationName(getName); // returns null - should return the name on the block (get) || to be used on the gui //System.out.println("Read NBT: " + getName); } public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); //System.out.println("NBT Write: " + setName); nbt.setString("name", setName); // is null - should be the name on the block (set) || set from the gui via packet } }
-
Okay, I've done the packet thing, but it stays the same because the string is static and if I try to change it, it throws me a couple of errors, like "Cannot make a static reference to the non-static method getIdentificationName() from the type PacketHandler" and it only allows me to change it back to static. Nevermind, I was forgetting how to do it properly.
-
Man, Packets are confusing and complicated and took me almost 4 hours to figure that out, but I did it - I think - but when I set the name and close and then open the GUI it doesn't get the new name (unless I log out). Also, every Block was the same name and every block should have their own name. Here's my code if you need it: BlockIdentification.java public class BlockIdentification extends BlockContainer { public BlockIdentification(int id, Material material) { super(id, material); setHardness(2.0F); setStepSound(Block.soundStoneFootstep); setUnlocalizedName("identificationBlock"); setCreativeTab(UsefulBlocks.tabUsefulBlocks); } public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7, float par8, float par9) { TileEntityIdentification t = (TileEntityIdentification) world.getBlockTileEntity(x, y, z); t.update(world); player.openGui(UsefulBlocks.instance, 0, world, x, y, z); return true; } @Override public boolean hasTileEntity(int meta) { return true; } @Override public TileEntity createNewTileEntity(World world) { return new TileEntityIdentification(); } } TileEntity.java public class TileEntityIdentification extends TileEntity { private static String name; public TileEntityIdentification() { } @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); if (PacketHandler.getIdentificationName() != null) { nbt.setString("name", PacketHandler.getIdentificationName()); } System.out.println("NBT - Write"); } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); TileEntityIdentification.name = nbt.getString("name"); System.out.println("NBT: " + TileEntityIdentification.name); PacketHandler.setIdentificationName(name); } public static String getName() { return name; } public void update(World world) { world.notifyBlockChange(xCoord, yCoord, zCoord, 2); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } } GuiIdentification.java public class GuiIdentification extends GuiScreen { public final int xSize = 176; public final int ySize = 88; private GuiTextField name; private String nameString; public GuiIdentification(TileEntityIdentification tileEntity) { } @SuppressWarnings("unchecked") @Override public void initGui() { Keyboard.enableRepeatEvents(true); int posX = (this.width - xSize) / 2; int posY = (this.height - ySize) / 2; this.buttonList.add(new GuiButton(0, posX + 7, posY + 60, 162, 20, "Set Player Name")); this.name = new GuiTextField(this.fontRenderer, posX + 8, posY + 35, 160, 20); this.name.setFocused(true); if (TileEntityIdentification.getName() != null) { this.name.setText(TileEntityIdentification.getName()); } } @Override public void drawScreen(int x, int y, float f) { this.drawDefaultBackground(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.renderEngine.func_110577_a(new ResourceLocation("usefulblocks:textures/gui/IdentificationBlock.png")); int posX = (this.width - xSize) / 2; int posY = (this.height - ySize) / 2; this.drawTexturedModalRect(posX, posY, 0, 0, xSize, ySize); this.fontRenderer.drawString("Identification Block", posX + 40, posY + 15, 4210752); this.name.drawTextBox(); super.drawScreen(x, y, f); } @Override public boolean doesGuiPauseGame() { return false; } @Override public void onGuiClosed() { Keyboard.enableRepeatEvents(false); } @Override public void updateScreen() { name.updateCursorCounter(); } @Override protected void mouseClicked(int par1, int par2, int par3) { super.mouseClicked(par1, par2, par3); name.mouseClicked(par1, par2, par3); } protected void actionPerformed(GuiButton par1GuiButton) { if (par1GuiButton.enabled) { if (par1GuiButton.id == 0) { System.out.println("Name: " + nameString); if (nameString != null) { PacketHandler.setIdentificationName(nameString); } } } } @Override protected void keyTyped(char par1, int par2) { if (name.isFocused()) { name.textboxKeyTyped(par1, par2); nameString = name.getText(); } if (par2 == 1) { this.mc.thePlayer.closeScreen(); } } } } PacketHandler.java public class PacketHandler implements IPacketHandler { private static String identificationName; @Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { ByteArrayDataInput reader = ByteStreams.newDataInput(packet.data); identificationName = reader.readUTF(); } public static void setIdentificationName(String name) { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); DataOutputStream dataStream = new DataOutputStream(byteStream); try { dataStream.writeUTF(name); } catch (IOException e) { System.err.append("Failed to send identification name packet"); } System.out.println("Packet: " + name); PacketDispatcher.sendPacketToServer(PacketDispatcher.getPacket(Reference.ModID, byteStream.toByteArray())); } public static String getIdentificationName() { System.out.println("Packet Read: " + identificationName); return identificationName; } }
-
I have a GuiScreen and you can access it by right clicking a block. There, you can set the name of the player you want to detect when it is touching the block (I'm still working on it). If the block already was a name set, it will get it from the TileEntity NBT Data, and when you set the name on the GUI it will write it to the TileEntity NBT Data. I've read that I will need to send and get packets to update the GUI and write to the TileEntity NBT Data, but I'm not sure if I need to do it using packets and how to do it.