forked from TAIGA/TAIGA
Custom Explosion "ZExplosion", called via TraitInstable, works, but does not destroy anything... still needs to be reworked.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package com.sosnitzka.ztic_addon.util.traits;
|
||||
package com.sosnitzka.ztic_addon.util;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
@@ -16,15 +16,14 @@ import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by Robert on 11.06.2016.
|
||||
*/
|
||||
public class ZExplosion extends Explosion {
|
||||
|
||||
/**
|
||||
@@ -46,12 +45,14 @@ public class ZExplosion extends Explosion {
|
||||
private final Map<EntityPlayer, Vec3d> playerKnockbackMap;
|
||||
private final Vec3d position;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ZExplosion(World worldIn, Entity entityIn, double x, double y, double z, float size, boolean flaming, boolean smoking) {
|
||||
super(worldIn, entityIn, x, y, z, size, flaming, smoking);
|
||||
|
||||
this.explosionRNG = new Random();
|
||||
this.affectedBlockPositions = Lists.<BlockPos>newArrayList();
|
||||
this.playerKnockbackMap = Maps.<EntityPlayer, Vec3d>newHashMap();
|
||||
this.worldObj = worldIn;
|
||||
this.worldObj = entityIn.getEntityWorld();
|
||||
this.exploder = entityIn;
|
||||
this.explosionSize = size;
|
||||
this.explosionX = x;
|
||||
@@ -135,8 +136,7 @@ public class ZExplosion extends Explosion {
|
||||
d9 = d9 / d13;
|
||||
double d14 = (double) this.worldObj.getBlockDensity(vec3d, entity.getEntityBoundingBox());
|
||||
double d10 = (1.0D - d12) * d14;
|
||||
if (!(entity instanceof EntityPlayer))
|
||||
entity.attackEntityFrom(DamageSource.causeExplosionDamage(this), (float) ((int) ((d10 * d10 + d10) / 2.0D * 7.0D * (double) f3 + 1.0D)));
|
||||
entity.attackEntityFrom(DamageSource.causeExplosionDamage(this), (float) ((int) ((d10 * d10 + d10) / 2.0D * 7.0D * (double) f3 + 1.0D)));
|
||||
double d11 = 1.0D;
|
||||
|
||||
if (entity instanceof EntityLivingBase) {
|
||||
@@ -159,4 +159,5 @@ public class ZExplosion extends Explosion {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
package com.sosnitzka.ztic_addon.util;
|
||||
|
||||
import com.sosnitzka.ztic_addon.util.traits.ZExplosion;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.profiler.Profiler;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldProvider;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.storage.ISaveHandler;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
|
||||
/**
|
||||
* Created by Robert on 11.06.2016.
|
||||
*/
|
||||
public class ZWorld extends World {
|
||||
protected ZWorld(ISaveHandler saveHandlerIn, WorldInfo info, WorldProvider providerIn, Profiler profilerIn, boolean client) {
|
||||
super(saveHandlerIn, info, providerIn, profilerIn, client);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IChunkProvider createChunkProvider() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isChunkLoaded(int x, int z, boolean allowEmpty) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Explosion newExplosion(Entity entityIn, double x, double y, double z, float strength, boolean isFlaming, boolean isSmoking) {
|
||||
ZExplosion explosion = new ZExplosion(this, entityIn, x, y, z, strength, isFlaming, isSmoking);
|
||||
if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this, explosion)) return explosion;
|
||||
explosion.doExplosionA();
|
||||
explosion.doExplosionB(true);
|
||||
return explosion;
|
||||
}
|
||||
}
|
@@ -1,7 +1,8 @@
|
||||
package com.sosnitzka.ztic_addon.util.traits;
|
||||
|
||||
import com.sosnitzka.ztic_addon.util.ZWorld;
|
||||
import com.sosnitzka.ztic_addon.util.ZExplosion;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -24,11 +25,10 @@ public class TraitInstable extends AbstractTrait {
|
||||
|
||||
@Override
|
||||
public void afterBlockBreak(ItemStack tool, World world, IBlockState state, BlockPos pos, EntityLivingBase player, boolean wasEffective) {
|
||||
ZWorld world2 = (ZWorld) world;
|
||||
if (MathHelper.getRandomIntegerInRange(random, 0, 100) > 2) {
|
||||
if (!world.isRemote)
|
||||
|
||||
world2.newExplosion(null, pos.getX(), pos.getY(), pos.getZ(), 2f, true, true);
|
||||
newZExplosion(player, pos.getX(), pos.getY(), pos.getZ(), 2f, true, true);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class TraitInstable extends AbstractTrait {
|
||||
public void afterHit(ItemStack tool, EntityLivingBase player, EntityLivingBase target, float damage, boolean wasCritical, boolean wasHit) {
|
||||
BlockPos pos = target.getPosition();
|
||||
if (MathHelper.getRandomIntegerInRange(random, 0, 100) < 2) {
|
||||
target.getEntityWorld().newExplosion(target, pos.getX(), pos.getY(), pos.getZ(), 1.5f, true, true);
|
||||
newZExplosion(target, pos.getX(), pos.getY(), pos.getZ(), 2f, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,14 @@ public class TraitInstable extends AbstractTrait {
|
||||
}
|
||||
} */
|
||||
|
||||
private ZExplosion newZExplosion(Entity entityIn, double x, double y, double z, float strength, boolean isFlaming, boolean isSmoking) {
|
||||
ZExplosion explosion = new ZExplosion(entityIn.worldObj, entityIn, x, y, z, strength, isFlaming, isSmoking);
|
||||
if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(entityIn.worldObj, explosion)) return explosion;
|
||||
explosion.doExplosionA();
|
||||
explosion.doExplosionB(true);
|
||||
return explosion;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user