Jump to content

sep87x

Members
  • Posts

    68
  • Joined

  • Last visited

Posts posted by sep87x

  1. Yesterday, a bird tweeted me that there is a new Forge update available, namely 10.13.0.1180, so I updated my workspace to the latest recommended version by the corresponding tutorial in Forge's Wiki. However, as I updated my 1.7.2 mods today and wanted to run the client it didn't even show the Minecraft window; literally no sign of life when I tried to launch it.  The only thing I saw in the system log was that the LaunchWrapper class tried to launch the main class, but it failed as it can be seen from the recent log.

     

    I seriously don't know where to start since this is the first time this error occured. Any recommendations on how to fix this issue?

  2. There is no need to create a class simply to implement an interface. If your class does nothing else, get rid of it.

     

    Not really. It's always better to create an extra class implementing an interface just to make your whole project look neatly arranged. However, if you're merging multiple functionalities of the same type to one big compound of methods, then you could also make some kind of handler which handles all events of the same type. Speaking of that, wouldn't it be a good idea to implement the IFuelHandler interface directly into the item to which it belongs to?

  3. Oh my god. In 1.6.X was .getID now it doesn't works. No do you understand or not?

    O wann't listen to some one who would like be as my mum but anyone whou is able to help me.

     

    Most of the parts of this tutorial still work. The only thing you'll need to do is change

    Item.customItem.itemID

    to

    Item.getIdFromItem(Items.apple)

     

    If your problem is to determine the item's ID, then please mention it in your root post. Otherwise we're all unable to help.

  4. I need to get the stack out of the player's inventory container which is currently being hovered with the mouse. Basically, I have this code set up which checks for a keybinding and invokes onKeyPressed() when the button is pressed. (The KeyBindingWrapper is a utility class I wrote for myself, it's not available in Forge)

     

     

    new KeyBindingWrapper("key.forcefieldmod.inventory.assign", Keyboard.KEY_Z, "key.forcefieldmod.category") {
    
    @Override
    public void onKeyPressed() {
    	GuiScreen currentGuiScreen = ForgeUtils.getMinecraft().currentScreen;
    
    	if (currentGuiScreen instanceof GuiInventory) {
    		GuiInventory inv = (GuiInventory) currentGuiScreen;
    		// get ze stack
    	}
    }
    
    };

     

     

    What's the best way to accomplish this? I've looked through the inventory's GUI and container class, but I haven't found fields or methods which could be of any use yet.

  5. I register my events using this code; MinecraftForge.EVENT_BUS.register(new ItemPickupHandler());

    Maybe try that? It seems like it goes wrong at the registring part.

     

    ForgeUtils.getForgeEventBus().register(new SkillCombatListener());

     

    is basically just an alias for

     

    MinecraftForge.EVENT_BUS.register(new SkillCombatListener());

     

    I wrote the ForgeUtils class for me so it's easier for me to get into the new 1.7.2 system. In the first place I wrote the class to distinguish the Forge event bus from the FML event bus because they're two things on their own ... soooo the typo can't be at this place.

     

    Edit: I might just take a nap and make a new attempt tomorrow. I'll let you guys know whether your advice was helping me out or not.

  6. Also, you should note that the if-statement contains unnecessery code.

     

    	@SubscribeEvent
    public void onLivingHurt(LivingHurtEvent event) {
    	System.out.println("FEHFOUHUOjhgriwgwrg");
    	if (!(event.entity instanceof EntityPlayer)) {
    		System.out.println(event.entity.getDistanceToEntity(ForgeUtils.getPlayer()) + " " + event.source.damageType);
    	}
    }

     

    I already expected that, but I was too lazy to change this. However, this wouldn't change anything in how the handler works. As I said in my first post, I've already tried some standard logging (like above) but it doesn't even send the output to the console. It should work and that's my main problem here.

  7. Hey, I'm back with another problem,

     

    At first, thanks to everyone who was helping me in my previous question about how to come along with the "new" event system. However, I discovered another hurdle on my way to a new release. I set up a LivingHurtEvent and want to find out the distance between the player and the dead hurt entity, but for some reason Forge won't let me know if there's been an entity murdered hurted. Here the most important code snippets:

     

    Main Mod Class:

     

    	@EventHandler
    public void onInit(FMLInitializationEvent event) {
    	ForgeUtils.getForgeEventBus().register(new SkillCombatListener()); // registered at MinecraftForge.EVENT_BUS
    }

     

    Death Handler:

     

    	@SubscribeEvent
    public void onLivingHurt(LivingHurtEvent event) {
    	if (event.entity instanceof EntityLiving && !(event.entity instanceof EntityPlayer)) {
    		System.out.println(event.entity.getDistanceToEntity(ForgeUtils.getPlayer()) + " " + event.source.damageType);
    	}
    }

     

    I've tried to find typos in the code with some basic console logging but Forge doesn't even seem to call the LivingHurtEvent. Though LivingHurtEvent extends LivingEvent it doesn't seem to do anything. Am I just missing something or is this a bug?

     

    Greets from Germany

    ~sep87x

  8. Hello everybody,

     

    recently I've been trying to get into the "new" Forge 1.7.2 and I'm kind of saddened because it seems like the tick handling system got a complete overhaul. In 1.6.x and earlier you were able to implement the ITickHandler interface to detect ticks on client- and server side. However, this doesn't seem to work anymore. My whole ideas are based on these tick handlers and I'd seriously like to know how to get this tick interface back. I've seen a TickEvent in some package, but it doesn't seem to do the job like I imagine. So where did this interface go and how do I need to set up a tick handler in the 1.7.x version?

     

    Greets from Germany

    ~sep87x

  9. Try adding a debug println right after you register the EventHandler class. It might not get printed if anything before it in the method throws any exception. Guava's EventBus (which is what FML uses for the @EventHandler) is a bit funky if an event handler method throws an exception: it get's silently ignored.

     

    Tried it, but it prints the debug message in the console, so it should work.

     

    	@EventHandler
    public void onInit(FMLInitializationEvent event) {		
    	session = new GamingSession();
    	MinecraftForge.EVENT_BUS.register(session);
    
    	System.out.println("DEBUG :3");
    }

     

    2013-09-15 12:53:12 [information] [sTDOUT] DEBUG :3

  10. Hello there,

     

    I'm very close to finishing a new mod, but MinecraftForge won't let me finish my job :c I want to register an event handler - no big deal, but MinecraftForge won't let me. I've set up anything that I need, but it won't call the events. There must be something I can't see.

    OverlayMod.java

     

    package net.sep87x.steamol;
    
    import java.io.File;
    import java.util.ArrayList;
    import java.util.HashMap;
    
    import net.minecraftforge.common.MinecraftForge;
    import net.sep87x.steamol.network.JobPlanetMinecraft;
    import net.sep87x.steamol.network.PMCTag;
    
    import cpw.mods.fml.common.Mod;
    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.network.NetworkMod;
    import cpw.mods.fml.common.registry.TickRegistry;
    import cpw.mods.fml.relauncher.Side;
    
    @Mod(modid = OverlayMod.MOD_MODID, name = OverlayMod.MOD_NAME, version = OverlayMod.MOD_VERSION)
    @NetworkMod(clientSideRequired = true, serverSideRequired = false)
    public class OverlayMod {
    
    /* a lot of uninteresting, secret fields. please ignore */
    
    public GamingSession session;
    
    @EventHandler
    public void onInit(FMLInitializationEvent event) {
    	// secret code ... unnecessary
    
    	session = new GamingSession();
    	MinecraftForge.EVENT_BUS.register(session);
    }
    
    }
    

     

    GamingSession.java

     

    package net.sep87x.steamol;
    
    import java.text.DateFormat;
    import java.util.ArrayList;
    import java.util.Date;
    
    import net.minecraft.client.entity.EntityClientPlayerMP;
    import net.minecraft.client.entity.EntityPlayerSP;
    import net.minecraftforge.event.ForgeSubscribe;
    import net.minecraftforge.event.entity.item.ItemTossEvent;
    import net.minecraftforge.event.entity.living.LivingAttackEvent;
    
    public class GamingSession {
    
    private Date startDate;
    
    private float statTossedItems, statPlayerDamageTaken = 0;
    
    public GamingSession() {
    	this.startDate = new Date();
    }
    
    /**
     * @return A integer array with the time listed as follows. { SECONDS, MINUTES, HOURS }
     */
    public ArrayList<Integer> getDuration() {
    	ArrayList<Integer> timeDecoded = new ArrayList<Integer>();
    
    	Date now = new Date();
    	long timeInMilliseconds = now.getTime() - startDate.getTime();
    	long timeInSeconds = timeInMilliseconds / 1000;
    	long timeInMinutes = timeInSeconds / 60;
    	long timeInHours = timeInMinutes / 60;
    
    	timeInSeconds = timeInSeconds % 60;
    	timeInMinutes = timeInMinutes % 60;
    	timeInHours = timeInHours % 60;
    
    	timeDecoded.add(new Double(Math.floor(timeInSeconds)).intValue());
    	timeDecoded.add(new Double(Math.floor(timeInMinutes)).intValue());
    	timeDecoded.add(new Double(Math.floor(timeInHours)).intValue());
    
    	return timeDecoded;
    }
    
    @ForgeSubscribe
    public void onItemToss(ItemTossEvent event) {
    	++statTossedItems;
    	System.out.println(statTossedItems);
    }
    
    @ForgeSubscribe
    public void onLivingAttack(LivingAttackEvent event) {
    	if (event.entity instanceof EntityClientPlayerMP) {
    		statPlayerDamageTaken += event.ammount;
    	}
    }
    
    }
    

     

    There's no output on the console, which means that the methods won't be called. Any help?

     

    Greets from Germany

    ~sep87x

  11. The way to go here is a coremod that modifies the bytecode of the GuiMainMenu class (or GuiScreen to be more generic).

     

    Not necessarily. When I was a coding noob, I tried the same and found another method without editing base classes. At first create a new GuiScreen (I'll call it FakeGuiMainMenu) which is similar to the GuiMainMenu (so simply copy & paste). After that, add a client side tick handler to your mod. In the tickEnd() method, check if the current screen being is an instance of the GuiMainMenu. If so, then make Minecraft display your "fake" gui screen.

     

    package my.dummy.package;
    
    import net.minecraft.client.Minecraft;
    import net.minecraft.client.gui.GuiMainMenu;
    import net.minecraft.client.gui.GuiScreen;
    
    import cpw.mods.fml.common.ITickHandler;
    import cpw.mods.fml.common.TickType;
    
    public class OpenGuiListener implements ITickHandler {
    
    @Override
    public void tickStart(EnumSet<TickType> type, Object... tickData) {
    
    }
    
    @Override
    public void tickEnd(EnumSet<TickType> type, Object... tickData) {
    	if (Minecraft.getMinecraft().currentScreen instanceof GuiMainMenu) {
    		Minecraft.getMinecraft().displayGuiScreen(new FakeGuiMainMenu());
    	}
    }
    
    @Override
    public EnumSet<TickType> ticks() {
    	return EnumSet.of(TickType.CLIENT);
    }
    
    @Override
    public String getLabel() {
    	return "dummyMainMenuListener";
    }
    
    }

     

    If it works, you may now edit the FakeGuiScreen as you like. I made it earlier and it works sweet.

     

    Greets from Germany

    ~sep87x

  12. The way to go here is a coremod that modifies the bytecode of the GuiMainMenu class (or GuiScreen to be more generic).

     

    Not necessarily. When I was a coding noob, I tried the same and found another method without editing base classes. At first create a new GuiScreen (I'll call it FakeGuiMainMenu) which is similar to the GuiMainMenu (so simply copy & paste). After that, add a client side tick handler to your mod. In the tickEnd() method, check if the current screen being is an instance of the GuiMainMenu. If so, then make Minecraft display your "fake" gui screen.

     

    package my.dummy.package;
    
    import net.minecraft.client.Minecraft;
    import net.minecraft.client.gui.GuiMainMenu;
    import net.minecraft.client.gui.GuiScreen;
    
    import cpw.mods.fml.common.ITickHandler;
    import cpw.mods.fml.common.TickType;
    
    public class OpenGuiListener implements ITickHandler {
    
    @Override
    public void tickStart(EnumSet<TickType> type, Object... tickData) {
    
    }
    
    @Override
    public void tickEnd(EnumSet<TickType> type, Object... tickData) {
    	if (Minecraft.getMinecraft().currentScreen instanceof GuiMainMenu) {
    		Minecraft.getMinecraft().displayGuiScreen(new FakeGuiMainMenu());
    	}
    }
    
    @Override
    public EnumSet<TickType> ticks() {
    	return EnumSet.of(TickType.CLIENT);
    }
    
    @Override
    public String getLabel() {
    	return "dummyMainMenuListener";
    }
    
    }

     

    I made it earlier and it works sweet.

     

    Greets from Germany

    ~sep87x

  13. Hey there, sep87x ... back again ...

     

    so this isn't really an issue, it's more a question which I am unable to answer. I have the following "problem": after figuring out how this "read-image-files-from-an-external-location-and-bind-it"-thing works, I got to another problem. Usually I work in debug mode so I can edit the code live. At the moment there are only two textures (from that "read-image-files-from-an-external-location-and-bind-it"-thing ... I guess I'll just call it "riffaelabi-thing" in future) being drawn, both of the same size. One of these images changes every five seconds. To prevent the graphics driver from overworking, I register the texture id with the file object in a HashMap object, so LWJGL doesn't need to analyze the image and turn it into its bytes over and over again, and it works sweet, BUT anytime I try to edit the code, Minecraft and the Eclipse IDE slow down for 30 seconds, followed by a sudden termination of the Minecraft window.

     

    My questions are: could it be that this is caused by the debug mode (it works fine on "normal running")? There's no output on the termination. Why?

     

    Thanks in advance

    ~sep87x

  14. Ah okay. I forgot the following:

     

    // Setup wrap mode
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
    
    // Setup texture scaling filtering
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
    

     

    And I figured out that I'm able to save the images with PNG (+alpha) without any conversions, so anything went better than expected. Thanks a lot man

  15. So I kinda did something ... but it's not correct. I read through the whole thread and made the method fit my conditions. (That's the only example I found)

     

        private void bindBufferedImage(BufferedImage image) {
        	image = image.getSubimage((image.getWidth() - 128) / 2, (image.getHeight() - 128) / 2, 128, 128);
        	
        	int[] pixels = new int[image.getWidth() * image.getHeight()];
        	image.getRGB(0, 0, image.getWidth(), image.getHeight(), pixels, 0, image.getWidth());
        	
        	ByteBuffer buffer = BufferUtils.createByteBuffer(image.getWidth() * image.getHeight() * 4);
        	
        	for (int y = 0; y < image.getHeight(); y++) {
        		for (int x = 0; x < image.getWidth(); x++) {
        			int pixel = pixels[y * image.getWidth() + x];
        			buffer.put((byte)((pixel >> 16) & 0xFF));
        			buffer.put((byte)((pixel >>  & 0xFF));
        			buffer.put((byte)(pixel & 0xFF));
        			buffer.put((byte)((pixel >> 24) & 0xFF));
        		}
        	}
        	
        	buffer.flip();
        	
        	int textureID = GL11.glGenTextures();
        	GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
            
            //GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, image.getWidth(), image.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer);
        }

     

    Now I want to draw the image, but only a white box shows up.

     

    			        // fyi, the variable tag stores some information about a compound in a xml file. tag.tagType is an enum. the file name is correct. i verified that
    		        try {
    					bindBufferedImage(ImageIO.read(new File("pmcol-cache/tag_" + tag.tagType.getStringForTag().toLowerCase() + "_" + (showcaseIndex % 3) + ".jpg")));
    					this.drawTexturedModalRect(0, 0, 0, 0, 256, 256);
    				} catch (IOException e) {
    					e.printStackTrace();
    				}

     

    IMO, there are only two possible causes. One: the integer array "pixels" is not fed with right information. Two: the format of the file is not correct. Can anyone help me? I've coded for several weeks now and don't want to get stuck on that tiny problem.

     

    Edit: And yes I know ... a jpg doesn't have an alpha level ... me dumb. Ignore that.

  16. Hey there, sep87x with another problem,

     

    so for my (quiet huge) project I need to download image and place them in a cropped size (128x128) into a cache folder (located at .minecraft/sol-cache). After that, I need to render them to a GUI screen. As far as I know I can't use the ResourceLocation class because it only gets contents from the assets folder, but is it possible in some other way to retrieve the image from the cache with a ResourceLocation or do I need to do some "hardcore texture binding"?

     

    ... and no, I won't use slick-util.

     

    Greets from Germany

    ~sep87x

     

    Edit: okay, I will use the slick-util library if none of this works ... which would make me really sad.

  17. Hey there again,

     

    I'm having troubles using the drawRect() function. So I have a GuiScreen set up and want to render a semi-transparent black box to it, but it doesn't work properly.

     

    drawRect(50, 50, 100, 100, 0x00000088);

     

    And yes, it is in the drawScreen() method. Since I installed the build #804, this code snippet doesn't work anymore. Any help?

     

    ~sep87x

×
×
  • Create New...

Important Information

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