Everything posted by Daeruin
-
[1.8.9] BreakEvent doesn't fire when on a server?
I believe the HarvestDropsEvent fires on both client and server, after the block is actually broken.
-
I'm having difficulty learning to mod for 1.12
Jabelar's stuff is great. I used his article on updating older mods (yes, I have it bookmarked) to update mine from 1.8 to 1.11. Jabelar is great at diving deep into specific subjects and explaining things that others don't. For brand-new, from-scratch stuff, I usually recommend Shadowfacts tutorials. I've occasionally used McJty's tutorials, as well. You can also learn a ton by browsing Choonster's test mod and/or The Grey Ghost's Minecraft by Example.
-
onUpdate() get player methods
You better use the code Draco posted before you cast the Entity to EntityPlayer, because if the Entity isn't an EntityPlayer and you try to cast it to EntityPlayer, bad things will happen.
-
[1.10.2] Different code formatting?
No effect on code. It's purely visual. Some people prefer the second way because it's more compact. I prefer the first way because it's more clear to me where code blocks begin and end. It's totally up to personal preference.
-
[1.11.2] Make large biomes the default
I got it to work by using an InitGuiEvent to check for GuiCreateWorld, then using reflection to modify the selectedIndex field of GuiCreateWorld to manually set it to WorldType.LARGE_BIOMES.getId(). This still allows the user to go into More World Options and change the world type if they want, but by default it will automatically be set to the Large Biomes type. If anyone has a good idea of another way to do it, I'm all ears. As a side note, when trying to set up the reflection, I was baffled by ReflectionHelper#setPrivateValue. I ended up doing it "manually" so to speak, without using ReflectionHelper. But I was initially trying to use ReflectionHelper#setPrivateValue like this: ReflectionHelper.setPrivateValue(GuiCreateWorld.class, event.getGui(), 2, "selectedIndex"); Where 2 is an int that's the value I wanted to set the field selectedIndex to. But Eclipse keeps giving me this error: The method setPrivateValue(Class<? super T>, T, E, int) in the type ReflectionHelper is not applicable for the arguments (Class<GuiCreateWorld>, GuiScreen, int, String). I'm actually trying to use the other setPrivateValue, whose final parameter is a vararg of String, rather than an int. I suspect I'm not passing a correct argument for E value, and it's causing Eclipse to think I want the other method, but I'm not sure. I tried reading up on generic type parameters but didn't see anything that clearly pointed to me doing it wrong. What am I not understanding here?
-
[1.10.2] [UNSOLVABLE] Make the player light like a torch?
How does Optifine handle its dynamic lighting? I believe they do it purely client-side, and from what I've seen performance is pretty good.
-
[1.10.2] Event that fires when a player attempts to fly (hit space bar twice?)
Pretty sure you can detect any key press using KeyInputEvent. See: http://jabelarminecraft.blogspot.com/p/minecraft-forge-1721710-keybinding.html. So you might be able to detect when the player uses space bar to fly. You can also use LivingUpdateEvent or PlayerTickEvent to see if the player is currently flying.
-
[1.11.2] Make large biomes the default
For my mod, I would like large biomes to be the default when people create a new world with my mod. How would you recommend going about this? Do I have to create my own WorldProvider, etc.? I'm open to that, because there's a chance I'll eventually want to do other stuff with it. But for now I'm kinda hoping there's a simpler way.
-
Grayscale
I doubt anyone here really wants to write the code for you. Most of us are here because we have our own ideas we are trying to implement. But you never know. If you want to try this yourself but have no experience with coding, you need to take a Java class or some online tutorials. I used Codecademy when I first started modding. There are others. Then you'll want to follow a basic modding tutorial. I recommend Shadowfacts tutorials since they are simple and up to date. Modding is very challenging for a complete beginner, but it can be really rewarding as well.
-
[1.10.2] [SOLVED] List of all Events??
The only list I've found is several years old. Since then, some events have been renamed and others are missing entirely. I made the mistake of using that list the other day and completely missed the event I needed, because it wasn't on the list. By relying on your IDE, you ensure you are always looking at the latest and greatest for your version. You will also benefit greatly from making yourself familiar with the contents of Forge's code. Instead of using the shortcuts Draco18s has posted, I sometimes like to just scroll down to the events. They are in the package net.minecraftforge.event. There are 10 sub packages. If you know what you're trying to accomplish, you usually only have to look in a few folders to find what you need.
-
Modify or remove vanilla block's collision box
Cool. That ended up being pretty easy. The GetCollisionBoxesEvent gives you a list of all the collision boxes involved in the event. I created an iterator to iterate over the list. From each AxisAlignedBB you can get a Vec3d of the center, from that you can get a BlockPos, and from that you can get the block. If it's a leaf block, remove the AxisAlignedBB from the list. I made the mistake of doing a regular for-loop over the list at first and got a concurrent modification exception. That's why I switched to an iterator.
-
Modify or remove vanilla block's collision box
Never heard of that one before. I was looking at a super old list of events that I got somewhere. It's a nice list because it summarizes a lot of information about tons of events on a single page. But it's pretty outdated. Next time I need to remember to check out the REAL list in my IDE.
-
Modify or remove vanilla block's collision box
I'd like to make it so the player can move through leaf blocks. Is there any way to modify or remove a vanilla block's collision box? I found a few old comments about people making this happen, but with no description. The one actual example I found used ASM. Not sure how to approach this or if it's even possible without ASM?
-
1.12 getting active item
This subject has been discussed many times on this forum. Use the search function. Actually, here you go. It took me 5 seconds to find this:
-
[1.12] Entity AI not working
Define "not working." We need to know what your problem actually is.
-
1.12 getting active item
BlockEvent.BreakEvent is called before the block is actually finished breaking. It's also called on the server only, I believe. I have found that if I want to do something as a result of blocks breaking, I usually need BlockEvent.HarvestDropsEvent since it fires on the server AND client, and fires after the block is broken, but before the block drops anything. There are a few different threads about making tree-choppers, so you could benefit from doing a search here on the forum.
-
(SOLVED) How to send text message to a player?
If you have the player, you can use EntityPlayer#sendMessage(new TextComponentString("string").
-
[1.10.2] How to check if there is room in the player inventory
Show how you're using it.
-
1.12 (This is a stupid question, probably anyone can answer it)
Please make your post title actually informative. And mark it solved if it's solved (even though nobody else seems to give a flying rat's ass).
-
[Solved] Difficulty creating a dirt block.
In addition to calling the method on the server side, the piece you are missing needs to be an IBlockState. For vanilla dirt, it would probably be Blocks.DIRT.getDefaultState(). If you're looking for podzol or something, you'll need to get that state instead.
-
[1.11.2] [SOLVED] Increased attack damage via NBT not working
That was it. I really appreciate your help, especially since nobody else seemed inclined to reply. Updated getAttributeModifiers method:
-
[1.11.2] [SOLVED] Increased attack damage via NBT not working
I must have read in a dozen different places that you should override Item#getAttributeModifiers (particularly Forge's ItemStack-sensitive version of it) in order to set a custom attack modifier on a tool, similar to how ItemSword does it. Yet it isn't working for me. getAttributeModifers gets called when displaying the tool tip, but not when it comes to actually applying damage. I finally found this nice method from Choonster that does work, however it results in this big nasty tool tip (see attachment) that I think comes from ItemStack#getToolTip. My item is a weapon that has to be held in your main hand to attack with, so this tool tip doesn't make sense. I was hoping someone would have a quick answer for how I control this tool tip.
-
[1.11.2] [SOLVED] Increased attack damage via NBT not working
I have implemented a custom recipe class that adds NBT data to the crafting output's ItemStack. It's just an integer that I want to use to increase the player's attack damage when using the tool. In my custom tool class, I have overridden Forge's ItemStack-sensitive version of getAttributeModifiers to look at the ItemStack's NBT data. I've also created a custom tool tip for the item, and I can see in my custom tool tip that the NBT data is there. But the player's attack damage is not changing when holding the item. What am I missing? Code for the custom tool:
-
[1.12] custom logs and planks
You'll need to find out what key the items typically use in the OreDictionary. As far as I know, it's arbitrary. I registered a bunch of my items as "bark" to the OreDictionary because I wanted them to be interchangeable with each other. I have no idea if other mods are using "bark" but if they are, those items will work in my recipes. Here's what I used to register my custom wood blocks to OreDictionary: OreDictionary.registerOre("logWood", BlockRegistry.logHickory);
-
[1.11.2] [SOLVED] Remember which buttons are enabled when resizing Minecraft window
Thank you. It's obvious, now that you say it. I created a List of Boolean and initialize it in the constructor to an empty ArrayList. I populate it alongside the standard buttonList as I create the buttons in initGui. When a button gets disabled, I update the List so the corresponding boolean there is set to false. When running initGui, as I create each button, I first check to see if that button's boolean in the List is already set to false; if so, the button already exists and needs to be disabled when redrawing the screen. It's working great.
IPS spam blocked by CleanTalk.