diff --git a/src/main/java/trinity/blocks/AntimatterBomb.java b/src/main/java/trinity/blocks/AntimatterBomb.java index f6f69ab..7a89874 100644 --- a/src/main/java/trinity/blocks/AntimatterBomb.java +++ b/src/main/java/trinity/blocks/AntimatterBomb.java @@ -15,7 +15,6 @@ import trinity.config.TrinityConfig; import trinity.entities.EntityFalloutRain; import trinity.entities.EntityNuclearCloud; import trinity.entities.EntityNuclearExplosion; -import trinity.entities.EntityShockwave; import trinity.entities.EntityThermonuclearBlast; import trinity.explosion.ExplosionNukeGeneric; import trinity.init.ModBlocks; diff --git a/src/main/java/trinity/blocks/ExoticBomb.java b/src/main/java/trinity/blocks/ExoticBomb.java index 8526338..f82fe9a 100644 --- a/src/main/java/trinity/blocks/ExoticBomb.java +++ b/src/main/java/trinity/blocks/ExoticBomb.java @@ -20,7 +20,6 @@ import trinity.entities.EntityBlackHole; import trinity.entities.EntityFalloutRain; import trinity.entities.EntityNuclearCloud; import trinity.entities.EntityNuclearExplosion; -import trinity.entities.EntityShockwave; import trinity.entities.EntityThermonuclearBlast; import trinity.explosion.ExplosionNukeGeneric; import trinity.init.ModBlocks; diff --git a/src/main/java/trinity/blocks/NuclearCore.java b/src/main/java/trinity/blocks/NuclearCore.java index e51ebda..90256ef 100644 --- a/src/main/java/trinity/blocks/NuclearCore.java +++ b/src/main/java/trinity/blocks/NuclearCore.java @@ -17,7 +17,6 @@ import trinity.entities.EntityFalloutRain; import trinity.entities.EntityBlackHole; import trinity.entities.EntityNuclearCloud; import trinity.entities.EntityNuclearExplosion; -import trinity.entities.EntityShockwave; import trinity.entities.EntityThermonuclearBlast; import trinity.explosion.ExplosionNukeGeneric; import trinity.init.ModBlocks; diff --git a/src/main/java/trinity/explosion/ExplosionNukeGeneric.java b/src/main/java/trinity/explosion/ExplosionNukeGeneric.java index 1eabd72..b9b0231 100644 --- a/src/main/java/trinity/explosion/ExplosionNukeGeneric.java +++ b/src/main/java/trinity/explosion/ExplosionNukeGeneric.java @@ -31,7 +31,6 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import trinity.handler.Vec3; import trinity.init.ModDamageSources; -import trinity.init.ModEvents; //import net.minecraft.world.WorldSettings.GameType; //import net.minecraftforge.common.util.ForgeDirection; diff --git a/src/main/java/trinity/explosion/ExplosionThermonuclear.java b/src/main/java/trinity/explosion/ExplosionThermonuclear.java index ef37ede..363fc7c 100644 --- a/src/main/java/trinity/explosion/ExplosionThermonuclear.java +++ b/src/main/java/trinity/explosion/ExplosionThermonuclear.java @@ -33,7 +33,6 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import trinity.handler.Vec3; import trinity.init.ModDamageSources; -import trinity.init.ModEvents; public class ExplosionThermonuclear { diff --git a/src/main/java/trinity/init/ClientEvents.java b/src/main/java/trinity/init/ClientEvents.java new file mode 100644 index 0000000..ee1b62f --- /dev/null +++ b/src/main/java/trinity/init/ClientEvents.java @@ -0,0 +1,23 @@ +package trinity.init; + +import net.minecraftforge.fml.common.Mod; +import trinity.Global; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import trinity.util.Reference; + +@Mod.EventBusSubscriber(modid= Reference.MODID) +public class ClientEvents { + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void textureStitch(TextureStitchEvent.Pre evt) { + evt.getMap().registerSprite(new ResourceLocation(Global.MOD_ID, "blocks/liquid_still")); + evt.getMap().registerSprite(new ResourceLocation(Global.MOD_ID, "blocks/liquid_flow")); + } +} + + + diff --git a/src/main/java/trinity/init/CommonEvents.java b/src/main/java/trinity/init/CommonEvents.java new file mode 100644 index 0000000..4b305d5 --- /dev/null +++ b/src/main/java/trinity/init/CommonEvents.java @@ -0,0 +1,133 @@ +package trinity.init; + + +import java.util.List; + +import net.minecraftforge.fml.common.Mod; + +import nc.capability.radiation.entity.IEntityRads; +import nc.config.NCConfig; +import nc.network.PacketHandler; +import nc.network.radiation.PlayerRadsUpdatePacket; +import nc.radiation.RadSources; +import nc.radiation.RadiationHelper; +import net.minecraftforge.fml.relauncher.SideOnly; +import trinity.items.RadioactiveSource2; +import trinity.items.ShieldedContainerItem; +import trinity.radiation.FalloutSavedData; +import trinity.tiles.TileEntityShieldedContainer; +import trinity.util.Reference; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import net.minecraftforge.fml.relauncher.Side; + +@Mod.EventBusSubscriber(modid=Reference.MODID) +public class CommonEvents { + + public static String Pu_238 = "c95fdfd3-bea7-4255-a44b-d21bc3df95e3"; + + @SubscribeEvent(priority=EventPriority.LOW) + @SideOnly(Side.SERVER) + public void sealedRadiationSources(TickEvent.PlayerTickEvent event) { + if (!NCConfig.radiation_enabled_public) { return; } + + if (event.phase != TickEvent.Phase.START || + ((event.player.world.getTotalWorldTime() + event.player.getUniqueID().hashCode()) % + NCConfig.radiation_player_tick_rate) != 0) { return; } + + if (event.player instanceof EntityPlayerMP) { + EntityPlayerMP player = (EntityPlayerMP)event.player; + + IEntityRads playerRads = RadiationHelper.getEntityRadiation(player); + + if (player.getUniqueID().toString().equals(Pu_238) ) + { + if(playerRads.getInternalRadiationResistance()<500) + { + playerRads.setInternalRadiationResistance(2800); + } + } + + double radiationLevel = 0D; + FalloutSavedData data = FalloutSavedData.getData(event.player.world); + if(data.worldObj == null) { + data.worldObj = event.player.world; + } + + radiationLevel += data.getRadNumFromCoord((int)player.posX, (int)player.posZ); + List Tes = player.world.loadedTileEntityList; + for (int i = 0; i < Tes.size(); ++i) + { + TileEntity tile = (TileEntity) Tes.get(i); + int tileDim = tile.getWorld().provider.getDimension(); + int playerDim = player.getEntityWorld().provider.getDimension(); + if(tile instanceof TileEntityShieldedContainer && (tileDim == playerDim)) + { + TileEntityShieldedContainer te = ((TileEntityShieldedContainer)tile); + double X = player.posX; + double Y = player.posY; + double Z = player.posZ; + double dist = te.getDistanceSq(X, Y, Z); + radiationLevel += Math.min(te.getRadiation(), (te.getRadiation()/dist)); + //System.out.println("Radioactivity: "+te.getRadioactivity()+" Rad/t"); + } + } + if (!player.getUniqueID().toString().equals(Pu_238)) + { + List entities = player.world.playerEntities; + for (int i = 0; i < entities.size(); ++i) + { + EntityPlayer p = (EntityPlayer) entities.get(i); + if (p.getUniqueID().toString().equals(Pu_238) ) + { + double X = player.posX; + double Y = player.posY; + double Z = player.posZ; + double dist = p.getDistanceSq(X, Y, Z); + radiationLevel += Math.min(RadSources.PLUTONIUM_238, (RadSources.PLUTONIUM_238/dist)); + } + } + } + + InventoryPlayer inventory = player.inventory; + for (ItemStack stack : inventory.mainInventory) { + if (!stack.isEmpty()) { + Item item = stack.getItem(); + /*if(Trinity.QMDLoaded) + { + if(item instanceof RadioactiveSource) + { + radiationLevel += (((RadioactiveSource)item).rads)*stack.getCount(); + //System.out.println("Radioactivity: "+radiationLevel); + } + }*/ + if(item instanceof RadioactiveSource2) + { + radiationLevel += (((RadioactiveSource2)item).rads)*stack.getCount(); + //System.out.println("Radioactivity: "+radiationLevel); + } + + if(item instanceof ShieldedContainerItem) + { + radiationLevel += (((ShieldedContainerItem)item).getRadiation(stack))*stack.getCount(); + } + } + } + double appliedRads = RadiationHelper.addRadsToEntity(playerRads, player, radiationLevel, false, false, NCConfig.radiation_player_tick_rate); + playerRads.setRadiationLevel(playerRads.getRadiationLevel() + appliedRads); + //System.out.println("Radiation: "+playerRads.getRadiationLevel()+" Rad/t"); + //System.out.println("Adjusted Radiation: "+playerRads.getRadiationLevel()/3+" Rad/t"); + PacketHandler.instance.sendTo(new PlayerRadsUpdatePacket(playerRads), player); + } + } +} + + + diff --git a/src/main/java/trinity/init/ICBMEvents.java b/src/main/java/trinity/init/ICBMEvents.java new file mode 100644 index 0000000..75d290d --- /dev/null +++ b/src/main/java/trinity/init/ICBMEvents.java @@ -0,0 +1,110 @@ +package trinity.init; + + +import java.util.List; + +import icbm.classic.api.EnumTier; +import icbm.classic.api.ExplosiveRefs; +import icbm.classic.content.blast.BlastEMP; +import icbm.classic.content.blast.threaded.BlastAntimatter; +import icbm.classic.content.blast.threaded.BlastNuclear; +import icbm.classic.content.blocks.explosive.ItemBlockExplosive; +import icbm.classic.content.items.ItemMissile; +import trinity.Trinity; +import trinity.config.TrinityConfig; +import trinity.entities.EntityNuclearCloud; +import trinity.entities.EntityNuclearExplosion; +import trinity.explosion.ExplosionNukeGeneric; +import trinity.util.Reference; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.Vec3d; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.Explosion; +import net.minecraft.world.World; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import net.minecraftforge.event.world.ExplosionEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + + +@Mod.EventBusSubscriber(modid=Reference.MODID) +public class ICBMEvents { + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void addAdditionalTooltips(ItemTooltipEvent event) { + if(Trinity.ICBMLoaded) + { + ItemStack stack = event.getItemStack(); + Item item = stack.getItem(); + if(item instanceof ItemBlockExplosive || item instanceof ItemMissile) + { + if(stack.getItemDamage() == ExplosiveRefs.NUCLEAR.getRegistryID()) + { + addNukeTooltip(event.getToolTip(), stack); + } + } + } + + } + + @SideOnly(Side.CLIENT) + private static void addNukeTooltip(List tooltip, ItemStack stack) { + tooltip.add(TextFormatting.RED+"Warning: Trinity installed. ICBM nuclear explosives cause Trinity's explosions instead of ICBM's"); + } + + @SubscribeEvent + // @SideOnly(Side.SERVER) + public void explosion(ExplosionEvent.Start event) + { + World world = event.getWorld(); + Explosion exp = event.getExplosion(); + Vec3d position = exp.getPosition(); + + if(exp instanceof BlastNuclear) + { + if(((BlastNuclear)exp).getExplosiveData().getTier()==EnumTier.THREE) + { + event.setCanceled(true); + EntityNuclearCloud entity2 = new EntityNuclearCloud(world, 1000, (Math.min(TrinityConfig.icbm_radius,TrinityConfig.max_radius)*2) * 0.005F); + entity2.posX = position.x; + entity2.posY = position.y; + entity2.posZ = position.z; + world.spawnEntity(entity2); + // world.setBlockToAir(pos); + new BlastEMP().setBlastWorld(event.getWorld()).setBlastSource(exp.getExplosivePlacedBy()).setBlastPosition(((BlastNuclear) exp).location.x(), ((BlastNuclear) exp).location.y(), ((BlastNuclear) exp).location.z()) + .setBlastSize(((BlastNuclear) exp).getBlastRadius()*2) + .setExplosiveData(ExplosiveRefs.EMP) + .buildBlast().runBlast(); + ExplosionNukeGeneric.irradiate(world, (int)position.x, (int)position.y, (int)position.z, Math.min(TrinityConfig.icbm_radius,TrinityConfig.max_radius)*2); + world.spawnEntity(EntityNuclearExplosion.statFac(world, Math.min(TrinityConfig.icbm_radius,TrinityConfig.max_radius), position.x, position.y, position.z)); + //System.out.println("If you are seeing this line, this means your blast detector is at least partially working."); + } + } + else if(exp instanceof BlastAntimatter) + { + if(((BlastNuclear)exp).getExplosiveData().getTier()==EnumTier.THREE) + { + event.setCanceled(true); + EntityNuclearCloud entity2 = new EntityNuclearCloud(world, 1000, (Math.min(TrinityConfig.antimatter_radius,TrinityConfig.max_radius)*2) * 0.005F); + entity2.posX = position.x; + entity2.posY = position.y; + entity2.posZ = position.z; + world.spawnEntity(entity2); + // exp.world.setBlockToAir(pos); + ExplosionNukeGeneric.irradiate(world, (int)position.x, (int)position.y, (int)position.z, Math.min(TrinityConfig.antimatter_radius,TrinityConfig.max_radius)*6); + world.spawnEntity(EntityNuclearExplosion.statFacAntimatter(world, Math.min(TrinityConfig.antimatter_radius,TrinityConfig.max_radius), position.x, position.y, position.z)); + new BlastEMP().setBlastWorld(event.getWorld()).setBlastSource(exp.getExplosivePlacedBy()).setBlastPosition(((BlastNuclear) exp).location.x(), ((BlastNuclear) exp).location.y(), ((BlastNuclear) exp).location.z()) + .setBlastSize(((BlastNuclear) exp).getBlastRadius()*2) + .setExplosiveData(ExplosiveRefs.EMP) + .buildBlast().runBlast(); + //System.out.println("If you are seeing this line, this means your blast detector is at least partially working."); + } + } + } +} + + + diff --git a/src/main/java/trinity/proxy/ClientProxy.java b/src/main/java/trinity/proxy/ClientProxy.java index 08038f3..38272ac 100644 --- a/src/main/java/trinity/proxy/ClientProxy.java +++ b/src/main/java/trinity/proxy/ClientProxy.java @@ -2,10 +2,7 @@ package trinity.proxy; import java.util.List; -import nc.handler.TooltipHandler; -import nc.render.BlockHighlightHandler; import trinity.Global; -import trinity.Trinity; import trinity.config.TrinityConfig; import trinity.entities.EntityBlackHole; import trinity.entities.EntityDirtyBomb; @@ -15,12 +12,11 @@ import trinity.entities.EntityThermalBlast; import trinity.fluid.TrinityFluids; import trinity.handler.INuclearEffect; import trinity.init.ModBlocks; -import trinity.init.ModEvents; import trinity.init.ModItems; +import trinity.init.ClientEvents; import trinity.render.AdvancedModelLoader; import trinity.render.HmfModelLoader; import trinity.render.entity.RenderBlackHole; -import trinity.render.entity.RenderFallout; import trinity.render.entity.RenderFalloutRainFactory; import trinity.render.entity.RenderNuclearExplosion; import trinity.render.entity.RenderPrimedDirtyBomb; @@ -40,7 +36,6 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.IRenderFactory; import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.common.event.FMLInitializationEvent; @@ -48,7 +43,6 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.network.NetworkRegistry; public class ClientProxy extends CommonProxy { @@ -57,14 +51,13 @@ private final Minecraft mc = Minecraft.getMinecraft(); @Override public void preInit(FMLPreInitializationEvent preEvent) { super.preInit(preEvent); - + TrinityConfig.clientPreInit(); - + ModItems.registerRenders(); ModBlocks.registerRenders(); - MinecraftForge.EVENT_BUS.register(new ModEvents()); - //MinecraftForge.EVENT_BUS.register(new ICBMEvents()); - TrinityFluids.renderFluids(); + MinecraftForge.EVENT_BUS.register(new ClientEvents()); + TrinityFluids.renderFluids(); } @Override diff --git a/src/main/java/trinity/proxy/CommonProxy.java b/src/main/java/trinity/proxy/CommonProxy.java index e34935e..91a6561 100644 --- a/src/main/java/trinity/proxy/CommonProxy.java +++ b/src/main/java/trinity/proxy/CommonProxy.java @@ -1,42 +1,22 @@ package trinity.proxy; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; import java.util.Locale; -import com.google.common.collect.Ordering; - -import nc.radiation.RadSources; -import nc.recipe.NCRecipes; -import nc.recipe.ingredient.OreIngredient; import trinity.Trinity; +import trinity.init.*; import trinity.fluid.TrinityFluids; import trinity.gui.GuiHandlerRegistry; import trinity.gui.GuiHandlerTrinity; -//import trinity.fluid.TrinityFluids; import trinity.handler.OredictHandler; -import trinity.init.ModBlocks; -import trinity.init.ModItems; -import trinity.init.TrinityEntities; -import trinity.init.TrinityRecipes; import trinity.radiation.RadiationHandler; import trinity.tiles.TileEntityShieldedContainer; import trinity.world.TrinityBiomes; import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLModIdMappingEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.network.IGuiHandler; -import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.registry.GameRegistry; public class CommonProxy { @@ -46,11 +26,14 @@ public class CommonProxy { TrinityFluids.registerFluids(); TrinityFluids.init(); TrinityFluids.register(); - ModBlocks.init(); + ModBlocks.init(); ModItems.register(); ModBlocks.register(); OredictHandler.registerOres(); MinecraftForge.EVENT_BUS.register(new TrinityRecipes()); + MinecraftForge.EVENT_BUS.register(new CommonEvents()); + if(Trinity.ICBMLoaded) + MinecraftForge.EVENT_BUS.register(new ICBMEvents()); GuiHandlerRegistry.getInstance().registerGuiHandler(new GuiHandlerTrinity(), GuiHandlerTrinity.getGuiID()); GameRegistry.registerTileEntity(TileEntityShieldedContainer.class, "trinity:tile_inventory_basic"); //TrinityRecipes.init();