Jump to content

[1.8] [Solved] methods #onEntityWalking #onEntityCollideWithBlock


Glistre

Recommended Posts

Edit: I was registering BlockFluidClassic and not my custom Block class so never called my overrided methods!!!         

 

 

Having a bit of trouble getting potion effects to work onEntityCollideWithBlock ...I have tried both (World worldIn, BlockPos pos, Entity entityIn) as parameters and (World worldIn, BlockPos pos, IBlockState state, Entity entityIn)

 

 @Override   
    public void onEntityWalking(World worldIn, BlockPos pos,  Entity entity){

        super.onEntityWalking(worldIn, pos, entity);
        if ((!worldIn.isRemote && entity instanceof EntityPlayer ))
    	((EntityPlayer)entity).attackEntityFrom(DamageSource.wither, 100);
    	
    }  
   //tried using IBlockState needed for 1.8 since there are two possible overloads 

   @Override
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, Entity entityIn) {

	if (entityIn instanceof EntityLiving ) {

		((EntityLiving)entityIn).addPotionEffect(new PotionEffect(Potion.damageBoost.id, 200, 1, false, true));		//adds potion effect to mobs/ target --strength=damageboost
	}	
		else if (entityIn instanceof EntityPlayer){	

		((EntityPlayer)entityIn).addPotionEffect(new PotionEffect(Potion.confusion.id, 200, 0, false, true));		//adds potion effect to player/target--nausea=confusion
		System.out.print("Called");
		}
		else if ((entityIn instanceof EntityBlackTobo || entityIn instanceof EntityTobieKing || entityIn instanceof EntityTobieQueen)){

			((EntityBlackTobo) entityIn).addPotionEffect(new PotionEffect(Potion.heal.id, 2000, 7, false, true));
			((EntityTobieKing) entityIn).addPotionEffect(new PotionEffect(Potion.heal.id, 2000, 7, false, true));
			((EntityTobieQueen) entityIn).addPotionEffect(new PotionEffect(Potion.heal.id, 2000, 7, false, true));

		}
		  
}

  At any rate, not real sure what the four parameters of PotionEffect are, I think it is duration, level ..not sure on the two booleans.

 

Also @Overriding onEntityWalking is redlined by eclipse . . .it does not seem to work at all in 1.8 ...has that method changed in 1.8 from 1.7.10?

 

Edit:  Looks like #onEntityWalking is now #onEntityCollidedWithBlock with only the three parameters --ie, no IBlockState, and the former #onEntityCollidedWithBlock now has four parameters. 

Mine is still not working though.  Help appreciated

Link to comment
Share on other sites

Also @Overriding onEntityWalking is redlined by eclipse . . .it does not seem to work at all in 1.8 ...has that method changed in 1.8 from 1.7.10?

 

That means you aren't overriding a method (method signature doesn't match anything). You need to go look at the parent class to determine what the new signature is.

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

Also @Overriding onEntityWalking is redlined by eclipse . . .it does not seem to work at all in 1.8 ...has that method changed in 1.8 from 1.7.10?

 

That means you aren't overriding a method (method signature doesn't match anything). You need to go look at the parent class to determine what the new signature is.

 

I don't see that method #onEntityWalking in 1.8

 

Why is the #onEntityCollidedWithBlock is not working for me in 1.8?  in 1.7.10 instead of the BlockPos parameter, it was x, y, z but I did not change anything else?  Sry to bother you but I'm sure this is something pitifully simple I'm just f---ing missing it

Link to comment
Share on other sites

Also @Overriding onEntityWalking is redlined by eclipse . . .it does not seem to work at all in 1.8 ...has that method changed in 1.8 from 1.7.10?

 

That means you aren't overriding a method (method signature doesn't match anything). You need to go look at the parent class to determine what the new signature is.

 

I don't see that method #onEntityWalking in 1.8

 

Why is the #onEntityCollidedWithBlock is not working for me in 1.8?  in 1.7.10 instead of the BlockPos parameter, it was x, y, z but I did not change anything else?  Sry to bother you but I'm sure this is something pitifully simple I'm just f---ing missing it

Block#onEntityWalk(World worldIn, BlockPos pos, Entity entityIn)

and

Block#public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) (Which is only called when the entity is within the collision bounds).

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

Edited:

 

#onEntityWalk not coming up for me as a method...perhaps that's a 1.8.9 or later version not 1.8?

 

