2017-02-23 13:29:43 +01:00
|
|
|
/*
|
|
|
|
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
|
|
|
*
|
|
|
|
* Copyright (c) 2017 TechReborn
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
|
|
* copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2016-03-13 12:50:46 +01:00
|
|
|
package techreborn.entitys;
|
|
|
|
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2016-11-19 13:50:08 +01:00
|
|
|
import net.minecraft.entity.MoverType;
|
2016-03-13 12:50:46 +01:00
|
|
|
import net.minecraft.entity.item.EntityTNTPrimed;
|
|
|
|
import net.minecraft.util.EnumParticleTypes;
|
2016-03-15 09:13:05 +01:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2016-03-13 12:50:46 +01:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
import reborncore.common.explosion.RebornExplosion;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by Mark on 13/03/2016.
|
|
|
|
*/
|
2016-10-08 21:46:16 +02:00
|
|
|
public class EntityNukePrimed extends EntityTNTPrimed {
|
2016-03-13 12:50:46 +01:00
|
|
|
|
2016-03-25 10:47:34 +01:00
|
|
|
public int fuse = 400;
|
|
|
|
|
2016-10-08 21:46:16 +02:00
|
|
|
public EntityNukePrimed(World world) {
|
2016-03-25 10:47:34 +01:00
|
|
|
super(world);
|
|
|
|
}
|
|
|
|
|
2016-10-08 21:46:16 +02:00
|
|
|
public EntityNukePrimed(World world, double x, double y, double z, EntityLivingBase tntPlacedBy) {
|
2016-03-25 10:47:34 +01:00
|
|
|
super(world, x, y, z, tntPlacedBy);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-10-08 21:46:16 +02:00
|
|
|
public void onUpdate() {
|
2016-03-25 10:47:34 +01:00
|
|
|
|
|
|
|
this.prevPosX = this.posX;
|
|
|
|
this.prevPosY = this.posY;
|
|
|
|
this.prevPosZ = this.posZ;
|
|
|
|
this.motionY -= 0.03999999910593033D;
|
2016-11-19 13:50:08 +01:00
|
|
|
this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ);
|
2016-03-25 10:47:34 +01:00
|
|
|
this.motionX *= 0.9800000190734863D;
|
|
|
|
this.motionY *= 0.9800000190734863D;
|
|
|
|
this.motionZ *= 0.9800000190734863D;
|
2016-10-08 21:46:16 +02:00
|
|
|
if (this.onGround) {
|
2016-03-25 10:47:34 +01:00
|
|
|
this.motionX *= 0.699999988079071D;
|
|
|
|
this.motionZ *= 0.699999988079071D;
|
|
|
|
this.motionY *= -0.5D;
|
|
|
|
}
|
2016-10-08 21:46:16 +02:00
|
|
|
if (this.fuse-- <= 0) {
|
2016-03-25 10:47:34 +01:00
|
|
|
this.setDead();
|
2016-11-19 13:50:08 +01:00
|
|
|
if (!this.world.isRemote) {
|
2016-03-25 10:47:34 +01:00
|
|
|
this.explodeNuke();
|
|
|
|
}
|
2016-10-08 21:46:16 +02:00
|
|
|
} else {
|
2016-03-25 10:47:34 +01:00
|
|
|
this.handleWaterMovement();
|
2016-11-19 13:50:08 +01:00
|
|
|
this.world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX, this.posY + 0.5D, this.posZ, 0.0D,
|
2016-10-08 21:46:16 +02:00
|
|
|
0.0D, 0.0D, new int[0]);
|
2016-03-25 10:47:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-08 21:46:16 +02:00
|
|
|
public void explodeNuke() {
|
2016-11-19 13:50:08 +01:00
|
|
|
RebornExplosion nukeExplosion = new RebornExplosion(new BlockPos(this.posX, this.posY, this.posZ), world,
|
2016-10-08 21:46:16 +02:00
|
|
|
40);
|
2016-03-25 10:47:34 +01:00
|
|
|
nukeExplosion.setLivingBase(getTntPlacedBy());
|
|
|
|
nukeExplosion.explode();
|
|
|
|
}
|
2016-03-13 12:50:46 +01:00
|
|
|
|
|
|
|
}
|