summaryrefslogtreecommitdiff
path: root/src/main/java/com/sosnitzka
diff options
context:
space:
mode:
authorRobert Sosnitzka <robert.sosnitzka@gmail.com>2016-06-12 14:02:37 +0200
committerRobert Sosnitzka <robert.sosnitzka@gmail.com>2016-06-12 14:02:37 +0200
commitbd09ee6a1c88ef1cadaa4fa09d99f050f74dc1b9 (patch)
treea63c5fdf0ef7ca45d656656d0ead6fccc2bd620f /src/main/java/com/sosnitzka
parent78e091a0c98c581407bd9b89d20dfe2480dda7c9 (diff)
Custom Explosion "ZExplosion", called via TraitInstable, works, but does not destroy anything... still needs to be reworked.
Diffstat (limited to 'src/main/java/com/sosnitzka')
-rw-r--r--src/main/java/com/sosnitzka/ztic_addon/util/ZExplosion.java (renamed from src/main/java/com/sosnitzka/ztic_addon/util/traits/ZExplosion.java)17
-rw-r--r--src/main/java/com/sosnitzka/ztic_addon/util/ZWorld.java39
-rw-r--r--src/main/java/com/sosnitzka/ztic_addon/util/traits/TraitInstable.java16
3 files changed, 21 insertions, 51 deletions
diff --git a/src/main/java/com/sosnitzka/ztic_addon/util/traits/ZExplosion.java b/src/main/java/com/sosnitzka/ztic_addon/util/ZExplosion.java
index 68f874f..07a3788 100644
--- a/src/main/java/com/sosnitzka/ztic_addon/util/traits/ZExplosion.java
+++ b/src/main/java/com/sosnitzka/ztic_addon/util/ZExplosion.java
@@ -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 {
}
}
}
-}
+
+} \ No newline at end of file
diff --git a/src/main/java/com/sosnitzka/ztic_addon/util/ZWorld.java b/src/main/java/com/sosnitzka/ztic_addon/util/ZWorld.java
deleted file mode 100644
index 05ee2a4..0000000
--- a/src/main/java/com/sosnitzka/ztic_addon/util/ZWorld.java
+++ /dev/null
@@ -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;
- }
-}
diff --git a/src/main/java/com/sosnitzka/ztic_addon/util/traits/TraitInstable.java b/src/main/java/com/sosnitzka/ztic_addon/util/traits/TraitInstable.java
index 8f9cbf6..4b15dc3 100644
--- a/src/main/java/com/sosnitzka/ztic_addon/util/traits/TraitInstable.java
+++ b/src/main/java/com/sosnitzka/ztic_addon/util/traits/TraitInstable.java
@@ -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;
+ }
+
}