The other method Block#public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)is not working for me either maybe something wrong with my coding?

Link to comment
Share on other sites

bump

 

Help please ...just a couple more problems to fix with my 1.8 mod update then I can move on to a newer version ..what is wrong with my coding?  neither #onEntityCollideWithBlock with IBlockState parameter or without is working

 

I have no errors in Eclipse, and no crash.  The method is simply not being called.  My Block class extends BlockFluidClassic.

 

package com.glistre.glistremod.blocks;

import com.glistre.glistremod.entities.blacktobie.EntityBlackTobo;
import com.glistre.glistremod.entities.king.EntityTobieKing;
import com.glistre.glistremod.entities.queen.EntityTobieQueen;
import com.glistre.glistremod.init.ItemRegistry;
import com.glistre.glistremod.reference.Reference;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;

public class RudBlock extends BlockFluidClassic {

public RudBlock(Fluid fluid, Material material) {
	super(fluid, material);
	setCreativeTab(CreativeTabs.tabMisc);
}

    @Override
    public boolean canDisplace(IBlockAccess world, BlockPos pos) {
            if (world.getBlockState(pos).getBlock().getMaterial().isLiquid()) return false;
            return super.canDisplace(world, pos);
    }
    
    @Override
    public boolean displaceIfPossible(World world, BlockPos pos) {
            if (world.getBlockState(pos).getBlock().getMaterial().isLiquid()) return false;
            return super.displaceIfPossible(world, pos);
    }
   @Override 
    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
    {
        return true;
    }

/* @Override   
  //duration, level , badeffect or not
    public void onEntityWalk(World worldIn, BlockPos pos, Entity entity){

//    ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(ItemRegistry.poisonProtectPotion.id, 300, 0, false));
//adds damage effect from Rud
        
        if ((!worldIn.isRemote && entity instanceof EntityPlayer ))
    	((EntityPlayer)entity).attackEntityFrom(DamageSource.wither, 100);
    	
    }  */

   public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
   {
       float f = .01F;
       return new AxisAlignedBB((double)((float)pos.getX() + f), (double)pos.getY(), (double)((float)pos.getZ() + f), (double)((float)(pos.getX() + 1) - f), (double)((float)(pos.getY() + 1) - f), (double)((float)(pos.getZ() + 1) - f));
   }
//adds 0.01F to the block bounding box AKA makes box smaller?larger?
   @Override
   @SideOnly(Side.CLIENT)
   public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos)
   {
           float f = 0.01F;
           return new AxisAlignedBB((double)((float)pos.getX() + f), (double)pos.getY(), (double)((float)pos.getZ() + f), (double)((float)(pos.getX() + 1) - f), (double)(pos.getY() + 1), (double)((float)(pos.getZ() + 1) - f));
   }
   
   @Override 
   public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos){
   this.setBlockBounds(0.0F,  0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
   }
   
   @Override//no IBlockState aka stateless matches old onEntityWalking exactly like with slimes
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, Entity entityIn) {
  
//	   super.onEntityCollidedWithBlock(worldIn, pos, entityIn);
   //adds damage effect from Rud
       
       if ((!worldIn.isRemote && entityIn instanceof EntityPlayer ))
   	((EntityPlayer)entityIn).attackEntityFrom(DamageSource.wither, 100);
   	
   }	  

   //use IBlockState needed for 1.8 there are two overloads 
  //duration, level , badeffect , no swirls?
   @Override
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
   
//	   super.onEntityCollidedWithBlock(worldIn, pos, state, entityIn);

   if (!worldIn.isRemote && entityIn instanceof EntityPlayer ){	

	   ((EntityPlayer)entityIn).attackEntityFrom(DamageSource.wither, 1.0F);
		((EntityPlayer)entityIn).addPotionEffect(new PotionEffect(Potion.confusion.id, 300, 0, false, false));


		//adds potion effect to player/target--nausea=confusion
		System.out.print("Called confusion");
		return;
	}	
		else if (entityIn instanceof EntityLiving ) {		
			((EntityLiving)entityIn).addPotionEffect(new PotionEffect(Potion.damageBoost.id, 2000, 2, false, false));
			//adds potion effect to mobs/ target --strength=damageboost
			System.out.println("Called damageboost");
			return;
	}
		else if ((entityIn instanceof EntityBlackTobo || entityIn instanceof EntityTobieKing || entityIn instanceof EntityTobieQueen)){

			((EntityBlackTobo) entityIn).addPotionEffect(new PotionEffect(Potion.heal.id, 2000, 7, false, true));
			((EntityTobieKing) entityIn).addPotionEffect(new PotionEffect(Potion.heal.id, 2000, 7, false, true));
			((EntityTobieQueen) entityIn).addPotionEffect(new PotionEffect(Potion.heal.id, 2000, 7, false, true));
			System.out.println("Called mob healing");
		}
   return;
}
    
    @Override 
    public boolean isOpaqueCube(){

    	return true;
    }
    @Override 
    public boolean isFullCube(){

    	return false;
    }
    
}

