Problems with Collides...

Started by Quentindray74 on

Topic category: Help with MCreator software

Joined Jun 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Problems with Collides...

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.

 

Joined Jan 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
please post the console log
Thu, 06/29/2017 - 06:53

please post the console log

Put in a spoiler for it

 

Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Try cast the Entity to an
Thu, 06/29/2017 - 11:39

Try cast the Entity to an EntityPlayer

Joined Jun 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hi Daleks, How do I do? I'm
Thu, 06/29/2017 - 23:03

Hi Daleks, How do I do? I'm new!

And Nuparu, What?

Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The code is accessing a
Fri, 06/30/2017 - 10:10

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.

Joined Jun 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Ok, I'll do it in a few hours
Fri, 06/30/2017 - 10:14

Ok, I'll do it in a few hours! Thank you for your help ! :)

Joined Jun 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I've got this:
Fri, 06/30/2017 - 11:05

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]

Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Oh, the first is just my
Fri, 06/30/2017 - 11:15

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)

Joined Jun 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Okay, so I changed your line
Fri, 06/30/2017 - 11:21

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]

Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You haven't deleted the
Fri, 06/30/2017 - 16:05

You haven't deleted the original "if("

Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can I see your whole code?
Fri, 06/30/2017 - 20:56

Can I see your whole code?

Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You have one more "equality
Sat, 07/01/2017 - 07:45

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); } } }