Jump to content

AnZaNaMa

Forge Modder
  • Posts

    161
  • Joined

  • Last visited

Posts posted by AnZaNaMa

  1. Oh, okay. So @Elix_x I don't really understand how you're passing the TileEntity to the getQuads(). I know you're using some sort of workaround with the UnlistedPropertyGeneric, but I don't see what's going on. Is there any chance you could give an example of passing the TileEntity to getQuads() without the Optionals and lambda functions? I'm not well versed in Java 8, so it's extremely confusing to me.

  2. Honestly, I was pretty overwhelmed reading through that the first time. However, on closer inspection this doesn't seem all that complicated. I'm just wondering - if getBakedQuads is called every frame, how is it more efficient than a TESR or FastTESR? I mean, obviously it may be because with a TESR, I'd be pushing and popping matrices, and drawing point-by-point and whatnot, but doesn't that eventually have to be done anyway, whether I give Minecraft a BakedModel, or I just render it myself?

  3. Alright, so I have a block with a TileEntity that is basically a frame that will hold different "parts". I'm trying to determine whether I should use a JSON model (or OBJ) or a TESR. In the end, there will be quite a few unique parts that all will need to render differently and one of my blocks will need to be able to hold multiple different parts. I feel like if I tried to do this using JSON models, it would be way too complex. Also, I have experience using OpenGL apart from Minecraft so I'd probably be able use a TESR pretty well. I don't know if they will cause too much lag, though. Are they a lot more expensive than JSON models? I need the player to be able to use quite a few of these before they lag too badly.

     

    Sorry if this question seems unclear. I find it difficult to put what I'm thinking into words. Is there some other option I'm missing or a better way to dynamically render a TileEntity?

  4. At first, I was going to say that it could just be that you're never calling setCustomNameTag() after the Name is changed, but seeing that you're printing the value of Name to the console and it's not changing, I guess that doesn't really solve the issue here, though you still may want to consider doing so.

     

    I believe the real issue here is the way you're handling the GUI. The solution to the problem is not to sync the data from the client to the server. When working with GUIs, you want to use both sides, so your method that opens the GUI should not be @SideOnly(Side.CLIENT) and you should not use  Minecraft.getMinecraft().displayGuiScreen(), but instead FMLNetworkHandler.openGui().  I haven't worked with GUIs in a while, but here's a tutorial on using them properly:

     

    https://bedrockminer.jimdo.com/modding-tutorials/advanced-modding/gui-screen/

  5. Okay, I've moved the model registering function, gotten rid of the saved reference to name, and slapped an @SideOnly(Side.CLIENT) on the model registry. I don't know why you're saying to call setUnlocalizedName(getRegistryName()). getRegistryName() returns a ResourceLocation and setUnlocalizedName() requires a String.

     

    Also, my item still isn't showing up in the creative menu. I was trying to use my own tab at first, but thought that might be the issue, so I changed it to Tab.MATERIALS and it's still not working correctly. With the @Mod.EventBusSubscriber, I don't need to call MinecraftForge.EVENT_BUS.register() anywhere do I?

  6. So, I haven't attempted to create any mods in 1.12 yet. I'm following shadowfacts' tutorial on items and I see now that registering things requires an EventHandler. I have implemented a class for items that just does basic stuff, and I have created EventHandlers.

    @SubscribeEvent
    public static void registerItems(RegistryEvent.Register<Item> event) {
        event.getRegistry().registerAll(
                wrench
        );
    }
    
    @SubscribeEvent
    public static void registerItemModels(ModelRegistryEvent event) {
        wrench.registerItemModel();
    }
    
    @SideOnly(Side.CLIENT)
    public static void registerItemRenderer(Item item, int meta, String id) {
        ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(Modularity.MODID +
                ":" + id, "inventory"));
    }

     

    I've followed this tutorial down to the letter (well I guess not literally) and for some reason, my item is not showing up when I load the game. Yes, I have included the @Mod.EventBusSubscriber annotation on my class.

     

    Here's a link to my Item Class.

     

  7. oops sorry, try this.

    public void eventHandler(PlayerEvent.PlayerLoggedInEvent event) {
      if(!event.player.getEntityWorld().isRemote()) {
      	event.player.capabilities.allowFlying = true;
      	event.player.capabilities.disableDamage = true;
      	event.player.sendPlayerAbilities();
      }

    The if statement just makes sure the code only runs on the server, then the sendPlayerAbilities() forces the server to send updated abilities to the client.

  8. During initialization, there won't even be a World, let alone a player. On top of that, you should not use Minecraft.getMinecraft().player for anything other than rendering, as it exists only on the Client side, and won't work properly.

     

    If you don't know much about Forge events, I suggest you check them out. They are probably the most important part of the Forge API and modding the game. You can find a quick tutorial I made here. Also, you can always check the forge docs, which are a great source for information.

  9. One way you could accomplish this for all players is to use an Event Handler that catches player creation:

    public class EventHandlerClass {
    
    	//Called when the player is originally created
    	@SubscribeEvent
    	public void onPlayerCreate(EntityJoinWorldEvent event) {
    		if(event.getEntity() instanceof EntityPlayer) {
    			EntityPlayer player = (EntityPlayer)event.getEntity();
    			player.capabilities.allowFlying = true;
    			player.capabilities.disableDamage = true;
    		}
    	}
    
    	//Called when the player respawns or changes dimensions. Will ensure that the player maintains its stats.
    	@SubscribeEvent
    	public void onPlayerClone(PlayerEvent.Clone event) {
    		event.getEntityPlayer().capabilities.allowFlying = true;
    		event.getEntityPlayer().capabilities.disableDamage = true;
    	}
    }

    and in whatever method handles FMLInitializationEvent, you need to register the class that has an event handler:

    public void init(FMLInitializationEvent e) {
    	MinecraftForge.EVENT_BUS.register(new EventHandlerClass());
    }

     

    I've edited this post a couple times, because I haven't been modding for a while, so I forgot some things. Sorry for any confusion

×
×
  • Create New...

Important Information

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