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

Hey all, CJ here, I was recently creating a block (pretty standard) and when testing it in world I noticed something. It can be replaced with another block. When you try to place a block on top of it, or on the side of it, or anything, if you click on the block to do so, it replaces the block. Now, I went and did another block, and it doesn't do this at all. Looked, and I have the same stuff in it that affects bounding boxes and all that. Nothing. Yep, that is right, I originally messed with the BB and then took it out because it didn't fix it, but now it is gone. So their should be nothing that makes it do this, right? Well, that is what I thought. Here is the code I used for the block.

 

 

package net.CJCutrone.TheGrid.block;

 

import java.util.Random;

 

import net.CJCutrone.TheGrid.common.TheGrid;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IconRegister;

import net.minecraft.entity.Entity;

import net.minecraft.item.Item;

import net.minecraft.util.AxisAlignedBB;

import net.minecraft.util.DamageSource;

import net.minecraft.world.Explosion;

import net.minecraft.world.World;

 

public class MaelstromSource extends Block{

 

public MaelstromSource(int par1, Material par2Material) {

super(par1, par2Material);

this.setHardness(1F);

this.setLightValue(-1F);

}

 

 

public void onEntityWalking(World par1World, int par2, int par3, int par4, Entity par5Entity) {

        par5Entity.attackEntityFrom(DamageSource.wither, 2.0F);

        par5Entity.setInWeb();

    }

 

 

public int idDropped(int par1, Random par2Random, int par3)

    {

        return 0;

    }

 

    public void registerIcons(IconRegister ir){

 

blockIcon = ir.registerIcon("TheGrid:MS");

 

}

   

    public void onBlockDestroyedByExplosion(World par1World, int par2, int par3, int par4, Explosion par5Explosion) {

   

   

    if(par1World.isAirBlock(par2, par3, par4)){

    par1World.setBlock(par2, par3, par4, TheGrid.MaelstromSource.blockID);

   

    }if(par1World.isAirBlock(par2 + 1, par3, par4)){

    par1World.setBlock(par2 + 1, par3, par4, TheGrid.MaelstromSource.blockID);

   

    }if(par1World.isAirBlock(par2, par3, par4 + 1)){

    par1World.setBlock(par2, par3, par4 + 1, TheGrid.MaelstromSource.blockID);

   

    }if(par1World.isAirBlock(par2 - 1, par3, par4)){

    par1World.setBlock(par2 - 1, par3, par4, TheGrid.MaelstromSource.blockID);

   

    }if(par1World.isAirBlock(par2, par3, par4 - 1)){

    par1World.setBlock(par2, par3, par4 - 1, TheGrid.MaelstromSource.blockID);

    }if(!par1World.isAirBlock(par2, par3 + 1, par4)){

    par1World.setBlock(par2, par3 + 1, par4, TheGrid.MaelstromSource.blockID);

    }

    }

   

    public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5) {

   

    par1World.setBlock(par2, par3, par4, TheGrid.MaelstromSource.blockID);

   

    }

}

 

  • Author

Thanks! That seemed to fix it, but now I have another question. Before it would turn into an air block when it came into contact with a specific fluid source, how would I do it, only for that fluid source?

I'd suggest override:

Block#onNeighborBlockUpdate(...)

check if neighbour is the fluid source, then set the block to air.

  • Author

And that worked! Thanks man, with the code I put in to that block it was indestructible even in creative and my entire test world was turning into it my world my explosions. xD

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.