Skip to content

Commit

Permalink
Consolidate all packages into single module, fixed configuration and …
Browse files Browse the repository at this point in the history
…added config interface
  • Loading branch information
aidancbrady committed Apr 25, 2016
1 parent 048349b commit b74a8cc
Show file tree
Hide file tree
Showing 57 changed files with 1,303 additions and 1,339 deletions.
6 changes: 3 additions & 3 deletions etc/mcmod.info
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"modid": "DefenseTech",
"name": "DefenseTech",
"description": "DefenseTech is a Minecraft add-on featuring high-tech weaponry and defense technologies, including missiles, devastating explosives, and other nifty gadgets. The mod serves as a continuation of Calclavia's classic mod 'ICBM.'",
"version": "1.0",
"mcversion": "1.7.10",
"version": "${version}",
"mcversion": "${mc_version}",
"authors": [
"aidancbrady"
],
"credits": "",
"logoFile": "/defense_banner.png",
"screenshots": [],
"dependencies": ["DefenseTech"]
"dependencies": ["Mekanism"]
}
]
6 changes: 1 addition & 5 deletions src/main/java/defense/Reference.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ public class Reference
/** Name of the channel and mod ID. */
public static final String NAME = "DefenseTech";

public static final String MAJOR_VERSION = "@MAJOR@";
public static final String MINOR_VERSION = "@MINOR@";
public static final String REVISION_VERSION = "@REVIS@";
public static final String BUILD_VERSION = "@BUILD@";
public static final String VERSION = MAJOR_VERSION + "." + MINOR_VERSION + "." + REVISION_VERSION;
public static final String VERSION = "1.0.0";

public static final String CHANNEL = "DEF";
public static final String ENTITY_PREFIX = CHANNEL;
Expand Down
35 changes: 19 additions & 16 deletions src/main/java/defense/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,31 @@ public class Settings
public static int MAX_MISSILE_DISTANCE = 10000;
public static int ANTIMATTER_SIZE = 55;
public static boolean DESTROY_BEDROCK = true;
public static int MAX_ROCKET_LAUCNHER_TIER = 2;
public static int MAX_ROCKET_LAUNCHER_TIER = 2;
public static boolean GENERATE_SULFUR = true;
public static int MAX_REDMATTER_LIFESPAN = 3600;
public static boolean DO_REDMATTER_DESPAWN = true;
public static boolean CREEPER_DROP_SULFER = true;
public static boolean CREEPER_DROP_SULFUR = true;
public static boolean CREEPER_BLOW_UP_IN_FIRE = true;
public static boolean POLLUTIVE_NUCLEAR = true;
public static boolean CREATE_NETHERRACK = true;
public static double REDUCE_OBSIDIAN_RESISTANCE = 45F;

