-
Posts
21 -
Joined
-
Last visited
Posts posted by FrostBytes
-
-
Just now, diesieben07 said:
DamageSource#getTrueSource will give you the entity causing the damage, if there is any. You can then check if it's a living entity (instanceof EntityLivingBase) and if so use EntityLivingBase#getHeldItemMainhand to get the held item. Check if that item is yours and if so, increase the drop chance.
How would I "increase the drop chance?"
Currently I have no loot tables or any of the sort set up. Would it just be spawning the item entity? -
To be more specific:
I have a chance for a item to drop when killed normally. However, it's ridiculously small, so it basically means you'd have to be really lucky to get the drop.
However, there's an item in my mod, that lets you significantly increase the chances of this item being dropped. How would I do that? -
1 hour ago, Cadiboo said:
Because there are better ways of doing this than the one you’re trying. For example, putting the item into the container from the container. This is super easy if the container has something that runs every tick (like an Entity or a TileEntity).
What you’re trying to do is always relevant, because there’s usually a better way of doing it.
Wow. Never really thought of that. Thanks.
-
14 minutes ago, Cadiboo said:
That much is obvious. What will this achieve for an end user perspective?
It's going to just be code that randomly checks if there is a certain container nearby and move the itemstack into it. Not sure how that would contribute to this.
-
I’ve been reading up on capabilities, but capabilities seem like something used to store different types of data or lists of data. What would be the best way to store an integer in an itemstack?
-
14 hours ago, Laike_Endaril said:
If you're trying to do something that changes at a constant rate over time, you can do it using timestamps. What exactly is the goal?
I’m trying to run code every tick for every itemstack currently loaded.
-
47 minutes ago, DavidM said:
In this case you need to use different method fr each. I don't think this is possible with the chest inventory though (in which case you have to create your own chest).
As for on the floor, override Item#onEntityItemUpdate.
Would it be possible to override functionality of the vanilla chest from the mod?
-
50 minutes ago, DavidM said:
When? When in the player's inventory? Please clarify.
To call a function every tick when the item stack is in the player's inventory, override Item#onUpdate.
Generally anywhere. Like if it's in a player inventory, or a chest inventory (as long as it's loaded) or on the floor?
-
I'm trying to call a function every tick for each ItemStack that is a type of my Item. How would I do that?
-
5 hours ago, diesieben07 said:
What kind of data do you want to change? It would help if you could explain what you are actually trying to achieve.
I’m not trying to achieve anything atm. I just want to know what I can do with it and how. I just want someone to break down some of the information provided in the documents because I don’t really understand it. But, because it will be a complete waste of time rewording everything, lets just say I want to make power levels for an item. This item carrys only a single integer that cannot be higher than 20. How would I implement the capability system to do such thing?
- 1
-
Thanks. It should work now.
Lock request. -
Alright, may have jumped to conclusions there. But why is SOOCH null? According to the Forge Documentation:
"After the Register<Block> event has fired, all ObjectHolder annotations are refreshed, and after Register<Item> has fired they are refreshed again."
Which means that SOOCH should've been injected, but it's null.
Spoiler@ObjectHolder(Soochcraft.MODID) public class SoochItems { public static final ItemSooch SOOCH = null; }
Is it not injecting because of the uppercased SOOCH variable? I was told before that it automatically lowercases and *then* checks for injection.
-
So, I have two SubscribeEvent methods. One registers all my items (1 so far) and the other registers the models on the client. From many other tutorials, I've seen many styles of this, but they are all different. I'm using this one from cubicoder's tutorial.
Spoilerpublic class SoochModelRegEvents { // this is only registered on client and in preinit (placing the register call anywhere else will cause the handler to miss the modelreg events) @SubscribeEvent public static void registerModels(ModelRegistryEvent event) { registerModel(SoochItems.SOOCH); } private static void registerModel(Item item) { ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory")); } }
Spoilerpublic class SoochRegisterEvents { @SubscribeEvent public static void registerItems(Register<Item> event) { final Item[] items = { new ItemSooch() }; event.getRegistry().registerAll(items); } }
Here's the problem though. Item registering comes after the model registries. Which means that SoochItems.SOOCH is null when the model register events are called.
How do I handle this? Should I just initialize all of my items in an array? This gets rid of the entire point of ObjectHolder, so I wasn't tempted to do it. As I said, every tutorial I can find conflicts in some way. What do I do? -
I didn't really understand the Forge Capabilities docs and I was asking if someone could help me digest the information.
Things I understand:
Capabilities provide a way to save data, like energy or inventories.
How am I supposed to change data about a tile entity using capabilities? I understand how to create a custom capability, but after that I was lost. -
Thanks a lot, that helped clear things up a bit.
-
I have a really good question.
How does a mod create it’s own recipe system? I could imagine it has something to do with IRecipe, but I don’t know where to start.
-
You can always just generate your own JavaDocs. The Forge source (at least from GradleForge) seldom has JavaDoc comments, and the comments that are there are limited in information. If you really want to comprehend everything, build your own JavaDocs.
2 hours ago, JavaMan7 said:1. add this line apply plugin: 'eclipse' to build.gradle just under apply plugin: 'net.minecraftforge.gradle'
2. run gradlew eclipse
3.if eclipse is open restart it
NOTE: you must build first.
That's not how you build JavaDocs in Eclipse, at least from the time I used the program.
Project > Generate JavaDocs- 1
-
Nevermind. This API doc helped me understand what happens where and actually answers a problem I was considering too:
https://mcforge.readthedocs.io/en/latest/concepts/sides/
Lock? -
4 minutes ago, deerangle said:
Where the event is called really depends on the Event and where it is being invoked.
How do I know if it's going to be executed on the server or the client?
-
I am aware of the single-player internal server concept. At least from what I've been reading, single-player worlds are really just local listen servers. But I have a question. Lets take an event:
public class BlockEvent extends Event
What is with this event? Is the event only called on the server, or on both clients? And how about other events? How do I know if some are called on the client or server?
[1.12.2] Only drop when killed by a certain weapon.
in Modder Support
Posted
I’m not. I was just asking in case I started to do something and then someone presented a solution for something else.
I’ll try that when I can.