use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project VoodooCraft by Mod-DevCafeTeam.
the class HexHandler method setLightSource.
/**
* TODO: Update position of light source relative to player's position
* TODO: and replace old position of light source with air
* @param event
*/
@SubscribeEvent
public static void setLightSource(TickEvent.PlayerTickEvent event) {
if (event.player.world.isRemote)
return;
EntityPlayer player = event.player;
ItemStack stack = getDollWithHex(player, "fear_the_darkness");
if (stack != null) {
World world = player.world;
BlockPos oldPos = new BlockPos(player.prevPosX, player.prevPosY, player.prevPosZ);
if (player.motionX != 0F || player.motionZ != 0F) {
BlockPos newPos = player.getPosition();
if (world.getTotalWorldTime() % 15 == 0) {
VoodooCraft.log.info("OldPos: " + oldPos + ", NewPos: " + newPos);
}
if (oldPos != newPos) {
world.setBlockState(oldPos, Blocks.AIR.getDefaultState());
world.setBlockState(newPos, VCBlocks.LIGHT_SOURCE.getDefaultState());
VoodooCraft.log.info("Changing light source locationg...");
}
} else {
world.setBlockState(player.getPosition(), VCBlocks.LIGHT_SOURCE.getDefaultState());
}
}
}
use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project VoodooCraft by Mod-DevCafeTeam.
the class HexHandler method fallEvent.
/**
* Feather Hex
*/
@SubscribeEvent
public static void fallEvent(LivingFallEvent event) {
//Feather - Removes fall damage
ItemStack stack = getDollWithHex(event.getEntityLiving(), "feather");
if (stack != null) {
event.setDistance(0);
event.setDamageMultiplier(0);
//Damage the doll
stack.damageItem(1, event.getEntityLiving());
}
}
use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project ConvenientAdditions by Necr0.
the class BlockEnderProof method onEnderTeleport.
@SubscribeEvent
public void onEnderTeleport(EnderTeleportEvent e) {
Entity ent = e.getEntity();
List<BlockPos> l = rayTraceBlocks(ent.world, new Vec3d(ent.posX, ent.posY, ent.posZ), new Vec3d(e.getTargetX(), e.getTargetY(), e.getTargetZ()), false, new FloodFill.BlockMatcher(3).set(BlockEnderProof.class));
if (l.size() > 0) {
e.setCanceled(true);
}
}
use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project ConvenientAdditions by Necr0.
the class CAGbookBookRegistry method onFirstSpawn.
@Optional.Method(modid = "gbook")
@SubscribeEvent
public static void onFirstSpawn(EntityJoinWorldEvent event) {
if (!ModConfigCompat.gbook_onFirstSpawn)
return;
if (!event.getWorld().isRemote && event.getEntity() instanceof EntityPlayer) {
EntityPlayer p = (EntityPlayer) event.getEntity();
NBTTagCompound tag = Helper.getPersistentTag(p, ModConstants.Mod.MODID);
if (!tag.getBoolean(TAG_BOOK_RECEIVED)) {
Helper.insertOrDrop(p, GameRegistry.makeItemStack("gbook:guidebook", 0, 1, "{Book:\"convenientadditions:xml/book.xml\"}"));
tag.setBoolean(TAG_BOOK_RECEIVED, true);
}
}
}
use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project NetherEx by LogicTechCorp.
the class EventHandler method onLivingUpdate.
@SubscribeEvent
public static void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
World world = event.getEntityLiving().getEntityWorld();
BlockPos pos = new BlockPos(event.getEntityLiving());
EntityLivingBase entity = event.getEntityLiving();
boolean canFreeze = !(entity instanceof EntityPlayer) && !Arrays.asList(ConfigHandler.potionEffect.freeze.blacklist).contains(EntityList.getKey(entity).toString());
if (world.getBiomeForCoordsBody(pos) == NetherExBiomes.ARCTIC_ABYSS) {
if (canFreeze && !entity.isPotionActive(NetherExEffects.FREEZE) && world.rand.nextInt(ConfigHandler.biome.arcticAbyss.chanceOfFreezing) == 0) {
entity.addPotionEffect(new PotionEffect(NetherExEffects.FREEZE, 300, 0));
}
}
if (entity instanceof EntityLiving && canFreeze) {
if (!entity.isPotionActive(NetherExEffects.FREEZE)) {
if (((EntityLiving) entity).isAIDisabled()) {
((EntityLiving) entity).setNoAI(false);
entity.setSilent(false);
}
} else {
((EntityLiving) entity).setNoAI(true);
entity.setSilent(true);
if (world.rand.nextInt(ConfigHandler.potionEffect.freeze.chanceOfThawing) == 0) {
entity.removePotionEffect(NetherExEffects.FREEZE);
}
}
}
if (entity instanceof EntityPlayer && entity.isPotionActive(NetherExEffects.FREEZE)) {
entity.setPosition(entity.prevPosX, entity.posY, entity.prevPosZ);
}
boolean canSpawnSpore = entity instanceof EntityPlayer || !Arrays.asList(ConfigHandler.potionEffect.spore.blacklist).contains(EntityList.getKey(entity).toString());
if (canSpawnSpore && entity.isPotionActive(NetherExEffects.SPORE) && world.rand.nextInt(ConfigHandler.potionEffect.spore.chanceOfSporeSpawning) == 0) {
if (world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(pos).expand(1, 1, 1)).size() < 3) {
BlockPos newPos = pos.offset(EnumFacing.Plane.HORIZONTAL.random(world.rand));
if (!world.isRemote && world.isAirBlock(newPos) && world.getBlockState(newPos.down()).isSideSolid(world, newPos.down(), EnumFacing.UP)) {
EntitySpore spore = new EntitySpore(world, 0);
spore.setPosition(newPos.getX(), newPos.getY(), newPos.getZ());
world.spawnEntity(spore);
}
}
}
boolean canSpawnGhastling = entity instanceof EntityPlayer && world.provider.getDimension() == DimensionType.NETHER.getId();
if (canSpawnGhastling && entity.isPotionActive(NetherExEffects.LOST) && world.rand.nextInt(ConfigHandler.potionEffect.lost.chanceOfGhastlingSpawning) == 0) {
BlockPos newPos = pos.add(0, 5, 0).offset(entity.getHorizontalFacing().getOpposite(), 5);
if (!world.isRemote && world.isAirBlock(newPos)) {
EntityGhastling ghastling = new EntityGhastling(world);
ghastling.setPosition(newPos.getX(), newPos.getY(), newPos.getZ());
ghastling.setAttackTarget(entity);
world.spawnEntity(ghastling);
}
}
}
Aggregations