Jump to content

Make a block only collidable for a specific entity


MosquitoFRA

Recommended Posts

In fact, I'm not used to this method. I found an example:

public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn) {
        super.addCollisionBoxToList(pos, entityBox, collidingBoxes, under);

        super.addCollisionBoxToList(pos, entityBox, collidingBoxes, middle);

        super.addCollisionBoxToList(pos, entityBox, collidingBoxes, top);
    }

 

So what do I have to do with these information?

Link to comment
Share on other sites

public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn)

     if(entity.projectiles)

    {   super.addCollisionBoxToList(pos, entityBox, collidingBoxes, under);

        super.addCollisionBoxToList(pos, entityBox, collidingBoxes, middle);

        super.addCollisionBoxToList(pos, entityBox, collidingBoxes, top);
    }

Is it like this?

Link to comment
Share on other sites

For the entity, it's entityLiving (I think it's for projectiles).
And I don't know to do this null check

     { if(EntityLiving)

        super.addCollisionBoxToList(pos, entityBox, collidingBoxes, under);

        super.addCollisionBoxToList(pos, entityBox, collidingBoxes, middle);

        super.addCollisionBoxToList(pos, entityBox, collidingBoxes, top);
    }

 

Edited by MosquitoFRA
Link to comment
Share on other sites

What diesieben was trying to say is that you should learn how to check if an entity is of a given instance or has some particular properties defined in the entity class. I'm pretty sure that the entity class itself has no "projectiles" property, and even if it does i don't think it's a boolean by the name. That being said, you should do something like this (assuming you are using Forge 1.12.2)

 

@Override
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, Entity entityIn, boolean isActualState) {
  if(entityIn instanceof EntityPlayer) {
    // Do stuff
  }
}

 

In this case you check if the entity that collides with the block is a player. If so then you can do whatever you want (like adding the collision box). 

Don't blame me if i always ask for your help. I just want to learn to be better :)

Link to comment
Share on other sites

On 11/4/2018 at 5:29 PM, JimiIT92 said:

...


@Override
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, Entity entityIn, boolean isActualState) {
  if(entityIn instanceof EntityPlayer) {
    // Do stuff
  }
}

...

And now you've just give him the code which he can copy-paste without learning anything from it.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

@Override
          public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, Entity entityIn, boolean isActualState) {
               if(entityIn instanceof EntityPlayer) {
                         public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
               return new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
                    }
               }
          }

I have this but it doesn't work

Edited by MosquitoFRA
Link to comment
Share on other sites

Learn java. Just the basics, 5 minutes of learning java and you will understand how horribly wrong that is on every level

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

@Override
          public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, Entity entityIn, boolean isActualState) {
               if(entityIn instanceof EntityPlayer) {
                         getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
               return new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
                    }
               }
          }

I tried this but it didn't work

Link to comment
Share on other sites

Learn Java.

Learn Java.

Learn Java.

 

Learn Java.

Edited by larsgerrits

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Ok, do you know what a method is?

right now your trying to define a method inside another method. This will never* work. I see you tried to fix your issue by removing “public AxisAlignedBB”, but your still trying to define a method inside a method, you’ve just now mangled the inner method. What you need to do where your trying to define the second (where your sure the entity is a player) method is run some code adding custom bounding boxes (look at fences), and otherwise (if the entity is not a player) call super (or run other logic).

 

 

*unless your instantiating an anonymous class (which you won’t learn about for a long time and may never need)

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

This has been said before “these formums are not a java tutorial”. Feel free to pm me on Discord (Cadiboo#8887) if you want help with this though

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Sorry, but I don't have Discord.

          @Override
          class collisionBox {
               public AxisAlignedBB addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, Entity entityIn, boolean isActualState) {
                    if(entityIn instanceof EntityPlayer) {
                         class boundingBox {
                              void getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
                                   return super.AxisAlignedBB[](0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
                              }
                         } 
                    }
               }
          }

I tried to correct the code as best as I could and search again on Google, but I can't figure it out.

Link to comment
Share on other sites

56 minutes ago, MosquitoFRA said:

Sorry, but I don't have Discord.


          @Override
          class collisionBox {
               public AxisAlignedBB addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, Entity entityIn, boolean isActualState) {
                    if(entityIn instanceof EntityPlayer) {
                         class boundingBox {
                              void getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
                                   return super.AxisAlignedBB[](0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
                              }
                         } 
                    }
               }
          }

I tried to correct the code as best as I could and search again on Google, but I can't figure it out.

Please, just go learn Java first. You have absolutely no idea what you are doing. That code won't even compile your IDE should be yelling its head off at you. 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

1 hour ago, Animefan8888 said:

go learn Java

 

On 11/6/2018 at 12:54 PM, Cadiboo said:

these formums are not a java tutorial

As I said though you can pm me for some help

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

I recommended discord because it

- doesn’t have a 1 minute delay between messages

- is something pretty much every gamer/programmer has

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.