@Deprecated
public static void initiate()
{
CONFIGURATION.load();
USE_FUEL = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Use Fuel", Settings.USE_FUEL).getBoolean(Settings.USE_FUEL);
LOAD_CHUNKS = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Allow Chunk Loading", LOAD_CHUNKS).getBoolean(LOAD_CHUNKS);
MAX_MISSILE_DISTANCE = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Max Missile Distance", Settings.MAX_MISSILE_DISTANCE).getInt(Settings.MAX_MISSILE_DISTANCE);
ANTIMATTER_SIZE = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Antimatter Explosion Size", ANTIMATTER_SIZE).getInt(ANTIMATTER_SIZE);
DESTROY_BEDROCK = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Antimatter Destroy Bedrock", DESTROY_BEDROCK).getBoolean(DESTROY_BEDROCK);
MAX_ROCKET_LAUCNHER_TIER = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Limits the max missile tier for rocket launcher item", MAX_ROCKET_LAUCNHER_TIER).getInt(MAX_ROCKET_LAUCNHER_TIER);
GENERATE_SULFUR = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Generate Sulfur Ore", GENERATE_SULFUR).getBoolean(GENERATE_SULFUR);
MAX_REDMATTER_LIFESPAN = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "RedMatter Life Span in ticks", MAX_REDMATTER_LIFESPAN).getInt(MAX_REDMATTER_LIFESPAN);
DO_REDMATTER_DESPAWN = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "RedMatter despawn", DO_REDMATTER_DESPAWN).getBoolean(DO_REDMATTER_DESPAWN);
CREEPER_DROP_SULFER = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Creepers Drop Sulfur", CREEPER_DROP_SULFER).getBoolean(CREEPER_DROP_SULFER);
CREEPER_BLOW_UP_IN_FIRE = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Creepers Blow up in Fire", CREEPER_BLOW_UP_IN_FIRE).getBoolean(CREEPER_BLOW_UP_IN_FIRE);
CONFIGURATION.save();
USE_FUEL = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Use Fuel", true).getBoolean(true);
LOAD_CHUNKS = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Allow Chunk Loading", true).getBoolean(true);
MAX_MISSILE_DISTANCE = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Max Missile Distance", 10000).getInt(10000);
ANTIMATTER_SIZE = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Antimatter Explosion Size", 55).getInt(55);
DESTROY_BEDROCK = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Antimatter Destroy Bedrock", true).getBoolean(true);
MAX_ROCKET_LAUNCHER_TIER = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Limits the max missile tier for rocket launcher item", 2).getInt(2);
GENERATE_SULFUR = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Generate Sulfur Ore", true).getBoolean(true);
MAX_REDMATTER_LIFESPAN = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "RedMatter Life Span in ticks", 3600).getInt(3600);
DO_REDMATTER_DESPAWN = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "RedMatter despawn", true).getBoolean(true);
CREEPER_DROP_SULFUR = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Creepers Drop Sulfur", true).getBoolean(true);
CREEPER_BLOW_UP_IN_FIRE = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Creepers Blow up in Fire", true).getBoolean(true);
POLLUTIVE_NUCLEAR = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Pollutive Nuclear", true).getBoolean(true);
CREATE_NETHERRACK = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Exothermic Create Netherrack", true).getBoolean(true);
REDUCE_OBSIDIAN_RESISTANCE = Settings.CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Reduce Obsidian Resistance", 45F).getDouble(45F);
}
}
263 changes: 262 additions & 1 deletion src/main/java/defense/core/ClientProxy.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
package defense.core;

import java.util.List;

import mekanism.api.Pos3D;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.particle.EntityDiggingFX;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.entity.RenderMinecart;
import net.minecraft.client.renderer.entity.RendererLivingEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.client.event.RenderLivingEvent.Specials.Pre;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.ReflectionHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import defense.api.IItemFrequency;
Expand All @@ -13,22 +35,93 @@
import defense.core.entity.RenderEntityBlock;
import defense.core.entity.RenderShrapnel;
import defense.core.gui.GuiFrequency;
import defense.explosion.entities.EntityBombCart;
import defense.explosion.entities.EntityExplosion;
import defense.explosion.entities.EntityExplosive;
import defense.explosion.entities.EntityGrenade;
import defense.explosion.entities.EntityLightBeam;
import defense.explosion.entities.EntityMissile;
import defense.explosion.ex.missiles.MissileMovingSound;
import defense.explosion.explosive.TileExplosive;
import defense.explosion.fx.FXAntimatterPartical;
import defense.explosion.fx.FXElectricBolt;
import defense.explosion.fx.FXElectricBoltSpawner;
import defense.explosion.fx.FXEnderPortalPartical;
import defense.explosion.fx.FXShockWave;
import defense.explosion.fx.FXSmoke;
import defense.explosion.gui.GuiCruiseLauncher;
import defense.explosion.gui.GuiEMPTower;
import defense.explosion.gui.GuiLauncherScreen;
import defense.explosion.gui.GuiMissileCoordinator;
import defense.explosion.gui.GuiRadarStation;
import defense.explosion.machines.TileCruiseLauncher;
import defense.explosion.machines.TileEMPTower;
import defense.explosion.machines.TileMissileCoordinator;
import defense.explosion.machines.TileRadarStation;
import defense.explosion.machines.launcher.TileLauncherBase;
import defense.explosion.machines.launcher.TileLauncherFrame;
import defense.explosion.machines.launcher.TileLauncherScreen;
import defense.explosion.potion.PoisonFrostBite;
import defense.explosion.render.entity.RenderEntityExplosive;
import defense.explosion.render.entity.RenderExplosion;
import defense.explosion.render.entity.RenderGrenade;
import defense.explosion.render.entity.RenderLightBeam;
import defense.explosion.render.entity.RenderMissile;
import defense.explosion.render.item.RenderItemMachine;
import defense.explosion.render.item.RenderItemMissile;
import defense.explosion.render.item.RenderRocketLauncher;
import defense.explosion.render.tile.BlockRenderHandler;
import defense.explosion.render.tile.RenderBombBlock;
import defense.explosion.render.tile.RenderCruiseLauncher;
import defense.explosion.render.tile.RenderEmpTower;
import defense.explosion.render.tile.RenderLauncherBase;
import defense.explosion.render.tile.RenderLauncherFrame;
import defense.explosion.render.tile.RenderLauncherScreen;
import defense.explosion.render.tile.RenderMissileCoordinator;
import defense.explosion.render.tile.RenderRadarStation;

