Use static fuse in static way.
This commit is contained in:
parent
67226de701
commit
8cac9a9315
4 changed files with 37 additions and 31 deletions
|
@ -33,8 +33,10 @@ import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.projectile.EntityArrow;
|
import net.minecraft.entity.projectile.EntityArrow;
|
||||||
|
import net.minecraft.init.SoundEvents;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
|
import net.minecraft.util.SoundCategory;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.Explosion;
|
import net.minecraft.world.Explosion;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -59,13 +61,13 @@ public class BlockNuke extends BaseBlock {
|
||||||
RebornModelRegistry.registerModel(new ModelCompound(ModInfo.MOD_ID, this));
|
RebornModelRegistry.registerModel(new ModelCompound(ModInfo.MOD_ID, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void explode(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase igniter) {
|
public void ignite(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase igniter) {
|
||||||
if (!worldIn.isRemote) {
|
if (!worldIn.isRemote) {
|
||||||
EntityNukePrimed entitynukeprimed = new EntityNukePrimed(worldIn, (double) ((float) pos.getX() + 0.5F),
|
EntityNukePrimed entitynukeprimed = new EntityNukePrimed(worldIn, (double) ((float) pos.getX() + 0.5F),
|
||||||
(double) pos.getY(), (double) ((float) pos.getZ() + 0.5F), igniter);
|
(double) pos.getY(), (double) ((float) pos.getZ() + 0.5F), igniter);
|
||||||
worldIn.spawnEntity(entitynukeprimed);
|
worldIn.spawnEntity(entitynukeprimed);
|
||||||
// worldIn.playSoundAtEntity(entitynukeprimed, "game.tnt.primed",
|
worldIn.playSound((EntityPlayer) null, entitynukeprimed.posX, entitynukeprimed.posY, entitynukeprimed.posZ,
|
||||||
// 1.0F, 1.0F);
|
SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +76,7 @@ public class BlockNuke extends BaseBlock {
|
||||||
if (!worldIn.isRemote) {
|
if (!worldIn.isRemote) {
|
||||||
EntityNukePrimed entitynukeprimed = new EntityNukePrimed(worldIn, (double) ((float) pos.getX() + 0.5F),
|
EntityNukePrimed entitynukeprimed = new EntityNukePrimed(worldIn, (double) ((float) pos.getX() + 0.5F),
|
||||||
(double) pos.getY(), (double) ((float) pos.getZ() + 0.5F), explosionIn.getExplosivePlacedBy());
|
(double) pos.getY(), (double) ((float) pos.getZ() + 0.5F), explosionIn.getExplosivePlacedBy());
|
||||||
entitynukeprimed.fuse = worldIn.rand.nextInt(entitynukeprimed.fuse / 4) + entitynukeprimed.fuse / 8;
|
entitynukeprimed.setFuse(worldIn.rand.nextInt(EntityNukePrimed.fuseTime / 4) + EntityNukePrimed.fuseTime / 8);
|
||||||
worldIn.spawnEntity(entitynukeprimed);
|
worldIn.spawnEntity(entitynukeprimed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,10 +85,12 @@ public class BlockNuke extends BaseBlock {
|
||||||
public void onEntityCollision(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
|
public void onEntityCollision(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
|
||||||
if (!worldIn.isRemote && entityIn instanceof EntityArrow) {
|
if (!worldIn.isRemote && entityIn instanceof EntityArrow) {
|
||||||
EntityArrow entityarrow = (EntityArrow) entityIn;
|
EntityArrow entityarrow = (EntityArrow) entityIn;
|
||||||
|
EntityLivingBase shooter = null;
|
||||||
|
if (entityarrow.shootingEntity instanceof EntityLivingBase) {
|
||||||
|
shooter = (EntityLivingBase) entityarrow.shootingEntity;
|
||||||
|
}
|
||||||
if (entityarrow.isBurning()) {
|
if (entityarrow.isBurning()) {
|
||||||
this.explode(worldIn, pos, state, entityarrow.shootingEntity instanceof EntityLivingBase
|
ignite(worldIn, pos, state, shooter);
|
||||||
? (EntityLivingBase) entityarrow.shootingEntity : null);
|
|
||||||
worldIn.setBlockToAir(pos);
|
worldIn.setBlockToAir(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,18 +100,15 @@ public class BlockNuke extends BaseBlock {
|
||||||
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
|
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
|
||||||
super.onBlockAdded(worldIn, pos, state);
|
super.onBlockAdded(worldIn, pos, state);
|
||||||
if (worldIn.isBlockPowered(pos)) {
|
if (worldIn.isBlockPowered(pos)) {
|
||||||
this.explode(worldIn, pos, state, null);
|
ignite(worldIn, pos, state, null);
|
||||||
worldIn.setBlockToAir(pos);
|
worldIn.setBlockToAir(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a neighboring block changes.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos p_189540_5_) {
|
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos p_189540_5_) {
|
||||||
if (worldIn.isBlockPowered(pos)) {
|
if (worldIn.isBlockPowered(pos)) {
|
||||||
this.explode(worldIn, pos, state, null);
|
ignite(worldIn, pos, state, null);
|
||||||
worldIn.setBlockToAir(pos);
|
worldIn.setBlockToAir(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ public class ContainerDestructoPack extends RebornContainer {
|
||||||
private EntityPlayer player;
|
private EntityPlayer player;
|
||||||
private Inventory inv;
|
private Inventory inv;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public ContainerDestructoPack(EntityPlayer player) {
|
public ContainerDestructoPack(EntityPlayer player) {
|
||||||
super(null);
|
super(null);
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
|
@ -51,8 +51,8 @@ public class RenderNukePrimed extends Render<EntityNukePrimed> {
|
||||||
BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
|
BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
GlStateManager.translate((float) x, (float) y + 0.5F, (float) z);
|
GlStateManager.translate((float) x, (float) y + 0.5F, (float) z);
|
||||||
if ((float) entity.fuse - partialTicks + 1.0F < 10.0F) {
|
if ((float) entity.getFuse() - partialTicks + 1.0F < 10.0F) {
|
||||||
float f = 1.0F - ((float) entity.fuse - partialTicks + 1.0F) / 10.0F;
|
float f = 1.0F - ((float) entity.getFuse() - partialTicks + 1.0F) / 10.0F;
|
||||||
f = MathHelper.clamp(f, 0.0F, 1.0F);
|
f = MathHelper.clamp(f, 0.0F, 1.0F);
|
||||||
f = f * f;
|
f = f * f;
|
||||||
f = f * f;
|
f = f * f;
|
||||||
|
@ -64,7 +64,7 @@ public class RenderNukePrimed extends Render<EntityNukePrimed> {
|
||||||
blockrendererdispatcher.renderBlockBrightness(ModBlocks.NUKE.getDefaultState(),
|
blockrendererdispatcher.renderBlockBrightness(ModBlocks.NUKE.getDefaultState(),
|
||||||
entity.getBrightness());
|
entity.getBrightness());
|
||||||
GlStateManager.translate(0.0F, 0.0F, 1.0F);
|
GlStateManager.translate(0.0F, 0.0F, 1.0F);
|
||||||
if (entity.fuse / 5 % 2 == 0) {
|
if (entity.getFuse() / 5 % 2 == 0) {
|
||||||
GlStateManager.disableLighting();
|
GlStateManager.disableLighting();
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
GlStateManager.blendFunc(770, 772);
|
GlStateManager.blendFunc(770, 772);
|
||||||
|
|
|
@ -41,8 +41,8 @@ import techreborn.lib.ModInfo;
|
||||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||||
public class EntityNukePrimed extends EntityTNTPrimed {
|
public class EntityNukePrimed extends EntityTNTPrimed {
|
||||||
|
|
||||||
@ConfigRegistry(config = "misc", category = "nuke", key = "fuse", comment = "Nuke fuse time (ticks)")
|
@ConfigRegistry(config = "misc", category = "nuke", key = "fusetime", comment = "Nuke fuse time (ticks)")
|
||||||
public static int fuse = 400;
|
public static int fuseTime = 400;
|
||||||
|
|
||||||
@ConfigRegistry(config = "misc", category = "nuke", key = "radius", comment = "Nuke explision radius")
|
@ConfigRegistry(config = "misc", category = "nuke", key = "radius", comment = "Nuke explision radius")
|
||||||
public static int radius = 40;
|
public static int radius = 40;
|
||||||
|
@ -52,37 +52,45 @@ public class EntityNukePrimed extends EntityTNTPrimed {
|
||||||
|
|
||||||
public EntityNukePrimed(World world) {
|
public EntityNukePrimed(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
|
setFuse(EntityNukePrimed.fuseTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityNukePrimed(World world, double x, double y, double z, EntityLivingBase tntPlacedBy) {
|
public EntityNukePrimed(World world, double x, double y, double z, EntityLivingBase tntPlacedBy) {
|
||||||
super(world, x, y, z, tntPlacedBy);
|
super(world, x, y, z, tntPlacedBy);
|
||||||
|
setFuse(EntityNukePrimed.fuseTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate() {
|
public void onUpdate() {
|
||||||
|
|
||||||
this.prevPosX = this.posX;
|
this.prevPosX = this.posX;
|
||||||
this.prevPosY = this.posY;
|
this.prevPosY = this.posY;
|
||||||
this.prevPosZ = this.posZ;
|
this.prevPosZ = this.posZ;
|
||||||
|
|
||||||
|
if (!this.hasNoGravity()) {
|
||||||
this.motionY -= 0.03999999910593033D;
|
this.motionY -= 0.03999999910593033D;
|
||||||
|
}
|
||||||
|
|
||||||
this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ);
|
this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ);
|
||||||
this.motionX *= 0.9800000190734863D;
|
this.motionX *= 0.9800000190734863D;
|
||||||
this.motionY *= 0.9800000190734863D;
|
this.motionY *= 0.9800000190734863D;
|
||||||
this.motionZ *= 0.9800000190734863D;
|
this.motionZ *= 0.9800000190734863D;
|
||||||
|
|
||||||
if (this.onGround) {
|
if (this.onGround) {
|
||||||
this.motionX *= 0.699999988079071D;
|
this.motionX *= 0.699999988079071D;
|
||||||
this.motionZ *= 0.699999988079071D;
|
this.motionZ *= 0.699999988079071D;
|
||||||
this.motionY *= -0.5D;
|
this.motionY *= -0.5D;
|
||||||
}
|
}
|
||||||
if (this.fuse-- <= 0) {
|
|
||||||
|
setFuse(getFuse() - 1);
|
||||||
|
|
||||||
|
if (getFuse() <= 0) {
|
||||||
this.setDead();
|
this.setDead();
|
||||||
if (!this.world.isRemote) {
|
if (!this.world.isRemote) {
|
||||||
this.explodeNuke();
|
explodeNuke();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.handleWaterMovement();
|
this.handleWaterMovement();
|
||||||
this.world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX, this.posY + 0.5D, this.posZ, 0.0D,
|
this.world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
|
||||||
0.0D, 0.0D, new int[0]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,10 +98,8 @@ public class EntityNukePrimed extends EntityTNTPrimed {
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RebornExplosion nukeExplosion = new RebornExplosion(new BlockPos(this.posX, this.posY, this.posZ), world,
|
RebornExplosion nukeExplosion = new RebornExplosion(new BlockPos(posX, posY, posZ), world, radius);
|
||||||
radius);
|
|
||||||
nukeExplosion.setLivingBase(getTntPlacedBy());
|
nukeExplosion.setLivingBase(getTntPlacedBy());
|
||||||
nukeExplosion.explode();
|
nukeExplosion.explode();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue