Started by
Sajevius
on
Topic category: Help with Minecraft modding (Java Edition)
I wanna know how to make it so that when a player mines a certain block (e.g. an ore in the Nether), nearby zombie pigmen will get angry at said player.
thanks in advance!
( P.S. I honestly don't know if this is a duplicate forum topic, so please bear with me, for I could not find this topic anywhere else in this site as far as I searched :P )
Edited by Sajevius on Fri, 09/25/2020 - 11:05
you would have to get the nearest pigzombie within range, and manually code setRevengeTarget to the player entity
is there anywhere i can find a code template? i would appreciate an in-depth explanation if possible as well... so that i don't mess up
which version of mcreator and for which version of minecraft are you making the mod for?
MCreator 2020.4
Forge 1.14.4
so...
any luck?
i'm still using 2020.3 for 1.12.2, so i don't know if 2020.4 has a new code block that gets the nearest entity or not, so i can only do it in code.
basically you do something like this:
the 10 in .grow(10) is the range for finding pig zombies.
i think there's already a code block that gets the nearest entity of a certain (sub)type within a certain range, but as for the one making pigmen aggressive (target a certain entity e.g. player), no such procedure exists yet and isn't part of the block creation wizard settings :/
but i'll try it on 1.14 tho, see what i can do, and if not, tinker with the code a bit, see if some classes/methods/parameters changed even a bit, although i'm an amateur when it comes to Minecraft's source code...
so, if I'm right, would I also have to import net.minecraft.entity.hostile.ZombiePigmanEntity?
if you can use existing code blocks to get the nearest entity in the procedure, then i would just add code snippet blocks in that procedure to set the revenge target, that way you won't need to import anything (mcreator does it automatically), and you won't need to edit source code.
ok, I'll try that. thx
i just keep getting a build error that says:
C:\Users\USER\MCreatorWorkspaces\deeper_inferno\src\main\java\com\sajevius\infernal_depths\procedures\VulkatiteOreBlockDestroyedByPlayerProcedure.java:44: error: cannot find symbol entity.getEntityBoundingBox().grow(10), entity);
^
symbol: variable entity
location: class VulkatiteOreBlockDestroyedByPlayerProcedure
C:\Users\USER\MCreatorWorkspaces\deeper_inferno\src\main\java\com\sajevius\infernal_depths\procedures\VulkatiteOreBlockDestroyedByPlayerProcedure.java:44: error: cannot find symbol entity.getEntityBoundingBox().grow(10), entity);
^
symbol: variable entity
location: class VulkatiteOreBlockDestroyedByPlayerProcedure
C:\Users\USER\MCreatorWorkspaces\deeper_inferno\src\main\java\com\sajevius\infernal_depths\procedures\VulkatiteOreBlockDestroyedByPlayerProcedure.java:46: error: cannot find symbol entityFound.setRevengeTarget(entity)
any way to fix it and information about the "entity" variable? (is the "entity" variable referring to the player? how should i declare it in code?)
how did you put the custom code in, using code snippet blocks or locking the element and manually editing code? be helpful if you posted the code blocks or source code.
for 1.14.4 it should be getBoundingBox() instead of getEntityBoundingBox(). as for the other error, i need to know which symbol was not found, "entityFound" or "setRevengeTarget".
i used code snippets on my 1st attempt, and when i found out it didn't work despite the ZombiePigmanEntity class being already imported, I proceeded to lock the code on 2nd attempt. ("EntityPigZombie" has been changed to "ZombiePigmanEntity") The only symbol that can't be found according to the error in console logs is "entity", and it looks like "entity" refers to the player, right? anyway, here's the src code:
i'm quite curious about how to use the "entity" symbol here. should I add an entity dependency as well, to make it work and make pigmen target the player?
also it seems that "findNearestEntityWithinAABB" has now been renamed to "getClosestEntityWithinAABB"...