@SideOnly(Side.CLIENT)
public class ClientProxy extends CommonProxy
{
private boolean disableReflectionFX = false;

@Override
public void preInit()
{
super.preInit();

FMLCommonHandler.instance().bus().register(new TickHandler());
}

@Override
public void init()
{
super.init();

MinecraftForgeClient.registerItemRenderer(DefenseTechItems.itemRocketLauncher, new RenderRocketLauncher());
MinecraftForgeClient.registerItemRenderer(DefenseTechItems.itemMissile, new RenderItemMissile());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(DefenseTechBlocks.blockMachine), new RenderItemMachine());

RenderingRegistry.registerEntityRenderingHandler(EntityFlyingBlock.class, new RenderEntityBlock());
RenderingRegistry.registerEntityRenderingHandler(EntityFragments.class, new RenderShrapnel());
RenderingRegistry.registerEntityRenderingHandler(EntityExplosive.class, new RenderEntityExplosive());
RenderingRegistry.registerEntityRenderingHandler(EntityMissile.class, new RenderMissile(0.5F));
RenderingRegistry.registerEntityRenderingHandler(EntityExplosion.class, new RenderExplosion());
RenderingRegistry.registerEntityRenderingHandler(EntityLightBeam.class, new RenderLightBeam());
RenderingRegistry.registerEntityRenderingHandler(EntityGrenade.class, new RenderGrenade());
RenderingRegistry.registerEntityRenderingHandler(EntityBombCart.class, new RenderMinecart());

RenderingRegistry.registerBlockHandler(new RenderBombBlock());
RenderingRegistry.registerBlockHandler(new BlockRenderHandler());

ClientRegistry.bindTileEntitySpecialRenderer(TileCruiseLauncher.class, new RenderCruiseLauncher());
ClientRegistry.bindTileEntitySpecialRenderer(TileLauncherBase.class, new RenderLauncherBase());
ClientRegistry.bindTileEntitySpecialRenderer(TileLauncherScreen.class, new RenderLauncherScreen());
ClientRegistry.bindTileEntitySpecialRenderer(TileLauncherFrame.class, new RenderLauncherFrame());
ClientRegistry.bindTileEntitySpecialRenderer(TileRadarStation.class, new RenderRadarStation());
ClientRegistry.bindTileEntitySpecialRenderer(TileEMPTower.class, new RenderEmpTower());
ClientRegistry.bindTileEntitySpecialRenderer(TileMissileCoordinator.class, new RenderMissileCoordinator());
ClientRegistry.bindTileEntitySpecialRenderer(TileExplosive.class, new RenderBombBlock());
}

@Override
Expand All @@ -40,7 +133,175 @@ public Object getClientGuiElement(int ID, EntityPlayer entityPlayer, World world
{
return new GuiFrequency(entityPlayer, entityPlayer.inventory.getCurrentItem());
}
else if (tileEntity instanceof TileCruiseLauncher)
{
return new GuiCruiseLauncher(entityPlayer.inventory, (TileCruiseLauncher) tileEntity);
}
else if (tileEntity instanceof TileLauncherScreen)
{
return new GuiLauncherScreen(((TileLauncherScreen) tileEntity));
}
else if (tileEntity instanceof TileRadarStation)
{
return new GuiRadarStation(((TileRadarStation) tileEntity));
}
else if (tileEntity instanceof TileEMPTower)
{
return new GuiEMPTower((TileEMPTower) tileEntity);
}
else if (tileEntity instanceof TileMissileCoordinator)
{
return new GuiMissileCoordinator(entityPlayer.inventory, (TileMissileCoordinator) tileEntity);
}

return null;
}

