Jump to content

Two

Members
  • Posts

    63
  • Joined

  • Last visited

Posts posted by Two

  1. I was setting the debug defines on the commandline used to start Minecraft in the Minecraft launcher as ChampionAsh535 suggested, this had zero effect. However enabling debugging in Curseforge did it.

    I have no idea what Curse is doing to suppress the commandlines, but if running with the Curseforge Launcher using that specific setting seems to be the only way to activate debug logs. Which is a bit odd, because it should listen to the commandline settings, especially if enforcing something like a log4j config file, but it is not.

    Thanks for the help!

  2. Hi,

    I am trying to help a modder to pin down an issue that's happening on my system and I am trying to figure out how to set the log level of forge file logging to debug. My attempts at googling and using the usual log4j settings have failed.

    I do not have access to the source code of the mod, so I need to set the log level on the command line.

  3. The error occurred again yesterday, and I can now say for sure that it is a re-obfuscation failure.

     

    I had just finished an update, did clean & build, tested the result in the IDE (non-obfuscated) and everything was working fine. So I copied the lib from that build to a real MC environment and it failed with the rock issue. I hit clean & build again, copied the lib again and then everything was working fine.

  4. Whenever I have a block in my mod that uses Blocks.stone or Materials.rock reobfuscation completely randomly fails sometimes.

     

    That is: the code works, then (without any change) I do a re-compile, and the game crashes with

     

    cpw.mods.fml.common.LoaderException: java.lang.NoSuchFieldError: rock

    at cpw.mods.fml.common.LoadController.transition(LoadController.java:163)

    at cpw.mods.fml.common.Loader.initializeMods(Loader.java:739)

    at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:311)

    at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:552)

    at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:878)

    at net.minecraft.client.main.Main.main(SourceFile:148)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

    at java.lang.reflect.Method.invoke(Unknown Source)

    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)

    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

    Caused by: java.lang.NoSuchFieldError: rock

    at two.graves.blocks.BlockGrave.<init>(BlockGrave.java:40)

    at two.graves.ProxyBase.registerBlocks(ProxyBase.java:51)

    at two.graves.ProxyBase.onInit(ProxyBase.java:77)

    at two.graves.ProxyClient.onInit(ProxyClient.java:16)

    at two.graves.Graves.load(Graves.java:64)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

    at java.lang.reflect.Method.invoke(Unknown Source)

    at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532)

    at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

    at java.lang.reflect.Method.invoke(Unknown Source)

    at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)

    at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)

    at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)

    at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)

    at com.google.common.eventbus.EventBus.post(EventBus.java:275)

    at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)

    at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

    at java.lang.reflect.Method.invoke(Unknown Source)

    at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)

    at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)

    at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)

    at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)

    at com.google.common.eventbus.EventBus.post(EventBus.java:275)

    at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)

    at cpw.mods.fml.common.Loader.initializeMods(Loader.java:737)

     

     

    Then I recompile the exact same code-base (without any changes) and the crash is gone. I have not seen this happen with anything but Materials.rock / Blocks.stone.

     

    This is really annoying when you do a quick recompile to change something like version number after extensive testing, upload the mod just to realize that it is crashing because of this.

  5. I managed to find your topic: http://www.minecraftforge.net/forum/index.php/topic,20135.0.html

     

    After some more fiddling with the way Minecraft handles worlds, I realized that the TileEntity (probably) needs to be requested as follows:

     

    - On the server: DimensionManager.getWorld(message.dimensionID)

    - On the client: Minecraft.getMinecraft().theWorld  (not sure about this one)

     

    The client often re-creates the world around the player, i.E. if he dies, which will cause the tile entity to be re-created as well, which however - to complicate things further - is NOT the tile that is actually used in the world.

     

    Also it is unclear to me what happens if the player is in a different dimension (there is only one theWorld) and the server sends an update for that tile entity, which makes me speculate that there is a better way to do this.

     

    I'd love to get some more feedback on this if you have the time.

  6. From the corresponding block to the tile entity code above:

     

    @Override
      public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float hitX, final float hitY, final float hitZ) {
        if (world.isRemote == false) {
          final TileEntity tileEntity = world.getTileEntity(x, y, z);
          if (tileEntityClass.isInstance(tileEntity)) {
            tileEntityClass.cast(tileEntity).giveItemsToPlayer(player);
          } else {
            FMLLog.severe("Grave TileEntity expected %s, but found %s", tileEntityClass.getName(), tileEntity == null ? "null" : tileEntity.getClass().getName());
          }
        }
        return true;
      }

  7. The code that adds the items. Log output tells me that all items are properly added on the server:

     

    public void giveItemsToPlayer(final EntityPlayer player) {
        int count = GravesAssets.itemsPerSecond >= 0 ? GravesAssets.itemsPerSecond / TICKS_PER_SECOND : Integer.MAX_VALUE;
        FMLLog.info("Giving %d of %d items back to %s...", count, this.inventoryContent.size(), player.getDisplayName());
        if (count == 0) {
          return;
        }
        InventoryContent content;
        final Deque<InventoryContent> notAdded = new LinkedList<InventoryContent>();
    
        while ((count-- > 0) && ((content = this.inventoryContent.poll()) != null)) {
          FMLLog.info("Returning %s...", content.toString());
          try {
            switch (content.inventoryID) {
              case INVENTORY_ID_VANILLA:
                if (player.inventory.getStackInSlot(content.slot) == null) {
                  player.inventory.setInventorySlotContents(content.slot, content.itemStack);
                } else {
                  notAdded.add(content);
                  FMLLog.info("Failed.");
                }
                break;
            }
          } catch (Exception e) {
            FMLLog.warning("Failed to add item to inventory: %s\n%s", e.toString(), content.toString());
          }
        }
    
        for (InventoryContent item : notAdded) {
          FMLLog.info("Adding %s...", item.toString());
          if (player.inventory.addItemStackToInventory(item.itemStack) == false) {
            this.inventoryContent.add(item);
            FMLLog.info("Failed");
          }
        }
    
        if (this.inventoryContent.isEmpty()) {
          FMLLog.info("All items have been returned");
          this.worldObj.setBlockToAir(this.xCoord, this.yCoord, this.zCoord);
        } else {
          FMLLog.info("Items remain in grave");
          this.markDirty();
        }
      }

     

    Neither setInventorySlotContents nor addItemStackToInventory synchronize to the client.

  8. I am currently trying to write a mod that sets items to specific player inventory slots (like armor) without using any containers or similar. I got that working so far using player.inventory.setInventorySlotContents(...), however the items are only visible after relogging, which tells me that I am missing something to synchronize that change to the player.

     

    How do I properly synchronize a batch change to the player's inventory?

  9. Took a little more try and error, but finally I got it.

     

    For future reference, this is how you load any texture from a given block IIcon (use block.getIcon to get that icon):

     

      
    /* Returns the pixel data of the texture described by icon in ARGB format */
    static int[] loadTexture(final IIcon icon) {
        try {
          final ResourceLocation resourceLocation = getResourceLocation(icon.getIconName());
          final IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager();
          final IResource resource = resourceManager.getResource(resourceLocation);
          final InputStream in = resource.getInputStream();
          final BufferedImage image = ImageIO.read(in);
          return image.getRGB(0, 0, image.getWidth(), image.getHeight(), null, 0, image.getWidth());
        } catch (Exception e) {
          FMLLog.log(Level.ERROR, e, "Unable to load texture '%s'", icon.getIconName());
        }
        return null;
      }
    
      static ResourceLocation getResourceLocation(final String blockTexture) {
        String domain = "minecraft";
        String path = blockTexture;
        final int domainSeparator = blockTexture.indexOf(':');
    
        if (domainSeparator >= 0) {
          path = blockTexture.substring(domainSeparator + 1);
    
          if (domainSeparator > 1) {
            domain = blockTexture.substring(0, domainSeparator);
          }
        }
    
        final String resourcePath = "textures/blocks/" + path + ".png";  // base path and PNG are hardcoded in Minecraft
        return new ResourceLocation(domain.toLowerCase(), resourcePath);
      }

×
×
  • Create New...

Important Information

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