Started by
Quentindray74
on
Topic category: Help with MCreator software
Hello everyone! Okay, here's my problem:
I'm trying to make a Super Mario Mod! I've created the question Block which is fine, but, when i check 'block is collidable", so I added an event result when the player colides the block, which is replace the actual block by another one, the fact is that, i want it IF the player has (for the moment, a diamond one) custom helmet, but, it generates an error when it compiles it, I'll show you in a video.
https://www.youtube.com/watch?v=6dqcPqLB65g&feature=youtu.be
Without any functions, it works, but I want to.
please post the console log
Put in a spoiler for it
Try cast the Entity to an EntityPlayer
Hi Daleks, How do I do? I'm new!
And Nuparu, What?
The code is accessing a variable "inventory" from the player. However the player is here referenced as just Entity, that is the parent class for entities. But the player is always instance/child of EntityPlayer, so you can do instead of entity.inventory this ((EntiyPlayer)entity).inventory
Also, the console log is the log in the console tab. It has all useful information about what went wrong. Paste it on Pastebin and write here a link or paste it directly here, but put it in spoiler tags.
example:
[.spoiler]
some text
[./spoiler]
Just remove the dot.
Ok, I'll do it in a few hours! Thank you for your help ! :)
I've got this:
[.spoiler]
Executing gradle command: clean build
Microsoft Windows [version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. Tous droits r‚serv‚s.
E:\Pylo\MCreator175>cd forge
E:\Pylo\MCreator175\forge>SET "JAVA_HOME=E:\Pylo\MCreator175\jdk64\"
E:\Pylo\MCreator175\forge>SET JAVA_EXE=%JAVA_HOME%\bin\java.exe
E:\Pylo\MCreator175\forge>SET PATH=%JAVA_HOME%\bin\;%PATH%
E:\Pylo\MCreator175\forge>gradlew -Dorg.gradle.jvmargs="-Xms128m -Xmx4096m" clean build
Download http://files.minecraftforge.net/maven/net/minecraftforge/gradle/ForgeGr…
This mapping 'snapshot_20161220' was designed for MC 1.11! Use at your own peril.
#################################################
ForgeGradle 2.2-SNAPSHOT-f0ba31b
https://github.com/MinecraftForge/ForgeGradle
#################################################
Powered by MCP unknown
http://modcoderpack.com
by: Searge, ProfMobius, Fesh0r,
R4wk, ZeuX, IngisKahn, bspkrs
#################################################
:clean
:deobfCompileDummyTask
:getVersionJson
:extractUserdev
:downloadClient
:downloadServer
:splitServerJar
:mergeJars
:applyBinaryPatches
:deobfProvidedDummyTask
:extractDependencyATs SKIPPED
:extractMcpData
:extractMcpMappings
:genSrgs
:deobfMcMCP
Applying SpecialSource...
Applying Exceptor...
:sourceApiJava
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:sourceMainJava
E:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_question.java:112: error: cannot find symbol
if (((EntiyPlayer) entity).inventory[Items.DIAMOND_HELMET]) {
^
symbol: class EntiyPlayer
location: class BlockQuestion
E:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_question.java:112: error: incompatible types: ItemArmor cannot be converted to int
if (((EntiyPlayer) entity).inventory[Items.DIAMOND_HELMET]) {
^
2 errors
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
BUILD FAILED
Execution failed for task ':compileJava'.
Total time: 1 mins 32.079 secs
> Compilation failed; see the comp* Try:
iler error output for details.
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
E:\Pylo\MCreator175\forge>
Task completed with return code 0 in 92962 milliseconds
[./spoiler]
Oh, the first is just my mistype, it is supposed to be EntityPlayer, not EntiyPlayer. And the 2nd one , I would personally try to use : if (((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() != null && ((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() == Items.DIAMOND_HELMET)
Ok, I'll try
Okay, so I changed your line a little bit which is now:
[spoiler] if (((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() != null || ((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() == Items.DIAMOND_HELMET))
[/spoiler]
And, I still have an error:
[spoiler]
Executing gradle command: clean build
Microsoft Windows [version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. Tous droits r‚serv‚s.
E:\Pylo\MCreator175>cd forge
E:\Pylo\MCreator175\forge>SET "JAVA_HOME=E:\Pylo\MCreator175\jdk64\"
E:\Pylo\MCreator175\forge>SET JAVA_EXE=%JAVA_HOME%\bin\java.exe
E:\Pylo\MCreator175\forge>SET PATH=%JAVA_HOME%\bin\;%PATH%
E:\Pylo\MCreator175\forge>gradlew -Dorg.gradle.jvmargs="-Xms128m -Xmx4096m" clean build
This mapping 'snapshot_20161220' was designed for MC 1.11! Use at your own peril.
#################################################
ForgeGradle 2.2-SNAPSHOT-f0ba31b
https://github.com/MinecraftForge/ForgeGradle
#################################################
Powered by MCP unknown
http://modcoderpack.com
by: Searge, ProfMobius, Fesh0r,
R4wk, ZeuX, IngisKahn, bspkrs
#################################################
:clean
:deobfCompileDummyTask
:getVersionJson
:extractUserdev UP-TO-DATE
:downloadClient SKIPPED
:downloadServer SKIPPED
:splitServerJar SKIPPED
:mergeJars SKIPPED
:applyBinaryPatches SKIPPED
:deobfProvidedDummyTask
:extractDependencyATs SKIPPED
:extractMcpData SKIPPED
:extractMcpMappings SKIPPED
:genSrgs SKIPPED
:deobfMcMCP SKIPPED
:sourceApiJava
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:sourceMainJava
E:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_question.java:111: error: illegal start of expression
if( if (((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() !== null && ((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() ==== Items.DIAMOND_HELMET)){
^
E:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_question.java:111: error: illegal start of expression
if( if (((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() !== null && ((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() ==== Items.DIAMOND_HELMET)){
^
E:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_question.java:111: error: illegal start of expression
if( if (((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() !== null && ((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() ==== Items.DIAMOND_HELMET)){
^
E:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_question.java:111: error: not a statement
if( if (((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() !== null && ((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() ==== Items.DIAMOND_HELMET)){
^
E:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_question.java:111: error: ';' expected
if( if (((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() !== null && ((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() ==== Items.DIAMOND_HELMET)){
^
5 errors
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wTotal time: 29.379 secs
rong:
BUILD FAILED
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
E:\Pylo\MCreator175\forge>
Task completed with return code 0 in 30237 milliseconds
Executing gradle command: clean build
Microsoft Windows [version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. Tous droits r‚serv‚s.
E:\Pylo\MCreator175>cd forge
E:\Pylo\MCreator175\forge>SET "JAVA_HOME=E:\Pylo\MCreator175\jdk64\"
E:\Pylo\MCreator175\forge>SET JAVA_EXE=%JAVA_HOME%\bin\java.exe
E:\Pylo\MCreator175\forge>SET PATH=%JAVA_HOME%\bin\;%PATH%
E:\Pylo\MCreator175\forge>gradlew -Dorg.gradle.jvmargs="-Xms128m -Xmx4096m" clean build
This mapping 'snapshot_20161220' was designed for MC 1.11! Use at your own peril.
#################################################
ForgeGradle 2.2-SNAPSHOT-f0ba31b
https://github.com/MinecraftForge/ForgeGradle
#################################################
Powered by MCP unknown
http://modcoderpack.com
by: Searge, ProfMobius, Fesh0r,
R4wk, ZeuX, IngisKahn, bspkrs
#################################################
:clean
:deobfCompileDummyTask
:getVersionJson
:extractUserdev UP-TO-DATE
:downloadClient SKIPPED
:downloadServer SKIPPED
:splitServerJar SKIPPED
:mergeJars SKIPPED
:applyBinaryPatches SKIPPED
:deobfProvidedDummyTask
:extractDependencyATs SKIPPED
:extractMcpData SKIPPED
:extractMcpMappings SKIPPED
:genSrgs SKIPPED
:deobfMcMCP SKIPPED
:sourceApiJava
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:sourceMainJava
E:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_question.java:111: error: illegal start of expression
if(if (((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() !== null || ((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() ==== Items.DIAMOND_HELMET))){
^
E:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_question.java:111:compileJava FAILED
: error: illegal start of expression
if(if (((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() !== null || ((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() ==== Items.DIAMOND_HELMET))){
^
E:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_question.java:111: error: illegal start of expression
if(if (((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() !== null || ((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() ==== Items.DIAMOND_HELMET))){
^
E:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_question.java:111: error: not a statement
if(if (((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() !== null || ((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() ==== Items.DIAMOND_HELMET))){
^
E:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_question.java:111: error: ';' expected
if(if (((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() !== null || ((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() ==== Items.DIAMOND_HELMET))){
^
5 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
BUILD FAILED
Total time: 36.453 secs
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
E:\Pylo\MCreator175\forge>
Task completed with return code 0 in 36951 milliseconds
[/spoiler]
You haven't deleted the original "if("
Ok, I didn't see sorry & Thanks!
But now, I've got 1 error:
https://pastebin.com/mMb4vYZw
Can I see your whole code?
Of the block? If yes,
https://pastebin.com/PWjfZP28
You have one more "equality sign" behind "!". This should work:
@Override public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity){ if(entity instanceof EntityPlayer){ if(((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() != null && ((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() == Items.DIAMOND_HELMET){ world.setBlockState(pos, mcreator_brickBlock.block.getDefaultState(), 3); } } }