Jump to content

Unable to delete water blocks


Player131

Recommended Posts

Hi all,

 

I need help to finish my EntityDrone... Indead, i'm trying to make a drone that is able to destroy blocks as well as water ! The problem is that sometimes on oceans, it works, water dissapear, but 1 second after, the game began to re-add water blocks at their original place !

 

Here is my code (i gave you the complete onImpact function witch gets called everytime entity hit something)

    /**
     * Called when this EntityDrone hits a block or entity.
     */
    protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
    {
        if (!this.worldObj.isRemote)
        {
            if (par1MovingObjectPosition != null && par1MovingObjectPosition.entityHit != null)
            {
                par1MovingObjectPosition.entityHit.attackEntityFrom(new DamageSource("AncientDamage"), 99F);
            }

            this.worldObj.newExplosion(null, this.posX, this.posY, this.posZ, 2.0F, true, this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"));
            this.worldObj.setBlock((int)this.posX, (int)this.posY, (int)this.posZ, Blocks.flowing_lava);

            List l = worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX - 3, this.motionY - 3, this.motionZ - 3).expand(3.0D, 3.0D, 3.0D));
            for (Object e : l){
                if (e instanceof EntityItem){
                    ((EntityItem) e).setDead();
                } else if (e instanceof EntityPlayer){
                    ((EntityPlayer) e).attackEntityFrom(new EntityDamageSourceIndirect("AncientDamage", this, shootingEntity), 99F);
                }
            }

            for (int x = (int) (posX - 3) ; x < posX + 3 ; x++){
                for (int z = (int) (posZ - 3); z < posZ + 3 ; z++){
                    for (int y = (int) (posY - 3); y < posY + 3 ; y++){
                        Block b = worldObj.getBlock(x, y, z);
                        Block b1 = worldObj.getBlock(x, y - 1, z);
                        if (b != Blocks.air && b == Blocks.bedrock) {
                            worldObj.removeTileEntity(x, y, z);
                            worldObj.setBlock(x, y, z, Blocks.air);
                        } else if (b == Blocks.air && b1 != Blocks.air){
                            worldObj.removeTileEntity(x, y, z);
                            worldObj.setBlock(x, y, z, Blocks.fire);
                        } else if (b != Blocks.air && b == Blocks.water){
                            worldObj.removeTileEntity(x, y, z);
                            worldObj.setBlock(x, y, z, Blocks.air);
                        } else if (b != Blocks.air && b == Blocks.flowing_water){
                            worldObj.removeTileEntity(x, y, z);
                            worldObj.setBlock(x, y, z, Blocks.air);
                        }
                    }
                }
            }

            this.setDead();
        }
    }

Thanks by advance

 

Link to comment
Share on other sites

Ok, so a couple things--and this is not related to your described problem.

 

1)

if (b != Blocks.air && b == Blocks.bedrock)

I do not think this is doing what you meant for it to do.

2)

worldObj.removeTileEntity(x, y, z);

unless your intent is for chests (and other containers) to destroy their contents and not drop them, this is likely not a good idea.

3)

} else if (b != Blocks.air && b == Blocks.water){

and

} else if (b != Blocks.air && b == Blocks.flowing_water){

same problem as #1

 

Now, related to your actual problem:

 

You do know that two water source blocks adjacent to each other will cause the non-source block between them to become a source block, yes?  Ok good.  If it's not that behavior, then I don't know what's causing your problem.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Have you any idea to solve the problem ?

Because normaly, the two source block think should work only if there's 1 layer of water, but it's realy strange !

Because sometimes, the entity is completely working destroying water, it's just on oceans that the bug is happening...

Link to comment
Share on other sites

And by "changed" we mean "that was a vanilla bug, and it was fixed."

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Ok but that's also defigning the bug as "can't be solved", isn't it ?

 

Anyway, i made a workaround : instead of exploding my EntityDrone whe it hits the ocean, i made it traveling under water by removing blocks of water ! It looks prety good at my eyes ! I'll try to make a video ; i'm sure i can using my NVIDIA GeForce Experience Software. I'll post it here soon.

 

 

EDIT : Here is the video i just made

EDIT 2 : I'll upload source code on GitHub when I'll solve Intellij's problem !

Link to comment
Share on other sites

Maybe I'm missing something, but why does it need to remove the water at all?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

No, I mean, why does it need to destroy the water in order to fly through it?

i made it traveling under water by removing blocks of water

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I don't even know myself. Maybe because when i made this entity i had the idea of destroying water blocks. But i think i'll remove this ability, and create another weapon that will generate a laser to fire everything, then it will remove blocks of water until you change the direction of the laser.

 

But for the moment i'm not realy sure how i can make a laser to render. I think it will need some advanced stuff using GL11.glVertex3f or using Mojang's Tesselator.

 

If you have any idea to solve the original problem, removing water blocks whith explosion, then post here, i'll be happy to include it in my code !

Link to comment
Share on other sites

Hi

 

You could perhaps create a custom block which looks exactly like air but stops water flowing into it.  For example like a ladder that you can't see.

 

-TGG

 

Oh !! Thank you so much i didn't think of that !! I'll try to do it, after i arrive to make GitHub Working correctly !

When my GitHub app will be back, the mod source code will be available here : https://github.com/Yuri6037/AncientAddinMod

 

EDIT : GitHub repo complete ! Everyone can view source code now ! The project is free and opensource !

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.