Cerandior
Members-
Posts
385 -
Joined
-
Last visited
Everything posted by Cerandior
-
1.15.1 how do i set the scale of entity?
Cerandior replied to Drachenbauer's topic in Modder Support
What kind of entity do you have? In living entities you can override getSize to scale it: @Override public EntitySize getSize(Pose poseIn) { return super.getSize(poseIn).scale(0.5F, 0.5F); } Not sure if there is such a thing for other entities. -
this.addLayer(new HeldItemLayer(this)); Add this into your renderer constructor. On an unrelated note, you seem to be registering your entity World spawns at the entity registry event. I am not entirely sure if that's the correct place to register those. At least you do it after you register your entities, so I guess there is no problem. Anyway just saying, someone more knowledgeable than me can perhaps give you more information on that.
-
Forge docs are usually my go-to when I am dealing with something I haven't done before, however I couldn't find anything related to custom GUIs. What do I need to do to make a custom GUI in 1.14?
-
(Solved)[1.15.2]How do I generate trees on all blocks?
Cerandior replied to kyazuki's topic in Modder Support
Make two instances of your block, one that overrides canSustainPlant and one that does not. Use the one that overrides it for the floor and the other one for your leaves. -
Alright, fixed it. You can find the updated classes below: The Block Class: https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/blocks/CollectiveStorage.java The Tile Class: https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/tileentities/TPTile.java The StorageBlock Class: https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/blocks/StorageBlock.java Ignore the printlns, I was checking a couple of things, didn't have time to cleanup right now. Also the update() method at the StorageBlock is kind of stupid I know. I was having a problem with duplicates, and that's my fault for using an ArrayList. I should have used a HashSet since the beginning, since I don't really care about the order of the list elements. (You can use LinkedHashSet if you do care about that).
-
That was the idea. Every time I right-clicked the master block (which is the CSTile), it would go through each of the connected parts and re-update the StorageBlock (An object that I am using to keep track of chests and storage block parts, such as CSTile and TPTile that are connected to this multi-block). I still don't think I am actually updating the original list. I am updating the list of an object that is stored in the original list. Does that still throw the Exception? I am following another route now, if that works I'll post here the updated code in case someone else has a similar issue in the future.
-
Sorry about that, I fixed it now. However I am getting a concurrent modification exception right now (unrelated to the original problem, I thought it was at first). I don't think I am removing or adding anything to the list while iterating through it, I am modifying some of its elements however. Can I not do this? Block Class: https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/blocks/CollectiveStorage.java Tile Class: https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/tileentities/TPTile.java
-
Their registry name is null. Considering the registry event is being called (I checked at the debugger), I am guessing I am doing the linking between the TileEntityType and the TileEntity wrong. I followed the docs tutorial on how to create tile entities but surely I must have messed up something. The related classes: Main Class: https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/main/VanillaExtended.java BlockList Class: https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/blocks/BlockList.java TileEntity Class (I am providing only one of them, same error with both): https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/tileentities/CSTile.java
-
[1.14.4] Custom block has the name "Air" in-game.
Cerandior replied to Cerandior's topic in Modder Support
Another thing which is unrelated to this topic, however I don't want to make another post about it since it's mostly a programming-practice related question more than problems with the mod. I have read a couple of things about static initializers, and apparently they are not good for Forge. Anyone would care to explain why? Is the correct approach to declare objects as static but initialize them inside the registry events? I am asking because my Entities are currently being initialized inside a static block. Or perhaps to be more specific I should say that I am declaring and initializing a static object at the same time. Is this bad? -
[1.14.4] Custom block has the name "Air" in-game.
Cerandior replied to Cerandior's topic in Modder Support
Oops, sorry about that, I thought I had set-up everything at the beginning, didn't think of checking what the heck I was actually doing in the event. Also, thank you for the additional information about the two other things, however DeferredWorkQueue is deprecated for me on forge 1.14.4-28.1.96. Is there any alternative? Additional Question: Do all blocks take the air registry name by default if you don't specify one? -
I don't know what I am doing wrong here. The block is registered with the proper registry name. The name is provided correctly (I think) in the lang file. Don't know why it would display as "Air" too. That's oddly specific considering I have no mentions of Air anywhere. Any help would be appreciated. Here are the related classes/files: Main Class: https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/main/VanillaExtended.java BlockList Class: https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/blocks/BlockList.java ItemList Class: https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/items/ItemList.java lang File: https://github.com/Cerandior/VanillaExtended/blob/master/src/main/resources/assets/vanillaextended/lang/en_us.json
-
[1.12.2] How do i make it so my sword renders in my mobs hand?.
Cerandior replied to J0WAY's topic in Modder Support
Listen man. super refers to the parent class. In your case, your entity class (EntityBarbarian) extends EntityMob, therefore your entity is a "child" of EntityMob (the parent). Every method of your parent class is accessible to you, but if you want a specific implementation of those methods, you override them (the @Override annotation). In your case, you don't really need a specific implementation of "setItemStackToSlot" so you don't have to override that method. You simply have to call it with the specified parameters. You have overriden "setItemStackToSlot" to always call the super class's method with the MAINHAND slot and your BARBARIAN_SWORD as the itemstack. Now that's bad because your entity now will always call that method with your specified parameters. That's perhaps something you don't care about. You just want it to work, and the bloody thing doesn't work. The reason why It doesn't work, is because you are never calling the "setItemStackToSlot" method anywhere. How do you expect it to do anything if it is never being called. The perfect place to call this method would be at the "onInitialSpawn" method, which currently does absolutely nothing in your class. That method is called when your entity is initially spawned on the world, as the name of the method suggests. However you just return the super class's implementation of that method and do nothing else. Which actually means you are doing nothing, because your super class's "onInitialSpawn" method would have been called anyway even if you didn't override it. Before you return the super class's implementation of "onInitialSpawn", you call the "setItemStackToSlot" with the parameters that you want (Mainhand slot and a new itemstack instance of barbarian sword). So now your class has its own implementation of "onInitialSpawn" and overriding the method makes sense. -
[1.12.2] How do i make it so my sword renders in my mobs hand?.
Cerandior replied to J0WAY's topic in Modder Support
I wouldn't say that you need to know java specifically in order to get into modding, but you need to have a good idea on Object Oriented Programming. In terms of concept, it is different from procedural programming. Which I am assuming is what you have started learning first. The way of thinking in terms of objects and how they interact with each-other is what you must work on at the moment. When you get the concepts right, learning the language becomes easier because you understand what is going on. There are plenty of courses online related to OOP and they will be worth your time not just for modding. -
I had been using Eclipse for too long before I switched to IntelliJ this year, and I absolutely love IntelliJ. It has a neater environment, offers more tools, and generally speaking, is more professional. However I do miss something from Eclipse. While on debug mode, you could just edit the classes, save them, and the changes would pop right into the game. A very nice tool to have, especially when working with models and such because you can see what's going on right away without needing to restart the game every time you make a change. IntelliJ kind of has the same thing too and they call it HotSwap, but it feels a little sluggish compared to Eclipse. I have to do the process manually by hitting the "Reload Changed Classes" and it actually takes longer to update the game. Also, sometimes it doesn't even change anything in-game and that's where it gets a little annoying, especially for me right now that I am working on a model. I had to refresh the game everytime I made an adjustment because HotSwap couldn't update it while on debug mode and I wasted an hour trying to get everything to look right. Is there a way to make the IntelliJ debugger work like the Eclipse debugger? It would really help out to save some time.
-
[1.12.2] How do i make it so my sword renders in my mobs hand?.
Cerandior replied to J0WAY's topic in Modder Support
https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/client/models/SkeletonKingModel.java That's one of my own models, but it is in 1.14. Some things will be different for you. -
[1.12.2] How do i make it so my sword renders in my mobs hand?.
Cerandior replied to J0WAY's topic in Modder Support
I believe you have to override postRenderArm in your entity's model class for the item to be rendered. You can adjust the rotation points in there to get it to the position you want it. -
Yeah, I registered the entity and everything is fine now.
-
I have no idea man. I tried setting the breakpoints at different parts of the class because intelliJ displays a tree of all the methods called at that point and I never found any of the shareTags methods where I expected them to be. And I know, what I did doesn't really make too much sense because the stack should call the readShareTag and getShareTag automatically (I did look into a lot of methods related to itemstacks), but for some reason nothing was working as expected for me. I just tried that and everything works fine now, if I get rid of that line of code nothing works again. As for the entity, that is probably caused by the "unique" type of zombie that my staff spawns. I forgot to register that in my registry events. I am surprised the entity was spawning considering I haven't registered them actually. I will register them right now, and check if the error will persist. Thank you for your help.
-
[1.12.2] Preventing block breaking on left click with item
Cerandior replied to finley243's topic in Modder Support
Another thing you can do is Subscribe to the BlockEvent.BreakEvent and check if the player is holding your item and cancel that event. It doesn't have quite the same effect as the sword in creative, but it won't allow the player to break that block if he is holding the item. @SubscribeEvent public static void onBlockBreak(BlockEvent.BreakEvent event){ PlayerEntity player = event.getPlayer(); if(player != null){ Item item = player.getHeldItemMainhand().getItem(); if(item instanceof *youritemhere*){ event.setCanceled(true); } } } -
Ok, I did something and it now worked. I looked carefully into it and apparently the stack.hasTag() was returning false for my item. So whenever I Use the item, if the stack's tag is null, I set its tag to readShareTag(itemstack). Basically I am treating the readShareTag as a normal method since it wasn't being updated automatically. It is working now, the client and the server data is synced. This is what I did: @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { ItemStack stack = playerIn.getHeldItem(handIn); ICoolDownItem cap = stack.getCapability(CapabilityRegistry.COOLDOWN_ITEM, null).orElse(null); if(stack.getTag() == null){ stack.setTag(getShareTag(stack)); } if(!worldIn.isRemote && cap.isOffCooldown()){ if(hasHeads(playerIn) || playerIn.abilities.isCreativeMode){ Random rn = new Random(20); StaffZombie zm = new StaffZombie(worldIn, playerIn); zm.setPosition(playerIn.posX + rn.nextDouble() * 2, playerIn.posY, playerIn.posZ + rn.nextDouble() * 2); zm.setItemStackToSlot(EquipmentSlotType.HEAD, new ItemStack(Items.GOLDEN_HELMET)); worldIn.addEntity(zm); for(int i = 0; i<36; i++){ if(playerIn.inventory.getStackInSlot(i).getItem() == Items.ZOMBIE_HEAD && !playerIn.abilities.isCreativeMode){ playerIn.inventory.getStackInSlot(i).split(1); break; } } cap.setCooldown(cap.getMaxCooldown()); return new ActionResult<>(ActionResultType.SUCCESS, playerIn.getHeldItem(handIn)); } } return new ActionResult<>(ActionResultType.FAIL, playerIn.getHeldItem(handIn)); } One slight worry that I have right now is a warning showing up on the console: [Client thread/WARN] [minecraft/ClientPlayNetHandler]: Received passengers for unknown entity Why is that happening?
-
How about sending a chat message to the player when he activates the item to tell him when the item is in cooldown?. It is the ugliest way of doing this, but if nothing else works, to hell with it.
-
I can't get the shareTags working, no idea why they don't work. If there is really no way I can fix that, then maybe I can use GUI to inform the player of the item cooldown. Can I render a UI element on the client using server data? I was thinking about rendering a [ Cooldown : (cooldown) ] text above the slots, but I still need the correct cooldown values from the item capability for that to work.
-
I wasn't able to get my item sync using shareTags, so I decided to use packets. However I have not used packets before and I am finding their implementation a little tricky. The lack of mods running forge 1.14 makes it hard to find examples related to specific things you want to do so I am asking for help here. I want to sync my item capability to the client, because I am using a part of the data stored in that capability to render the durability bar. I followed the docs instructions for my packet implementation, but the data in the client is still not synced with the server. What have I done wrong here? Packet Handler Class Packet Class Item Class Thank you in advance.
-
Remove that println at the event handler. It's causing problems when the player object is converted to string.