@Override
public boolean isFancyGraphicsEnabled()
{
return Minecraft.getMinecraft().gameSettings.fancyGraphics;
}

@Override
public int getParticleSetting()
{
return Minecraft.getMinecraft().gameSettings.particleSetting;
}

@Override
public void spawnParticle(String name, World world, Pos3D position, double motionX, double motionY, double motionZ, float red, float green, float blue, float scale, double distance)
{
EntityFX fx = null;

if (name.equals("smoke"))
{
fx = new FXSmoke(world, position, red, green, blue, scale, distance);
}
else if (name.equals("missile_smoke"))
{
fx = (new FXSmoke(world, position, red, green, blue, scale, distance)).setAge(100);
}
else if (name.equals("portal"))
{
fx = new FXEnderPortalPartical(world, position, red, green, blue, scale, distance);
}
else if (name.equals("antimatter"))
{
fx = new FXAntimatterPartical(world, position, red, green, blue, scale, distance);
}
else if (name.equals("digging"))
{
fx = new EntityDiggingFX(world, position.xPos, position.yPos, position.zPos, motionX, motionY, motionZ, Block.getBlockById((int)red), 0, (int) green);
fx.multipleParticleScaleBy(blue);
}
else if (name.equals("shockwave"))
{
fx = new FXShockWave(world, position, red, green, blue, scale, distance);
}

if (fx != null)
{
fx.motionX = motionX;
fx.motionY = motionY;
fx.motionZ = motionZ;
FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx);
}
}

@Override
public void spawnShock(World world, Pos3D startVec, Pos3D targetVec)
{
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new FXElectricBolt(world, startVec, targetVec, 0));
}

@Override
public void spawnShock(World world, Pos3D startVec, Pos3D targetVec, int duration)
{
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new FXElectricBoltSpawner(world, startVec, targetVec, 0, duration));
}

@Override
public void playSound(EntityMissile missile)
{
FMLClientHandler.instance().getClient().getSoundHandler().playSound(new MissileMovingSound(missile));
}

@Override
public List<Entity> getEntityFXs()
{
if (!this.disableReflectionFX)
{
try
{
EffectRenderer renderer = Minecraft.getMinecraft().effectRenderer;
List[] fxLayers = (List[]) ReflectionHelper.getPrivateValue(EffectRenderer.class, renderer, 2);

return fxLayers[0];
}
catch (Exception e)
{
DefenseTech.LOGGER.severe("Failed to use relfection on entity effects.");
e.printStackTrace();
this.disableReflectionFX = true;
}
}
return null;
}

// TODO: Work on this!
// @ForgeSubscribe
public void renderingLivingEvent(Pre evt)
{
if (evt.entity instanceof EntityLivingBase)
{
if (evt.entity.getActivePotionEffect(PoisonFrostBite.INSTANCE) != null)
{
try
{
ModelBase modelBase = (ModelBase) ReflectionHelper.getPrivateValue(RendererLivingEntity.class, evt.renderer, 2);

if (modelBase != null)
{
if (evt.entity.isInvisible())
{
GL11.glDepthMask(false);
}
else
{
GL11.glDepthMask(true);
}

float f1 = evt.entity.ticksExisted;
// this.bindTexture(evt.renderer.func_110829_a);
RenderUtils.setTerrainTexture();
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glLoadIdentity();
float f2 = f1 * 0.01F;
float f3 = f1 * 0.01F;
GL11.glTranslatef(f2, f3, 0.0F);
GL11.glScalef(2, 2, 2);
evt.renderer.setRenderPassModel(modelBase);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glEnable(GL11.GL_BLEND);
float f4 = 0.5F;
GL11.glColor4f(f4, f4, f4, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
modelBase.render(evt.entity, (float) evt.entity.posX, (float) evt.entity.posY, (float) evt.entity.posZ, evt.entity.rotationPitch, evt.entity.rotationYaw, 0.0625F);
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glLoadIdentity();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_BLEND);
}
}
catch (Exception e)
{
DefenseTech.LOGGER.severe("Failed to render entity layer object");
e.printStackTrace();
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package defense.explosion;
package defense.core;

import java.util.List;

Expand Down
Loading

0 comments on commit b74a8cc

Please sign in to comment.