Siqhter
Members-
Posts
149 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Siqhter
-
Registering an Event class that extends EntityLiving
Siqhter replied to Siqhter's topic in Modder Support
Yes, sorry I didn't post the whole class, I was editing it. Here. And the error, but I don't know what to do if I can't cast EntityCow. -
Registering an Event class that extends EntityLiving
Siqhter replied to Siqhter's topic in Modder Support
That's funny, I thought it was restricted to classes that extend EntityLiving, don't know how I missed that. Basically the event I'm trying to use is the right click event, for the custom cow milking mechanic I made, and I'm wanting to check to make sure you can't milk a baby cow, that's all its for. However, I created a variable, And then instantiated it in the method. But it's throwing an unexpected error thrown error on right click. -
Registering an Event class that extends EntityLiving
Siqhter replied to Siqhter's topic in Modder Support
Because, for example, I'm writing a method that checks if an EntityCow is a baby (this.isChild, so actually it should extend EntityCow, not EntityLiving). I can't figure out any other way to do it. And yes, I tried to pass an instance of world, but it's not liking it. -
Registering an Event class that extends EntityLiving
Siqhter replied to Siqhter's topic in Modder Support
Yep, sorry. Here is the entire Events class. I haven't actually edited a mob's AI yet, because I want to get the class registered and setup first. And if you needed the Main code, here is the init registration in Main. -
I have an Events class that needs to extend EntityLiving. However, when I attempt to register it in my Registry class init method, like this, it gives an error and says "Events (World) in Events cannot be applied." This is the super in the Events class that is causing the problem. And just to clarify, I am not registering a new entity, just a class that extends one. I have read over the forge docs in regards to registering, but I don't know if I'm overlooking something. Thanks.
-
Got it, thanks.
-
Well I tried making a conditional like this, but I'm not sure if I'm following you. I understand the idea.
-
Well, I realized if I return true then it doesn't allow both hands (from EnumHand) to be fired. But it still runs the addItemStackToInventory code twice.
-
Ah, I see. I debugged my code and can confirm it is running twice. e.g. Instead of subtracting 1 bottle from the stack, it takes 2. Aside from that it it working. Here is the correct class. I added this so it would add the final bottled item to the players current hand when the stack of empty bottles is depleted.
-
Well, I know, like I said it was the code I originally had, I tried reposting because the formatting got screwed up. Let me repost in a second.
-
If I define player locally it works, but I'm not sure why. Also I posted what I originally had, I know the .setCount isn't correct.
-
public class MainEvents { @SubscribeEvent public void inventoryif isRemoteif instanceof if EMPTY_BOTTLE capabilitiesisCreativeModeinventorynew BOTTLED_MILKENTITY_COW_MILK1.0F1.0F
-
Ok, that makes sense, but for some reason I'm crashing when I initialize the variable player that I defined at the top of my class.
-
I understand now why I should use addItemStackToInventory, but I'm just not clear on the set count.
-
So if I have, lets say, a stack of 10 bottles, when I right click to milk a cow, it deletes the whole stack and replaces it with a filled bottle, whereas it needs to just add a filled bottle to the inventory and not delete the stack. I looked through EntityCow code in the milking event, but it's not working. Not sure what concept I'd have to add to the code below.
-
Got it! Thanks for your help in thinking about it logically.
-
Right, I figured that out and was just adding a conditional to check whether or not the player is wearing the boots. How can I check for a specific enchantment?
-
I have recently been playing around with enchantments, and I setup the book/enchantment attributes in no time, but I'm having trouble mimicking the Frost Walker enchantment. For now, I am just trying to get it to act exactly like Frost Walker. Not sure if I'm registering wrong or just have overlooked something (I have never coded a functional enchantment). The enchantment book shows up fine, and applies to items in an anvil just as it should. No errors are logged, just nothing happens when I walk on ice. Thanks. UPDATE: I never called the freezeNearby class, so after adding to this to EnchantmentInit MyEnchantment.freezeNearby(livingBase, world, pos, 1); it works. However it does it whenever a player steps on ice, not when the enchanted boots are equipped.
-
V0idWa1k3r and Cadiboo thanks it works now.
-
Ok, I guess I got it figured out. Would it make sense to return if(world.isRemote)?
-
Ok, thanks for your help I think I'm getting it. Just to clarify I was looking through ItemMilkBucket's Class, and I found this. Is it basically just checking to make sure it's running on the server? if (!worldIn.isRemote) entityLiving.curePotionEffects(stack);
-
I think I understand what you are saying. I am currently modding on 1.12.2. And how would I check that it is only "filling" the bottle on the server?
-
So I just joined the forums today because this problem has been bugging me for a while. When I go to milk a cow with a custom empty bottle, it works fine, and the bottle becomes "bottled milk". When I drink the milk, everything works as expected and I receive an empty bottle. But when I go to milk the cow again, the item becomes bottled milk and then reverts to an empty bottle after a few seconds, like it won't hold the milk. Not sure if it is running the code with the EnumAction.DRINK automatically or what. Below are my CustomBottledItem and MainEvents classes. Thanks.