Hmm, actually, I have another question, sorry- I changed my script so that it attempts to damage the player by 10% of their current health when they're standing on sand, but it doesn't seem to be doing anything:
package missing.abyssalcore.common.blocks;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSand;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.BlockEvent.BreakEvent;
import net.minecraftforge.event.entity.player.*;
import net.minecraft.util.MathHelper;
public class Evilsand {
//thanks to jabelar for code
public Block findBlockUnderEntity(Entity parEntity)
{
int blockX = MathHelper.floor_double(parEntity.posX);
int blockY = MathHelper.floor_double(parEntity.boundingBox.minY)-1;
int blockZ = MathHelper.floor_double(parEntity.posZ);
return parEntity.worldObj.getBlock(blockX, blockY, blockZ);
}
@SubscribeEvent
public void Evil(PlayerTickEvent event) {
if (event.player instanceof EntityPlayer) {
//assign player to player entity
EntityPlayer player = (EntityPlayer) event.player;
Block newblock = findBlockUnderEntity(player);
if (newblock == Blocks.sand) {
float health = (float) (player.getHealth() * 0.9);
player.setHealth(health);
System.out.println("Oof");
}
}
}
}
Any ideas why? Should I have defined the findBlockUnderEntity method elsewhere, or is my problem someplace else?