mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
103 lines
3.7 KiB
Java
103 lines
3.7 KiB
Java
package com.hbm.main;
|
|
|
|
import com.hbm.entity.missile.EntityMissileBaseAdvanced;
|
|
import com.hbm.entity.projectile.EntityMeteor;
|
|
import com.hbm.lib.RefStrings;
|
|
|
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
|
import cpw.mods.fml.common.gameevent.TickEvent.WorldTickEvent;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.util.ChatComponentText;
|
|
import net.minecraftforge.event.entity.EntityEvent.EnteringChunk;
|
|
|
|
public class ModEventHandler
|
|
{
|
|
public static boolean showMessage = true;
|
|
public static int meteorShower = 0;
|
|
|
|
@SubscribeEvent
|
|
public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) {
|
|
if(showMessage)
|
|
{
|
|
event.player.addChatMessage(new ChatComponentText("Loaded world with Hbm's Nuclear Tech Mod " + RefStrings.VERSION + " for Minecraft 1.7.10!"));
|
|
}
|
|
|
|
showMessage = !showMessage;
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public void worldTick(WorldTickEvent event) {
|
|
if(event.world != null && !event.world.isRemote && event.world.provider.isSurfaceWorld() && MainRegistry.enableMeteorStrikes) {
|
|
if(event.world.rand.nextInt(meteorShower > 0 ? MainRegistry.meteorShowerChance : MainRegistry.meteorStrikeChance) == 0) {
|
|
if(!event.world.playerEntities.isEmpty()) {
|
|
EntityPlayer p = (EntityPlayer)event.world.playerEntities.get(event.world.rand.nextInt(event.world.playerEntities.size()));
|
|
|
|
if(p.dimension == 0) {
|
|
EntityMeteor meteor = new EntityMeteor(event.world);
|
|
meteor.posX = p.posX + event.world.rand.nextInt(201) - 100;
|
|
meteor.posY = 384;
|
|
meteor.posZ = p.posZ + event.world.rand.nextInt(201) - 100;
|
|
meteor.motionX = event.world.rand.nextDouble() - 0.5;
|
|
meteor.motionY = -2.5;
|
|
meteor.motionZ = event.world.rand.nextDouble() - 0.5;
|
|
event.world.spawnEntityInWorld(meteor);
|
|
}
|
|
}
|
|
}
|
|
|
|
if(meteorShower > 0) {
|
|
meteorShower--;
|
|
if(meteorShower == 0)
|
|
MainRegistry.logger.info("Ended meteor shower.");
|
|
}
|
|
|
|
if(event.world.rand.nextInt(MainRegistry.meteorStrikeChance * 100) == 0 && MainRegistry.enableMeteorShowers) {
|
|
meteorShower =
|
|
(int)(MainRegistry.meteorShowerDuration * 0.75 +
|
|
MainRegistry.meteorShowerDuration * 0.25 * event.world.rand.nextFloat());
|
|
MainRegistry.logger.info("Started meteor shower! Duration: " + meteorShower);
|
|
}
|
|
}
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public void enteringChunk(EnteringChunk evt)
|
|
{
|
|
if(evt.entity instanceof EntityMissileBaseAdvanced)
|
|
{
|
|
((EntityMissileBaseAdvanced)evt.entity).loadNeighboringChunks(evt.newChunkX, evt.newChunkZ);
|
|
}
|
|
}
|
|
|
|
/*@SubscribeEvent
|
|
public void itemSmelted(PlayerEvent.ItemSmeltedEvent e) {
|
|
if(e.smelting.getItem().equals(ModItems.ingot_titanium)) {
|
|
e.player.addStat(MainRegistry.achievementGetTitanium, 1);
|
|
}
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public void itemCrafted(PlayerEvent.ItemCraftedEvent e) {
|
|
|
|
Item item = e.crafting.getItem();
|
|
|
|
if(item.equals(Item.getItemFromBlock(ModBlocks.machine_difurnace_off))) {
|
|
e.player.addStat(MainRegistry.achievementCraftAlloyFurnace, 1);
|
|
}
|
|
if(item.equals(Item.getItemFromBlock(ModBlocks.machine_reactor))) {
|
|
e.player.addStat(MainRegistry.achievementCraftBreedingReactor, 1);
|
|
}
|
|
if(item.equals(Item.getItemFromBlock(ModBlocks.machine_centrifuge))) {
|
|
e.player.addStat(MainRegistry.achievementCraftCentrifuge, 1);
|
|
}
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public void itemCollected(PlayerEvent.ItemPickupEvent e) {
|
|
if(e.pickedUp.getEntityItem().equals(ModItems.nothing)) {
|
|
//e.player.addStat(MainRegistry.achievementGetAmblygonite, 1);
|
|
}
|
|
}*/
|
|
}
|