Jump to content

Tschipp

Forge Modder
  • Posts

    307
  • Joined

  • Last visited

Posts posted by Tschipp

  1. Not sure... it always seems to return false for some reason, even if a path is available:

    boolean result = (boolean) isDirectPathBetweenPoints.invoke(nav, new Vec3d(start.getX(), start.getY(), start.getZ()), new Vec3d(end.getX(), end.getY(), end.getZ()), (int)entity.width, (int)entity.height, (int)entity.width);

     

  2. 57 minutes ago, V0idWa1k3r said:

    Look at PathNavigateGround#isDirectPathBetweenPoints, I think that one is a direct check of whether the entity can actually navigate to the point.

    That said if you keep giving the entity an invalid path every time it asks for one then it will keep getting stuck. You need to check whtether the block is reachable before accepting it as a valid pathing target.

    isDirectPathBetweenPoints is protected, but I'll try reflecting it and see if it doesn't impact performance too much.

    My plan is of course to only make the entity walk to the position, if it is actually reachable.

  3. I'm writing some entity AI, which searches for blocks in a certain range and moves to them if it finds them.

    It works good, but the problem that I'm facing now is that the entity also moves to the block, even if it's in a position that it can never reach (completely encased behind walls).

     

    To try exclude these positions from valid ones, I added a check that calls

    entity.getNavigator().getPathToPos(pos)

    and checks if the path is null (because I thought it would be null if there was no available path).

    Sadly, that doesn't work. The entity now just walks against the wall and stays there until I remove it.

     

    Is there a way of checking if valid path to a position can be made before walking to it?

     

  4. I've made an item that acts as a water bucket but is damageable. I added it to the ore dictionary entry "listAllwater", added by Pam's harvestcraft.

    However, when I craft something, it only works when the item is undamaged. I registred the item to oredict like this:

    OreDictionary.registerOre("listAllwater", new ItemStack(ItemList.waterTalisman, 1, OreDictionary.WILDCARD_VALUE));
    OreDictionary.registerOre("listAllwater", ItemList.waterTalisman);

    Both methods don't seem to work when the item is damaged. What am I doing wrong?

     

    (btw, I'm crafting this recipe from Pam's Harvestcraft):

    {
      "result": {
        "item": "harvestcraft:saltitem"
      },
    
      "ingredients": [
        {
          "type": "forge:ore_dict",
          "ore": "toolPot"
        },
        {
          "type": "forge:ore_dict",
          "ore": "listAllwater"
        }
      ],
      "type": "forge:ore_shapeless"
    }

     

  5. 1 hour ago, Spaceboy Ross said:

    Well, then you cant do what you're trying to do.

    I think I actually just found a solution. I "borrowed" this code from CraftingManager.class and edited it a bit:

    		FileSystem filesystem = null;
    
    		URL url = MainModClass.class.getResource("/assets/modid/lang/");
    
    		try
    		{
    			if (url != null)
    			{
    				URI uri = url.toURI();
    				Path path = null;
    
    				if ("file".equals(uri.getScheme()))
    				{
    					path = Paths.get(MainModClass.class.getResource("/assets/modid/lang").toURI());
    				}
    				else
    				{
    
    					filesystem = FileSystems.newFileSystem(uri, Collections.emptyMap());
    					path = filesystem.getPath("/assets/modid/lang");
    
    				}
    				
    				Iterator<Path> it = Files.walk(path).iterator();
    				
    				while(it.hasNext())
    					System.out.println(it.next());
    			}
    		}
    		catch (Exception e)
    		{
    			e.printStackTrace();
    		}

    This now prints out all files in the lang folder. Works in the dev environment and when the mod is built into a jar, just tested.

  6. 4 minutes ago, Spaceboy Ross said:

    It should look something like this.

    
    Minecraft.getMinecraft().getResourceManager().getAllResources(new ResourceLocation(MODID,"dir.subdir"));

    You cannot access it like a path, you have to access it like a package.

    You sure? 

    Doing both

    Minecraft.getMinecraft().getResourceManager().getAllResources(new ResourceLocation(MODID, "assets.modid.lang"));
    

    or

    Minecraft.getMinecraft().getResourceManager().getAllResources(new ResourceLocation(MODID, "lang"));
    

    results in the same exception as before

  7. 5 minutes ago, Spaceboy Ross said:

    getAllResources may be what you're looking for.

    Doesn't seem to do it, unless I'm doing it wrong.

    As a test, I tried to list all files in the lang folder of my mod, I tried both this:

    Minecraft.getMinecraft().getResourceManager().getAllResources(new ResourceLocation(MODID, "assets/modid/lang/"));

    and this:

    Minecraft.getMinecraft().getResourceManager().getAllResources(new ResourceLocation(MODID, "lang/"));

     

    Both threw a FileNotFoundException

     

  8. I'm trying to get (and read the content) of all files contained in a custom asset folder.

    The folders location is something like:

    "assets/modid/customfolder/"

     

    The files of the folder can change have names that cannot be hardcoded. I'd like to somehow get all these files and read their content.

    I know that I can get the input stream from any resource using

    Minecraft.getMinecraft().getResourceManager().getResource(resourceLocation).getInputStream();

    but this doesn't work for folders. Is it possible to get all the contents of the folder?

  9. I'm trying to completely remove the inventory crafting matrix, meaning the 2x2 slots, the arrow, the "Crafting" text and the output slot.

    I did a small test to see if it was possible to get the slots of the inventory. I also tried to remove the output slot, but realized very quickly that 

    that was a bad idea, because the slot indices get all messed up.

    (Here's the code for that)

    @SubscribeEvent
    	public void onGuiInit(GuiScreenEvent.InitGuiEvent.Post event)
    	{
    		if(event.getGui() instanceof GuiInventory)
    		{
    			GuiInventory inv = (GuiInventory) event.getGui();
    			ContainerPlayer container = (ContainerPlayer) inv.inventorySlots;
    			for(int i = 0; i < container.inventorySlots.size(); i++)
    			{
    				Slot s = container.inventorySlots.get(i);
    				if(s instanceof SlotCrafting)
    					container.inventorySlots.remove(i);
    			}
    		}
    	}

     

    I think I need to approach this differently. Do I need to make a custom inventory gui and container and then override the vanilla gui?

    I'm afraid that that would cause severe incompatibilities with other mods though.

    If anyone has any ideas, I'd be glad to hear them!

  10. I'm adding several different milk fluids, and I'd like to add the milk buckets to the OreDictionary.

    However, I've found that it doesn't care about NBT of the UniversalBucket, only about meta (and item name ofc).

    That means that all UniversalBuckets get registered to the OreDictionary.

    Is there a way to only register my liquids, or is it not possible (without having to create a new bucket item)?

  11. 37 minutes ago, Draco18s said:

    What part of

    Have you failed to understand after FIVE PAGES (and at least four people trying to help) of thread?

    You have done fuckall to your folder names since I went to bed. Jesus mother foxing christ on a crutch.

    Yeah I guess you can’t expect much more from a person that adds „raw_poop“ and „cooked_poop“ items

  12. 1 minute ago, Cadiboo said:

    Currently in 1.12.2 Vanilla uses "/models/item" for models and "/textures/items" for textures

    However in 1.13 Vanilla with be using "/models/item" and "/textures/item"

    The texture folder can be called whatever you want. you just have to reference it correctly from code & JSON

    wow TIL

  13. Just now, Cadiboo said:

    This is good practice, but since he's using EventSubscribers, Forge knows what mod is registering the item & will add his ModId to the domain of the resourceLocation

    Oh, really? I didn't know, seemed to me like he was just registering the item with the wrong name

  14. public class ItemBase extends Item implements IHasModel {
    
    	public ItemBase(String name) {
    		setUnlocalizedName(name);
    		setRegistryName(name);
    		setCreativeTab(CreativeTabs.MATERIALS);
    
    		ItemsInit.ITEMS.add(this);
    	}
    
    	@Override
    	public void registerModels() {
    	     Main.proxy.registerItemRender(this, 0, "inventory");
    		}	
    
    }

     

    You need to set the correct registryName.

    Do

    setRegistryName(ref.MODID, name);

    instead of

    setRegistryName(name);

     

  15. 7 hours ago, Cadiboo said:

    Thanks! 

    Can your hologram properly render stained glass? I tried it with the blend function you used, but it didn't seem to work for me.

  16. 7 hours ago, Animefan8888 said:

    Try using this instead.

    
    GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);

     

    I tried it, but sadly the solid blocks like wood are still not transparent... The solution you suggested above might be the best one.

    Quote

    Also switch to using GLStateManager instead of direct OpenGL calls.

    do you mean this statement?

    GL14.glBlendColor(1f, 1f, 1f, 0.8f);

    I replaced it with this

    GlStateManager.color(1f, 1f, 1f, 0.8f);

    but that didn't change anything.

×
×
  • Create New...

Important Information

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