aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/entity
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2019-03-14 18:16:17 +0000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2019-03-14 18:16:17 +0000
commit0cb924d25dd80c22d000898fb27ab3ed0e0f80fb (patch)
tree83befe3606e583ab3b50f93205aea70d850bb8f1 /src/Java/gtPlusPlus/core/entity
parent3f6606f61cd5d1f822d26036f218da9defeed17a (diff)
downloadGT5-Unofficial-0cb924d25dd80c22d000898fb27ab3ed0e0f80fb.tar.gz
GT5-Unofficial-0cb924d25dd80c22d000898fb27ab3ed0e0f80fb.tar.bz2
GT5-Unofficial-0cb924d25dd80c22d000898fb27ab3ed0e0f80fb.zip
+ Added Bombs.
% Made RAW collectors produce 10x less. $ Fixed tooltips on RAW collectors. $ Fixed a bug regarding STARTUP_PHASE.
Diffstat (limited to 'src/Java/gtPlusPlus/core/entity')
-rw-r--r--src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java3
-rw-r--r--src/Java/gtPlusPlus/core/entity/projectile/EntityThrowableBomb.java115
2 files changed, 118 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java b/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java
index 36f5b86184..e5c779adcf 100644
--- a/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java
+++ b/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java
@@ -14,6 +14,7 @@ import gtPlusPlus.core.entity.monster.EntitySickBlaze;
import gtPlusPlus.core.entity.monster.EntityStaballoyConstruct;
import gtPlusPlus.core.entity.projectile.EntityHydrofluoricAcidPotion;
import gtPlusPlus.core.entity.projectile.EntitySulfuricAcidPotion;
+import gtPlusPlus.core.entity.projectile.EntityThrowableBomb;
import gtPlusPlus.core.entity.projectile.EntityToxinballSmall;
import gtPlusPlus.core.util.Utils;
@@ -51,6 +52,8 @@ public class InternalEntityRegistry {
//EntityRegistry.registerGlobalEntityID(EntityTeslaTowerLightning.class, "plasmaBolt", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(125, 125, 125));
EntityRegistry.registerModEntity(EntityTeslaTowerLightning.class, "plasmaBolt", mEntityID++, GTplusplus.instance, 64, 5, true);
+ EntityRegistry.registerModEntity(EntityThrowableBomb.class, "EntityThrowableBomb", mEntityID++, GTplusplus.instance, 64, 10, true);
+
/**
* Globals, which generate spawn eggs. (Currently required for Giant chicken spawning)
*/
diff --git a/src/Java/gtPlusPlus/core/entity/projectile/EntityThrowableBomb.java b/src/Java/gtPlusPlus/core/entity/projectile/EntityThrowableBomb.java
new file mode 100644
index 0000000000..9e72daf687
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/entity/projectile/EntityThrowableBomb.java
@@ -0,0 +1,115 @@
+package gtPlusPlus.core.entity.projectile;
+
+import net.minecraft.block.Block;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.projectile.EntityThrowable;
+import net.minecraft.init.Blocks;
+import net.minecraft.util.DamageSource;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.world.World;
+
+import gregtech.api.util.GT_Utility;
+
+import gtPlusPlus.api.objects.minecraft.BlockPos;
+import gtPlusPlus.core.util.math.MathUtils;
+import gtPlusPlus.core.util.minecraft.EntityUtils;
+
+public class EntityThrowableBomb extends EntityThrowable {
+
+ public EntityThrowableBomb(World world) {
+ super(world);
+ }
+
+ public EntityThrowableBomb(World world, EntityLivingBase entity) {
+ super(world, entity);
+ }
+
+ public EntityThrowableBomb(World world, double posX, double posY, double posZ) {
+ super(world, posX, posY, posZ);
+ }
+
+ /**
+ * Called when this EntityThrowable hits a block or entity.
+ */
+ @Override
+ protected void onImpact(MovingObjectPosition object) {
+ int xBlock = object.blockX;
+ int yBlock = object.blockY;
+ int zBlock = object.blockZ;
+ if (object.entityHit != null) {
+ byte b0 = 6;
+ if (!GT_Utility.isWearingFullRadioHazmat((EntityLivingBase) object.entityHit)){
+ object.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), b0);
+ EntityUtils.setEntityOnFire(object.entityHit, 10);
+ object.entityHit.fireResistance = 0;
+ ravage(EntityUtils.findBlockPosUnderEntity(object.entityHit));
+ }
+ }
+ if (object.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK){
+ ravage(new BlockPos(xBlock, yBlock, zBlock));
+ }
+
+ String mParticleType = "reddust";
+ int e=0;
+ for (int i = 0; i < 24; ++i) {
+ if ((e = MathUtils.randInt(0, 5)) <= 1){
+ if (e==0)
+ mParticleType = "largesmoke";
+ if (e==1)
+ mParticleType = "flame";
+ }
+ this.worldObj.spawnParticle(mParticleType, this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D);
+ }
+
+ if (!this.worldObj.isRemote) {
+ this.setDead();
+ }
+ }
+
+ private boolean ravage(BlockPos blockpos){
+
+ int radius = 1;
+
+ for (int i=(blockpos.xPos-radius);i<(blockpos.xPos+radius);i++){
+ for (int j=(blockpos.yPos-radius);j<(blockpos.yPos+radius);j++){
+ for (int h=(blockpos.zPos-radius);h<(blockpos.zPos+radius);h++){
+
+ int mChance = MathUtils.randInt(1, 10);
+ if (mChance <= 3){
+ Block mBlockhit = worldObj.getBlock(i, j, h);
+ this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D);
+ this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D);
+
+ //GT_Pollution.addPollution(worldObj.getChunkFromBlockCoords(blockpos.xPos, blockpos.zPos), mPol);
+ this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 0.01f, true);
+ if (mBlockhit == Blocks.grass || mBlockhit == Blocks.mycelium){
+ worldObj.setBlock(i, j+1, h, Blocks.fire);
+ worldObj.setBlock(i, j, h, Blocks.dirt);
+ }
+ else if (mBlockhit == Blocks.leaves || mBlockhit == Blocks.leaves2){
+ worldObj.setBlock(i, j, h, Blocks.fire);
+ }
+ else if (mBlockhit == Blocks.tallgrass){
+ worldObj.setBlock(i, j, h, Blocks.fire);
+ if (worldObj.getBlock(i, j-1, h) == Blocks.grass){
+ worldObj.setBlock(i, j-1, h, Blocks.dirt);
+ }
+ }
+ else if (mBlockhit == Blocks.carrots || mBlockhit == Blocks.melon_block || mBlockhit == Blocks.pumpkin || mBlockhit == Blocks.potatoes){
+ worldObj.setBlock(i, j+1, h, Blocks.fire);
+ worldObj.setBlock(i, j, h, Blocks.dirt);
+ }
+ else if (mBlockhit == Blocks.air){
+ worldObj.setBlock(i, j, h, Blocks.fire);
+ }
+ }
+ }
+ }
+ }
+
+
+ return true;
+ }
+
+
+} \ No newline at end of file