Jump to content

Recommended Posts

Posted

Hello everyone. Here is my issue: I don't know how to make a bloc only collidable for players. Arrows can cross it which is very annoying because I want to make a shield which stop projectiles and not players. Any help would be great.

Posted

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?

Posted (edited)

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

 

     if(entity.projectiles)
    

Edited by MosquitoFRA
Posted

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?

Posted (edited)

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
Posted

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 :)

Posted

@MosquitoFRA there are hundreds of resources to help you learn basic Java online. I started with Codecademy. Please run through some basic Java tutorials or courses before you keep trying to make mods. You are setting yourself up for constant frustration and failure until you learn more Java.

Posted
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/

Posted (edited)
@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
Posted

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)

Posted
@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

Posted (edited)

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/

Posted

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)

Posted

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)

Posted

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.

Posted
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.

Posted
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)

Posted

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)

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.