use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project MorePlanets by SteveKunG.
the class EntityEventHandler method onLivingDeath.
@SubscribeEvent
public void onLivingDeath(LivingDeathEvent event) {
EntityLivingBase living = event.getEntityLiving();
int id = GCCoreUtil.getDimensionID(living.world);
PacketSimpleMP.sendToAllAround(new PacketSimpleMP(EnumSimplePacketMP.C_REMOVE_ENTITY_ID, id, String.valueOf(living.getEntityId())), living.world, id, living.getPosition(), 64);
}
use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project MorePlanets by SteveKunG.
the class EntityEventHandler method onLivingUpdate.
@SubscribeEvent
public void onLivingUpdate(LivingUpdateEvent event) {
EntityLivingBase living = event.getEntityLiving();
World world = living.world;
if (living.isDead) {
int id = GCCoreUtil.getDimensionID(living.world);
PacketSimpleMP.sendToAllAround(new PacketSimpleMP(EnumSimplePacketMP.C_REMOVE_ENTITY_ID, id, String.valueOf(living.getEntityId())), living.world, id, living.getPosition(), 64);
}
if (living instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) living;
if (ConfigManagerMP.enableStartedPlanet && !WorldTickEventHandler.startedDimensionData.startedDimension && !(ConfigManagerMP.startedPlanet.equals("planet.") || ConfigManagerMP.startedPlanet.equals("moon.") || ConfigManagerMP.startedPlanet.equals("satellite."))) {
MPLog.debug("Start teleporting player to dimension {}", ConfigManagerMP.startedPlanet);
TeleportUtil.startNewDimension(player);
WorldTickEventHandler.startedDimensionData.startedDimension = true;
WorldTickEventHandler.startedDimensionData.planetToBack = ConfigManagerMP.startedPlanet;
WorldTickEventHandler.startedDimensionData.setDirty(true);
}
if (player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION) || this.isInOxygen(world, player)) {
player.removePotionEffect(MPPotions.INFECTED_SPORE);
}
if (player.isPotionActive(MPPotions.DARK_ENERGY_PROTECTION)) {
player.removePotionEffect(MPPotions.DARK_ENERGY);
}
if (world.provider instanceof WorldProviderNibiru) {
if (world.isRainingAt(player.getPosition()) && !this.isGodPlayer(player) && !player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION) && world.getBiome(player.getPosition()) != MPBiomes.GREEN_VEIN) {
player.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 40));
}
if (player.ticksExisted % 128 == 0 && !this.isGodPlayer(player) && !this.isInOxygen(world, player) && !player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION) && world.getBiome(player.getPosition()) != MPBiomes.GREEN_VEIN) {
player.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 80));
}
}
if (world.provider instanceof IMeteorType) {
// this.spawnMeteor(world, player, (IMeteorType)world.provider);
}
}
if (world.provider instanceof WorldProviderNibiru) {
if (!(living instanceof EntityPlayer) && !EntityEffectHelper.isGalacticraftMob(living) && !(living instanceof EntityJuicer)) {
if (living.ticksExisted % 128 == 0 && world.getBiome(living.getPosition()) != MPBiomes.GREEN_VEIN) {
living.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 80));
}
if (world.isRainingAt(living.getPosition()) && world.getBiome(living.getPosition()) != MPBiomes.GREEN_VEIN) {
living.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 40));
}
}
}
}
use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project MorePlanets by SteveKunG.
the class GeneralEventHandler method onPickupItem.
@SubscribeEvent
public void onPickupItem(ItemPickupEvent event) {
ItemStack itemStack = event.getOriginalEntity().getItem();
Item item = itemStack.getItem();
Block block = Block.getBlockFromItem(item);
if (block == ChalosBlocks.CHEESE_SPORE_STEM || block == NibiruBlocks.NIBIRU_LOG) {
// event.player.addStat(AchievementList.MINE_WOOD);
}
}
use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project MorePlanets by SteveKunG.
the class GeneralEventHandler method onBlockBreak.
@SubscribeEvent
public void onBlockBreak(BreakEvent event) {
IBlockState sourceState = event.getState();
Block source = sourceState.getBlock();
EntityPlayer player = event.getPlayer();
if (source == NibiruBlocks.INFECTED_FARMLAND && event.getWorld().getBiomeForCoordsBody(event.getPos()) == MPBiomes.GREEN_VEIN) {
return;
}
for (BreakBlockData data : GeneralEventHandler.NON_INFECTED_BLOCK_LIST) {
Block block = data.getBlock();
int meta = data.getMeta();
if (meta != -1) {
if (source == block && source.getMetaFromState(sourceState) == meta) {
return;
}
} else {
if (source == block) {
return;
}
}
}
for (BreakBlockData data : GeneralEventHandler.NON_INFECTED_BLOCK_LIST) {
Block block = data.getBlock();
int meta = data.getMeta();
boolean flag = false;
if (meta != -1) {
if (source == block && source.getMetaFromState(sourceState) == meta) {
flag = true;
}
} else {
if (source == block) {
flag = true;
}
}
if (flag && !player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION) && !player.capabilities.isCreativeMode) {
player.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 60));
}
}
if (source.getRegistryName().toString().contains("moreplanets")) {
if (source.getUnlocalizedName().contains("infected") || source.getUnlocalizedName().contains("nibiru") || source.getLocalizedName().contains("infected")) {
if (!player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION) && !player.capabilities.isCreativeMode) {
player.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 60));
}
}
}
if (this.isShears(player)) {
if (source == FronosBlocks.CANDY_CANE_1 || source == FronosBlocks.CANDY_CANE_2) {
player.getActiveItemStack().damageItem(1, player);
}
}
}
use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project MorePlanets by SteveKunG.
the class GeneralEventHandler method onRightClickBlock.
@SubscribeEvent
public void onRightClickBlock(PlayerInteractEvent.RightClickBlock event) {
EntityPlayer player = event.getEntityPlayer();
World world = event.getWorld();
BlockPos pos = event.getPos();
ItemStack heldItem = event.getItemStack();
if (!heldItem.isEmpty() && (heldItem.getItem() instanceof ItemSpade || heldItem.getItem().getToolClasses(heldItem) == Collections.singleton("shovel"))) {
if (event.getFace() != EnumFacing.DOWN && world.getBlockState(pos.up()).getMaterial() == Material.AIR) {
if (world.getBlockState(pos).getBlock() == NibiruBlocks.INFECTED_GRASS) {
if (!world.isRemote) {
world.playSound(null, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.setBlockState(pos, NibiruBlocks.NIBIRU_GRASS_PATH.getDefaultState(), 11);
heldItem.damageItem(1, player);
}
player.swingArm(event.getHand());
} else if (world.getBlockState(pos).getBlock() == NibiruBlocks.GREEN_VEIN_GRASS) {
if (!world.isRemote) {
world.playSound(null, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.setBlockState(pos, NibiruBlocks.NIBIRU_GRASS_PATH.getStateFromMeta(1), 11);
heldItem.damageItem(1, player);
}
player.swingArm(event.getHand());
}
}
}
}
Aggregations