Link to comment
Share on other sites

bump

 

Help please ...just a couple more problems to fix with my 1.8 mod update then I can move on to a newer version ..what is wrong with my coding?  neither #onEntityCollideWithBlock with IBlockState parameter or without is working

 

I have no errors in Eclipse, and no crash.  The method is simply not being called.  My Block class extends BlockFluidClassic.

 

package com.glistre.glistremod.blocks;

import com.glistre.glistremod.entities.blacktobie.EntityBlackTobo;
import com.glistre.glistremod.entities.king.EntityTobieKing;
import com.glistre.glistremod.entities.queen.EntityTobieQueen;
import com.glistre.glistremod.init.ItemRegistry;
import com.glistre.glistremod.reference.Reference;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;

public class RudBlock extends BlockFluidClassic {

public RudBlock(Fluid fluid, Material material) {
	super(fluid, material);
	setCreativeTab(CreativeTabs.tabMisc);
}

    @Override
    public boolean canDisplace(IBlockAccess world, BlockPos pos) {
            if (world.getBlockState(pos).getBlock().getMaterial().isLiquid()) return false;
            return super.canDisplace(world, pos);
    }
    
    @Override
    public boolean displaceIfPossible(World world, BlockPos pos) {
            if (world.getBlockState(pos).getBlock().getMaterial().isLiquid()) return false;
            return super.displaceIfPossible(world, pos);
    }
   @Override 
    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
    {
        return true;
    }

/* @Override   
  //duration, level , badeffect or not
    public void onEntityWalk(World worldIn, BlockPos pos, Entity entity){

//    ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(ItemRegistry.poisonProtectPotion.id, 300, 0, false));
//adds damage effect from Rud
        
        if ((!worldIn.isRemote && entity instanceof EntityPlayer ))
    	((EntityPlayer)entity).attackEntityFrom(DamageSource.wither, 100);
    	
    }  */

   public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
   {
       float f = .01F;
       return new AxisAlignedBB((double)((float)pos.getX() + f), (double)pos.getY(), (double)((float)pos.getZ() + f), (double)((float)(pos.getX() + 1) - f), (double)((float)(pos.getY() + 1) - f), (double)((float)(pos.getZ() + 1) - f));
   }
//adds 0.01F to the block bounding box AKA makes box smaller?larger?
   @Override
   @SideOnly(Side.CLIENT)
   public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos)
   {
           float f = 0.01F;
           return new AxisAlignedBB((double)((float)pos.getX() + f), (double)pos.getY(), (double)((float)pos.getZ() + f), (double)((float)(pos.getX() + 1) - f), (double)(pos.getY() + 1), (double)((float)(pos.getZ() + 1) - f));
   }
   
   @Override 
   public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos){
   this.setBlockBounds(0.0F,  0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
   }
   
   @Override//no IBlockState aka stateless matches old onEntityWalking exactly like with slimes
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, Entity entityIn) {
  
//	   super.onEntityCollidedWithBlock(worldIn, pos, entityIn);
   //adds damage effect from Rud
       
       if ((!worldIn.isRemote && entityIn instanceof EntityPlayer ))
   	((EntityPlayer)entityIn).attackEntityFrom(DamageSource.wither, 100);
   	
   }	  

   //use IBlockState needed for 1.8 there are two overloads 
  //duration, level , badeffect , no swirls?
   @Override
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
   
