Nuke.
This commit is contained in:
parent
3a99ebcf02
commit
05ee9f30f4
7 changed files with 254 additions and 10 deletions
|
@ -2,6 +2,7 @@ package techreborn;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraftforge.fml.common.registry.EntityRegistry;
|
||||
import org.apache.commons.lang3.time.StopWatch;
|
||||
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
|
@ -32,6 +33,7 @@ import techreborn.compat.CompatManager;
|
|||
import techreborn.compat.ICompatModule;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.dispenser.BehaviorDispenseScrapbox;
|
||||
import techreborn.entitys.EntityNukePrimed;
|
||||
import techreborn.events.OreUnifier;
|
||||
import techreborn.events.TRTickHandler;
|
||||
import techreborn.init.*;
|
||||
|
@ -83,6 +85,9 @@ public class Core {
|
|||
for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules) {
|
||||
compatModule.preInit(event);
|
||||
}
|
||||
//Entitys
|
||||
EntityRegistry.registerModEntity(EntityNukePrimed.class, "nuke", 0, INSTANCE, 160, 5, true);
|
||||
proxy.preInit(event);
|
||||
|
||||
RecipeConfigManager.load(event.getModConfigurationDirectory());
|
||||
versionChecker = new VersionChecker("TechReborn", new ModInfo());
|
||||
|
@ -114,7 +119,7 @@ public class Core {
|
|||
logHelper.all(watch + " : main recipes");
|
||||
watch.stop();
|
||||
// Client only init, needs to be done before parts system
|
||||
proxy.init();
|
||||
proxy.init(event);
|
||||
// WorldGen
|
||||
worldGen.load();
|
||||
GameRegistry.registerWorldGenerator(worldGen, 0);
|
||||
|
@ -128,11 +133,13 @@ public class Core {
|
|||
MinecraftForge.EVENT_BUS.register(new MultiblockEventHandler());
|
||||
// IDSU manager
|
||||
IDSUManager.INSTANCE = new IDSUManager();
|
||||
//Event busses
|
||||
MinecraftForge.EVENT_BUS.register(IDSUManager.INSTANCE);
|
||||
MinecraftForge.EVENT_BUS.register(new MultiblockServerTickHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new TRTickHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new OreUnifier());
|
||||
MinecraftForge.EVENT_BUS.register(worldGen.retroGen);
|
||||
//Scrapbox
|
||||
if (config.scrapboxDispenser) {
|
||||
BlockDispenser.dispenseBehaviorRegistry.putObject(ModItems.scrapBox, new BehaviorDispenseScrapbox());
|
||||
}
|
||||
|
@ -145,6 +152,7 @@ public class Core {
|
|||
for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules) {
|
||||
compatModule.postInit(event);
|
||||
}
|
||||
proxy.postInit(event);
|
||||
logHelper.info(RecipeHandler.recipeList.size() + " recipes loaded");
|
||||
|
||||
// RecipeHandler.scanForDupeRecipes();
|
||||
|
|
61
src/main/java/techreborn/blocks/BlockNuke.java
Normal file
61
src/main/java/techreborn/blocks/BlockNuke.java
Normal file
|
@ -0,0 +1,61 @@
|
|||
package techreborn.blocks;
|
||||
|
||||
import me.modmuss50.jsonDestroyer.api.ITexturedBlock;
|
||||
import net.minecraft.block.BlockTNT;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.RebornCore;
|
||||
import techreborn.client.TechRebornCreativeTabMisc;
|
||||
import techreborn.entitys.EntityNukePrimed;
|
||||
|
||||
/**
|
||||
* Created by Mark on 13/03/2016.
|
||||
*/
|
||||
public class BlockNuke extends BlockTNT implements ITexturedBlock {
|
||||
|
||||
public BlockNuke() {
|
||||
setUnlocalizedName("techreborn.nuke");
|
||||
setCreativeTab(TechRebornCreativeTabMisc.instance);
|
||||
RebornCore.jsonDestroyer.registerObject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explode(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase igniter) {
|
||||
if (!worldIn.isRemote) {
|
||||
if (state.getValue(EXPLODE).booleanValue()) {
|
||||
EntityNukePrimed entitynukeprimed = new EntityNukePrimed(worldIn, (double) ((float) pos.getX() + 0.5F), (double) pos.getY(), (double) ((float) pos.getZ() + 0.5F), igniter);
|
||||
worldIn.spawnEntityInWorld(entitynukeprimed);
|
||||
worldIn.playSoundAtEntity(entitynukeprimed, "game.tnt.primed", 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockDestroyedByExplosion(World worldIn, BlockPos pos, Explosion explosionIn) {
|
||||
if (!worldIn.isRemote) {
|
||||
EntityNukePrimed entitynukeprimed = new EntityNukePrimed(worldIn, (double) ((float) pos.getX() + 0.5F), (double) pos.getY(), (double) ((float) pos.getZ() + 0.5F), explosionIn.getExplosivePlacedBy());
|
||||
entitynukeprimed.fuse = worldIn.rand.nextInt(entitynukeprimed.fuse / 4) + entitynukeprimed.fuse / 8;
|
||||
worldIn.spawnEntityInWorld(entitynukeprimed);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
return false; //No flint and steel
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureNameFromState(IBlockState iBlockState, EnumFacing enumFacing) {
|
||||
return "techreborn:blocks/machine/machine_bottom";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int amountOfStates() {
|
||||
return 1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package techreborn.client.render.entitys;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import techreborn.entitys.EntityNukePrimed;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
/**
|
||||
* Created by Mark on 13/03/2016.
|
||||
*/
|
||||
public class RenderNukePrimed extends Render<EntityNukePrimed> {
|
||||
|
||||
public RenderNukePrimed(RenderManager renderManager) {
|
||||
super(renderManager);
|
||||
this.shadowSize = 0.5F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRender(EntityNukePrimed entity, double x, double y, double z, float entityYaw, float partialTicks) {
|
||||
BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate((float) x, (float) y + 0.5F, (float) z);
|
||||
if ((float) entity.fuse - partialTicks + 1.0F < 10.0F) {
|
||||
float f = 1.0F - ((float) entity.fuse - partialTicks + 1.0F) / 10.0F;
|
||||
f = MathHelper.clamp_float(f, 0.0F, 1.0F);
|
||||
f = f * f;
|
||||
f = f * f;
|
||||
float f1 = 1.0F + f * 0.3F;
|
||||
GlStateManager.scale(f1, f1, f1);
|
||||
}
|
||||
float f2 = (1.0F - ((float) entity.fuse - partialTicks + 1.0F) / 100.0F) * 0.8F;
|
||||
this.bindEntityTexture(entity);
|
||||
GlStateManager.translate(-0.5F, -0.5F, 0.5F);
|
||||
blockrendererdispatcher.renderBlockBrightness(ModBlocks.nuke.getDefaultState(), entity.getBrightness(partialTicks));
|
||||
GlStateManager.translate(0.0F, 0.0F, 1.0F);
|
||||
if (entity.fuse / 5 % 2 == 0) {
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(770, 772);
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, f2);
|
||||
GlStateManager.doPolygonOffset(-3.0F, -3.0F);
|
||||
GlStateManager.enablePolygonOffset();
|
||||
blockrendererdispatcher.renderBlockBrightness(Blocks.tnt.getDefaultState(), 1.0F);
|
||||
GlStateManager.doPolygonOffset(0.0F, 0.0F);
|
||||
GlStateManager.disablePolygonOffset();
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.enableTexture2D();
|
||||
}
|
||||
GlStateManager.popMatrix();
|
||||
super.doRender(entity, x, y, z, entityYaw, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(EntityNukePrimed entity) {
|
||||
return TextureMap.locationBlocksTexture;
|
||||
}
|
||||
}
|
60
src/main/java/techreborn/entitys/EntityNukePrimed.java
Normal file
60
src/main/java/techreborn/entitys/EntityNukePrimed.java
Normal file
|
@ -0,0 +1,60 @@
|
|||
package techreborn.entitys;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityTNTPrimed;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.explosion.RebornExplosion;
|
||||
|
||||
/**
|
||||
* Created by Mark on 13/03/2016.
|
||||
*/
|
||||
public class EntityNukePrimed extends EntityTNTPrimed {
|
||||
|
||||
int nukeFuseTime = 400;
|
||||
|
||||
public EntityNukePrimed(World world) {
|
||||
super(world);
|
||||
this.fuse = nukeFuseTime;
|
||||
}
|
||||
|
||||
public EntityNukePrimed(World world, double x, double y, double z, EntityLivingBase tntPlacedBy) {
|
||||
super(world, x, y, z, tntPlacedBy);
|
||||
this.fuse = nukeFuseTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
|
||||
this.prevPosX = this.posX;
|
||||
this.prevPosY = this.posY;
|
||||
this.prevPosZ = this.posZ;
|
||||
this.motionY -= 0.03999999910593033D;
|
||||
this.moveEntity(this.motionX, this.motionY, this.motionZ);
|
||||
this.motionX *= 0.9800000190734863D;
|
||||
this.motionY *= 0.9800000190734863D;
|
||||
this.motionZ *= 0.9800000190734863D;
|
||||
if (this.onGround) {
|
||||
this.motionX *= 0.699999988079071D;
|
||||
this.motionZ *= 0.699999988079071D;
|
||||
this.motionY *= -0.5D;
|
||||
}
|
||||
if (this.fuse-- <= 0) {
|
||||
this.setDead();
|
||||
if (!this.worldObj.isRemote) {
|
||||
this.explodeNuke();
|
||||
}
|
||||
} else {
|
||||
this.handleWaterMovement();
|
||||
this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public void explodeNuke() {
|
||||
RebornExplosion nukeExplosion = new RebornExplosion(new BlockPos(this.posX, this.posY, this.posZ), worldObj, 40);
|
||||
nukeExplosion.explode();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -131,6 +131,7 @@ public class ModBlocks {
|
|||
public static Block machineframe;
|
||||
public static Block reinforcedglass;
|
||||
public static Block ironFurnace;
|
||||
public static Block nuke;
|
||||
|
||||
public static Block rubberLog;
|
||||
public static Block rubberLeaves;
|
||||
|
@ -368,6 +369,10 @@ public class ModBlocks {
|
|||
ironFurnace = new BlockIronFurnace();
|
||||
GameRegistry.registerBlock(ironFurnace, "ironfurnace");
|
||||
GameRegistry.registerTileEntity(TileIronFurnace.class, "TileIronFurnaceTR");
|
||||
|
||||
nuke = new BlockNuke();
|
||||
GameRegistry.registerBlock(nuke, "nuke");
|
||||
|
||||
registerOreDict();
|
||||
Core.logHelper.info("TechReborns Blocks Loaded");
|
||||
}
|
||||
|
|
|
@ -1,23 +1,34 @@
|
|||
package techreborn.proxies;
|
||||
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
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;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import reborncore.client.multiblock.MultiblockRenderEvent;
|
||||
import techreborn.client.ClientMultiBlocks;
|
||||
import techreborn.client.IconSupplier;
|
||||
import techreborn.client.RegisterItemJsons;
|
||||
import techreborn.client.StackToolTipEvent;
|
||||
import techreborn.client.VersionCheckerClient;
|
||||
import techreborn.client.*;
|
||||
import techreborn.client.hud.ChargeHud;
|
||||
import techreborn.client.keybindings.KeyBindings;
|
||||
import techreborn.client.render.entitys.RenderNukePrimed;
|
||||
import techreborn.entitys.EntityNukePrimed;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
|
||||
public static MultiblockRenderEvent multiblockRenderEvent;
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
super.preInit(event);
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityNukePrimed.class, new RenderManagerNuke());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLInitializationEvent event) {
|
||||
super.init(event);
|
||||
RegisterItemJsons.registerModels();
|
||||
MinecraftForge.EVENT_BUS.register(new IconSupplier());
|
||||
MinecraftForge.EVENT_BUS.register(new ChargeHud());
|
||||
|
@ -29,4 +40,13 @@ public class ClientProxy extends CommonProxy {
|
|||
ClientRegistry.registerKeyBinding(KeyBindings.config);
|
||||
ClientMultiBlocks.init();
|
||||
}
|
||||
|
||||
public class RenderManagerNuke implements IRenderFactory<EntityNukePrimed>{
|
||||
|
||||
@Override
|
||||
public Render<? super EntityNukePrimed> createRenderFor(RenderManager manager) {
|
||||
return new RenderNukePrimed(manager);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,31 @@
|
|||
package techreborn.proxies;
|
||||
|
||||
public class CommonProxy {
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
import techreborn.compat.ICompatModule;
|
||||
|
||||
public void init() {
|
||||
public class CommonProxy implements ICompatModule{
|
||||
|
||||
|
||||
@Override
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLInitializationEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverStarting(FMLServerStartingEvent event) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue