Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

MikeyJY

Members
  • Posts

    13
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

MikeyJY's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Some mods create a folder in %appdata%/.minecraft. How to create a folder there and how to write a txt file there?
  2. Hi. Does anyone know how to compile a string and get the output as a string? I'm trying to make an programming mod for in-game java programming. An gui that acts as a "IDE": But I need to compile the code written by player. I have this string made by user in-game: String code = "class JavaMod{ public static void main(String args[]){ System.out.println(\"Text\"); } }"; I need to compile the string, get the output in a "String output", (in this case the value should be "Text"), and show in-game GUI; Of course for the player to play this mod will require JDK configured with bin path in control panel enviorment variables, because I need the actual Java Virtual Machine on player's PC for the code to be compiled, no?
  3. I'm trying to make a coding game, for players to start learning Java. I created a post yesterday about the multi-row textfield(I need it for the actual in-game Java IDE). Since then I started to work on a multi-row text filed. I added the basics: https://streamable.com/buse32 As you can see from the video it works, but there are some things missing(cursor, navigating trough code with arrow keys, CTRL+A, select, CTRL+C, CTRL+V, etc). I have no idea how to imlement theese things. Here is may code(GUI class): Console console = new Console(); @Override public void drawScreen(int x, int y, float ticks) { returns[0] = 0; int guiX = (width - guiWidth) / 2; int guiY = (height - guiHeight) / 2; //GL11.glColor4f(1, 1, 1, 1); mc.renderEngine.bindTexture(new ResourceLocation("jp", "textures/gui/java_final.png")); drawTexturedModalRect(guiX, guiY, 0, 0, guiWidth, guiHeight); for(int j = 1; j <= rows; j++) { String row = "nothing yet"; int i; for(i = 1, row = ""; i <= letterCount; i++) { if(returns[j] != 0) { if(i < returns[j] && i >= returns[j-1]) { row += Keys[i]; fontRendererObj.drawString(row, guiX + 10, guiY + 40 + (j - 1) * 10, 0x5e757d); } } if(returns[j] == 0) { if(i >= returns[j-1]) { row += Keys[i]; fontRendererObj.drawString(row, guiX + 10, guiY + 40 + (j - 1) * 10, 0x5e757d); } } } } super.drawScreen(x, y, ticks); } @Override protected void keyTyped(char c, int key) { //change the "fontRendererObj.drawString("String before any key", guiX + 10, guiY + 40, 0x5e757d);" text to the key tapped switch(key) { case Keyboard.KEY_BACK: if(letterCount >= 1) { Keys[letterCount] = null; letterCount--; if(returns[returnCount] == letterCount + 1) { returns[returnCount] = 0; returnCount--; rows--; } } console.log("Returns: "); for(int cnt = 1;cnt <= returnCount; cnt++) { console.log(returns[cnt] + " "); } console.newline(); console.log("Keys: "); for(int cnt = 1;cnt <= letterCount; cnt++) { console.log(Keys[cnt] + " "); } console.newline(); console.log("Retrun Count: " + returnCount); console.newline(); console.log("Rows: " + rows); console.newline(); console.log("Letter Count: " + letterCount); console.newline(); break; case Keyboard.KEY_ESCAPE: mc.displayGuiScreen(null); break; case Keyboard.KEY_RETURN: rows++; returnCount++; returns[returnCount]=letterCount + 1; console.log("Returns: "); for(int cnt = 1;cnt <= returnCount; cnt++) { console.log(returns[cnt] + " "); } console.newline(); console.log("Keys: "); for(int cnt = 1;cnt <= letterCount; cnt++) { console.log(Keys[cnt] + " "); } console.newline(); console.log("Retrun Count: " + returnCount); console.newline(); console.log("Rows: " + rows); console.newline(); console.log("Letter Count: " + letterCount); console.newline(); break; default: if(c >= 32 && c <= 127) { letterCount++; Keys[letterCount] = c + ""; console.log("Returns: "); for(int cnt = 1;cnt <= returnCount; cnt++) { console.log(returns[cnt] + " "); } console.newline(); console.log("Keys: "); for(int cnt = 1;cnt <= letterCount; cnt++) { console.log(Keys[cnt] + " "); } console.newline(); console.log("Retrun Count: " + returnCount); console.newline(); console.log("Rows: " + rows); console.newline(); console.log("Letter Count: " + letterCount); console.newline(); } break; } } The console class is just a class I made to avoid writing "System.out.println" every time I want to print in console something: package com.mikeyjy.methods; public class Console { public void log(Object obj) { System.out.print(obj); } public void newline() { System.out.println(); } }
  4. I want to get the ascii code(transform to string) the int representing the minecraft key code: protected void keyTyped(char c, int key) { //change the "fontRendererObj.drawString("String before any key", guiX + 10, guiY + 40, 0x5e757d);" text to the key tapped KeyTapped = (char) key + ""; System.out.println(key); } If I press b, in console I get 48 which is not the corresponding in ascii. I want to get the key I pressed in KeyTapped
  5. I have this code: @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); mc.renderEngine.bindTexture(new ResourceLocation("jp", "textures/gui/java_final.png")); drawTexturedModalRect(guiX, guiY, 0, 0, guiWidth, guiHeight); fontRendererObj.drawString("String before any key", guiX + 10, guiY + 40, 0x5e757d); super.drawScreen(x, y, ticks); } @Override protected void keyTyped(char c, int key) { //change the "fontRendererObj.drawString("String before any key", guiX + 10, guiY + 40, 0x5e757d);" text to the key tapped } I commented in the code what I need to do. I want to change the string text to the key.
  6. I need to create a text field with multiple lines, but I have no idea. Please help. I am new to forge modding.
  7. When I place @Override above the method it sais: The method doesGuiPauseMenu() of type GUI must override or implement a supertype method Remove @Override annotation I tried to remove it, but the game still is pausing in gui. I have this method in the main gui class that extends GuiScreen. How to stop the gui to pause the game. By pausing I mean stop the time, the animals, the furnace.
  8. I'm trying to make a laptop in minecraft. I created an obj in blender, I created an texture atlas(.png), I can't figure out the rendering in minecraft. It is my first mod: Mod name "JavaProgrammingMod"(It adds java in minecraft) JavaProgrammingMod.java: package com.mikeyjy.JavaProgramming; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @Mod(modid = "jp", name = "JavaProgramming", version = "0.27b") public class JavaProgrammingMod { public static Block blockPC; public static Item itemJavaSoft; @EventHandler public void preInit(FMLPreInitializationEvent event) { blockPC = new BlockPC(Material.anvil).setBlockName("BlockPC").setCreativeTab(tabJavaProgrammingMod); GameRegistry.registerBlock(blockPC, blockPC.getUnlocalizedName().substring(5)); itemJavaSoft = new ItemJavaSoft().setUnlocalizedName("ItemJavaSoft").setTextureName("jp:itemjavasoft").setCreativeTab(tabJavaProgrammingMod); GameRegistry.registerItem(itemJavaSoft, itemJavaSoft.getUnlocalizedName().substring(5)); GameRegistry.registerTileEntity(TileEntityBlockPC.class, "tileBlockPC"); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBlockPC.class, new RenderTileEntityBlockPC()); } @EventHandler public void preInit(FMLInitializationEvent event) { } @EventHandler public void preInit(FMLPostInitializationEvent event) { } public static CreativeTabs tabJavaProgrammingMod = new CreativeTabs("tabJavaProgrammingMod") { @Override public Item getTabIconItem() { return new ItemStack(blockPC).getItem(); } }; } BlockPC.java: package com.mikeyjy.JavaProgramming; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class BlockPC extends BlockContainer{ public BlockPC(Material material) { super(material); this.setBlockName("Computer"); } @Override public boolean renderAsNormalBlock(){ return false; } @Override public int getRenderType(){ return -1; } @Override public boolean isOpaqueCube(){ return false; } @Override public TileEntity createNewTileEntity(World world, int par2) { return new TileEntityBlockPC(); } } RenderTileEntityBlockPC: package com.mikeyjy.JavaProgramming; import org.lwjgl.opengl.GL11; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.AdvancedModelLoader; import net.minecraftforge.client.model.IModelCustom; public class RenderTileEntityBlockPC extends TileEntitySpecialRenderer { ResourceLocation texture; ResourceLocation objModelLocation; IModelCustom model; public RenderTileEntityBlockPC(){ texture = new ResourceLocation("jp", "models/BlockPCTexture.png"); objModelLocation = new ResourceLocation("jp", "models/BlockPC.obj"); model = AdvancedModelLoader.loadModel(objModelLocation); } @Override public void renderTileEntityAt(TileEntity te, double posX, double posY, double posZ, float timeSinceLastTick) { TileEntityBlockPC te2 = (TileEntityBlockPC) te; bindTexture(texture); GL11.glPushMatrix(); GL11.glTranslated(posX + 0.5, posY + 0.5, posZ + 0.5); GL11.glPushMatrix(); model.renderAll(); GL11.glPopMatrix(); GL11.glPopMatrix(); } } I have these errors: BlockPC.java line 34: TileEntityBlockPC cannot be resolved to a type RenderTileEntityBlockPC line 23: TileEntityBlockPC cannot be resolved to a type JavaProgrammingMod line 28: The method registerTileEntity(Class<? extends TileEntity>, String) in the type GameRegistry is not applicable for the arguments (Class<TileEntityBlockPC>, String) JavaProgrammingMod line 29: The method bindTileEntitySpecialRenderer(Class<? extends TileEntity>, TileEntitySpecialRenderer) in the type ClientRegistry is not applicable for the arguments (Class<TileEntityBlockPC>, RenderTileEntityBlockPC) I followed this tutorial: https://forums.minecraftforge.net/topic/29600-1710-rendering-obj-models-as-blocks/ Please help
×
×
  • Create New...

Important Information

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