Jump to content

Uhoh

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by Uhoh

  1. Yeah, I did, and it worked before I added the changes to the Evilsand class. For reference: package missing.abyssalcore.common; import net.minecraft.init.Blocks; import net.minecraftforge.common.MinecraftForge; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLInitializationEvent; import missing.abyssalcore.common.blocks.Evilsand; @Mod(modid = Abyssalcore.MODID, version = Abyssalcore.VERSION) public class Abyssalcore { public static final String MODID = "Abyssalcore"; public static final String VERSION = "1.1"; @EventHandler public void preInit(FMLPreInitializationEvent event) { //preinit } @EventHandler public void init(FMLInitializationEvent event){ //register evilsand MinecraftForge.EVENT_BUS.register(new Evilsand()); } public void postInit(FMLPostInitializationEvent event) { //postinit } }
  2. 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?
  3. Yep, that would do it. Thank you!
  4. Oh, I see. Actually testing the mod, I have another question: it seems that PlayerInteractEvent does not, like I hoped, encompass the event of the player standing on a block. If that's the case, then what does? I'm looking through Vic's list of Forge events and I don't see anything that seems to address player/entity block collision.
  5. So I have a test file called Evilsand that just does this: package missing.abyssalcore.common.blocks; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.block.BlockSand; import net.minecraft.block.material.Material; 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.ChatComponentText; public class Evilsand { @SubscribeEvent public void Evil(PlayerInteractEvent event) { System.out.println("Test"); System.out.println(event); } @SubscribeEvent public void aaa(BreakEvent event) { if (event.block == Blocks.sand) { System.out.println("Breaktest"); System.out.println(event); } } } When I compile my mod, nothing happens on these events. I'm assuming that it's just because it's not being called/ initialized in my main mod file: package missing.abyssalcore.common; import net.minecraft.init.Blocks; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLInitializationEvent; import missing.abyssalcore.common.blocks.Evilsand; @Mod(modid = Abyssalcore.MODID, version = Abyssalcore.VERSION) public class Abyssalcore { public static final String MODID = "Abyssalcore"; public static final String VERSION = "1.1"; @EventHandler public void preInit(FMLPreInitializationEvent event) { //preinit } @EventHandler public void init(FMLInitializationEvent event){ // some example code //System.out.println("DIRT BLOCK >> "+Blocks.dirt.getUnlocalizedName()); } public void postInit(FMLPostInitializationEvent event) { //postinit } } So my question is this: exactly in what part of the initialization process do I load in classes like this? It's a little more obvious more stuff like blocks and items and whatnot, but I'm not sure where/how to initialize my Evilsand class in the process.
×
×
  • Create New...

Important Information

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