Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello, I am having a problem with my entity's collision box, specificly it lets players go thru the entity, I dont want that.

I tried every possible way I saw in the vanilla minecraft logic... sadly couldnt get it to work.

Here is my code,

 

 

/**

*

*/

package com.zetaworx.tardis.block;

 

import java.util.Iterator;

 

import com.google.common.io.ByteArrayDataInput;

import com.google.common.io.ByteArrayDataOutput;

import com.zetaworx.tardis.lib.Vector3;

 

import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;

 

import net.minecraft.block.Block;

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityLiving;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.util.AxisAlignedBB;

import net.minecraft.util.DamageSource;

import net.minecraft.world.World;

 

/**

* @author ZetaHunter

*

*/

public class EntityTardis extends EntityLiving implements IEntityAdditionalSpawnData {

 

public String owner;

//public AxisAlignedBB boundingBox;

/**

* @param par1World

*/

public EntityTardis(World par1World) {

super(par1World);

this.height = 3;

this.width = 2;

}

 

    public AxisAlignedBB getCollisionBox(Entity par1Entity)

    {

        return par1Entity.boundingBox;

    }

 

public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)

    {

        if (this.isEntityInvulnerable())

        {

            return false;

        }

        else

        {

        if (this.owner != null) {

        System.out.println(this.owner);

        }

            //this.setDead();

            return true;

        }

    }

 

// @Override

//    public AxisAlignedBB getBoundingBox()

//    {

//        return AxisAlignedBB.getBoundingBox(-1, 0, -1, 1, 2, 1);

//    }

 

@Override

    public boolean canBeCollidedWith()

    {

        return true;

    }

 

public EntityTardis(World w, double x, double y, double z, String owner) {

this(w);

this.owner = owner;

this.setPosition(x, y, z);

}

 

public void onUpdate() {

this.activePotionsMap.clear();

this.extinguish();

}

 

@Override

protected void entityInit() {

}

 

@Override

public void readEntityFromNBT(NBTTagCompound var1) {

super.readEntityFromNBT(var1);

this.owner = var1.getString("owner");

}

 

@Override

public void writeEntityToNBT(NBTTagCompound var1) {

super.writeEntityToNBT(var1);

var1.setString("owner", this.owner);

}

 

@Override

public void writeSpawnData(ByteArrayDataOutput data) {

data.writeUTF(this.owner);

}

 

@Override

public void readSpawnData(ByteArrayDataInput data) {

this.owner = data.readUTF();

}

 

//Some cruel fun part :3

public boolean nuke(World worldObj, Vector3 position, Entity explosionSource, int callCount)

{

if (!worldObj.isRemote)

{

if (callCount == 1)

{

for (int x = (int)-getRadius(); x < getRadius(); x++)

{

for (int y = (int)-getRadius(); y < getRadius(); y++)

{

for (int z = (int)-getRadius(); z < getRadius(); z++)

{

Vector3 targetPosition = Vector3.add(position, new Vector3(x, y, z));

double dist = position.distanceTo(targetPosition);

 

if (dist < getRadius())

{

int blockID = targetPosition.getBlockID(worldObj);

 

if (blockID > 0)

{

if ((blockID != Block.bedrock.blockID))

{

if ((dist < getRadius() + 5.0F))

{

targetPosition.setBlockWithNotify(worldObj, 0);

}

}

}

}

}

}

}

Iterator<?> entities = worldObj.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getAABBPool().addOrModifyAABBInPool(

position.x - getRadius(), position.y - getRadius(), position.z - getRadius(), position.x + getRadius(), position.y + getRadius(), position.z + getRadius())).iterator();

while (entities.hasNext()) {

//System.out.println(entities.next().toString());

EntityLiving entity = (EntityLiving) entities.next();

entity.performHurtAnimation();

entity.attackEntityFrom(DamageSource.outOfWorld, 150);

}

return false;

}

 

}

 

if (callCount > getRadius())

{

return false;

}

 

return true;

}

 

public float getRadius()

{

return 10.0F;

}

 

@Override

public int getMaxHealth() {

return 1;

}

}

 

 

 

Currently everything but the collision box works perfectly so I dont see point posting any other source's.

But if needed I will.

 

Before I tried to make the block do what I planed, but it was causing even more trouble...

~I was here~

Do you want to let your entity push / block the Player like in the old versions of Minecraft? If yes, you would have to edit the EntityPlayer class. You can do that directly and risk incompatibilities with many other mods (which is bad), or you make your mod as a coremod.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

  • Author

There really isnt any other way to make the entity solid? :/

Cause I want it to be compatibly with everything...

~I was here~

There really isnt any other way to make the entity solid? :/

Cause I want it to be compatibly with everything...

 

Well, the only thing you could do is to make your mod as a core mod. But don't ask me how, since I never made such a mod before.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Let me start this off with WRONG!

Do

@Override

public AxisAlignedBb getBoundingBox(){

return yourboundingbox;

}

 

Simple as that

Btw, do you know anyways to get entities to be less fidgety?

"you seem to be THE best modder I've seen imo."

~spynathan

 

ლ(́◉◞౪◟◉‵ლ

Let me start this off with WRONG!

Do

@Override

public AxisAlignedBb getBoundingBox(){

return yourboundingbox;

}

 

Simple as that

Btw, do you know anyways to get entities to be less fidgety?

 

That is PARTIALLY right. You can add a collision box, yes, but that would only be recognized for the entity itself. Other entities ignore the Bounding Box. In order to achieve the idea the thread creator has, you have to add this method and return a Bounding Box to the EntityPlayer class (which must be done either with ASM (coremod) or base-edits)

 

WHOOPS, I looked at the wrong method (getCollisionBoundingBox). Yes, you're right, it works... I never used that method before. :D

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.