//	   super.onEntityCollidedWithBlock(worldIn, pos, state, entityIn);

   if (!worldIn.isRemote && entityIn instanceof EntityPlayer ){	

	   ((EntityPlayer)entityIn).attackEntityFrom(DamageSource.wither, 1.0F);
		((EntityPlayer)entityIn).addPotionEffect(new PotionEffect(Potion.confusion.id, 300, 0, false, false));


		//adds potion effect to player/target--nausea=confusion
		System.out.print("Called confusion");
		return;
	}	
		else if (entityIn instanceof EntityLiving ) {		
			((EntityLiving)entityIn).addPotionEffect(new PotionEffect(Potion.damageBoost.id, 2000, 2, false, false));
			//adds potion effect to mobs/ target --strength=damageboost
			System.out.println("Called damageboost");
			return;
	}
		else if ((entityIn instanceof EntityBlackTobo || entityIn instanceof EntityTobieKing || entityIn instanceof EntityTobieQueen)){

			((EntityBlackTobo) entityIn).addPotionEffect(new PotionEffect(Potion.heal.id, 2000, 7, false, true));
			((EntityTobieKing) entityIn).addPotionEffect(new PotionEffect(Potion.heal.id, 2000, 7, false, true));
			((EntityTobieQueen) entityIn).addPotionEffect(new PotionEffect(Potion.heal.id, 2000, 7, false, true));
			System.out.println("Called mob healing");
		}
   return;
}
    
    @Override 
    public boolean isOpaqueCube(){

    	return true;
    }
    @Override 
    public boolean isFullCube(){

    	return false;
    }
    
}

It may have something to do with canCollideCheck(...)

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

Not exactly sure how to use that method, I added the following to my RudBlock code and nothing changed.

 

@Override
public boolean canCollideCheck(IBlockState state, boolean hitIfLiquid){

	//return hitIfLiquid && ((Integer)state.getValue(LEVEL)).intValue() == 1;
//	return false;
	return this.isCollidable();
}

  @Override
  	@SideOnly(Side.CLIENT)
      public boolean isCollidable()
      {
      	return true;
      }

Link to comment
Share on other sites

  • 2 years later...
  • Guest locked this topic
Guest
This topic is now closed to further replies.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Turning the Tables: My Journey to Reclaim Stolen Bitcoins with Expert Help. When my Bitcoin wallet was hacked and my entire cryptocurrency portfolio was stolen, I felt utterly devastated and hopeless. Having worked hard to build up my digital assets, the sudden loss was gut-wrenching. It felt like my financial future had been ripped away in an instant, leaving me overwhelmed by a sense of betrayal and despair. In my search for help, I discovered TECH CYBER FORCE Recovery, a renowned cybersecurity firm specializing in cryptocurrency recovery. I was met with professionalism and empathy from my first contact with them. The team demonstrated a steadfast commitment to helping me retrieve my stolen Bitcoins. They understood the emotional toll of my situation and approached my case with genuine concern. TECH CYBER FORCE Recovery swung into action immediately, leveraging its extensive expertise in blockchain forensics and hacker tracking techniques. Their process was meticulous. They analyzed my transaction history, followed the digital trail left by the hackers, and worked diligently to pinpoint the location of the stolen funds. I was impressed by their technical prowess; they employed advanced cryptographic methods and strategic negotiations with the perpetrators, all while keeping me informed about their progress. The recovery process was complex and fraught with challenges. However, the tenacity displayed by the team was truly awe-inspiring. They navigated cryptocurrency crime's murky and ever-evolving landscape with skill and determination. After a series of strategic moves, they managed to recover the majority of my Bitcoins successfully.  
    • I removed giacomos_hud, oculus, (dont know what you mean with iris), enhanced_boss_bars, epicfight and essential.  Server still doesnt want to boot. new logs after removing: https://pastebin.com/LuM2PFtN I dont quite understand the "server side" and "client side" difference..
    • There are client side only mods in your server files   Remove giacomos_hud, oculus, iris, enhanced_boss_bars and epicfight You can keep these mods in your client Maybe also remove essentials
    • Here is my Log with java 17: https://pastebin.com/RPdWSjwq
    • Been working on creating a server for this mod, but i keep getting this error over and over again.  I have tried updating/changing the Forge launcher, Removing/replacing the ops.json and whitelist.json folders, and removing certain mods. Crash report log: https://pastebin.com/Bu046cVq Debug.log https://pastebin.com/7hKm40ke Latest.log https://pastebin.com/nCRLUH3b any help would be great thanks!
  • Topics

×
×
  • Create New...

Important Information

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