Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
minecraft_version=1.7.10
forge_version=10.13.0.1198
mod_version=1.15.0
minecraft_version=1.8
forge_version=11.14.1.1412
mod_version=1.16.0
mod_author=BalkondeurAlpha
mod_basename=weaponmod
mod_builder_tok=gitbuild
76 changes: 40 additions & 36 deletions src/main/java/ckathode/weaponmod/AdvancedExplosion.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,37 @@
import java.util.Random;
import java.util.Set;

import com.google.common.collect.Lists;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraft.world.ChunkPosition;
import net.minecraft.util.*;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import net.minecraft.util.EnumParticleTypes;
import org.lwjgl.Sys;

public class AdvancedExplosion extends Explosion
{
public World worldObj;
protected boolean blocksCalculated;

public AdvancedExplosion(World world, Entity entity, double d, double d1, double d2, float f)
protected double explosionX, explosionY, explosionZ;
public float explosionSize;
public List affectedBlockPositions;
public Entity exploder;

public AdvancedExplosion(World world, Entity exploder, double explosionX, double explosionY, double explosionZ, float explosionSize, boolean isFlaming, boolean isSmoking)
{
super(world, entity, d, d1, d2, f);
super(world, exploder, explosionX, explosionY, explosionZ, explosionSize, isFlaming, isSmoking);
this.explosionSize = explosionSize;
this.explosionX = explosionX;
this.explosionY = explosionY;
this.explosionZ = explosionZ;
affectedBlockPositions = Lists.newArrayList();
worldObj = world;
}

public void setAffectedBlockPositions(List<ChunkPosition> list)
public void setAffectedBlockPositions(List<BlockPos> list)
{
affectedBlockPositions = list;
blocksCalculated = true;
Expand All @@ -48,8 +56,8 @@ public void doEntityExplosion(DamageSource damagesource)
int k0 = MathHelper.floor_double(explosionZ - size - 1.0D);
int k1 = MathHelper.floor_double(explosionZ + size + 1.0D);
@SuppressWarnings("unchecked")
List<Entity> list = worldObj.getEntitiesWithinAABBExcludingEntity(exploder, AxisAlignedBB.getBoundingBox(i0, j0, k0, i1, j1, k1));
Vec3 vec31 = Vec3.createVectorHelper(explosionX, explosionY, explosionZ);
List<Entity> list = worldObj.getEntitiesWithinAABBExcludingEntity(exploder, AxisAlignedBB.fromBounds(i0, j0, k0, i1, j1, k1));
Vec3 vec31 = new Vec3(explosionX, explosionY, explosionZ);

double dx;
double dy;
Expand All @@ -72,7 +80,7 @@ public void doEntityExplosion(DamageSource damagesource)
dx /= d;
dy /= d;
dz /= d;
double dens = worldObj.getBlockDensity(vec31, entity.boundingBox);
double dens = worldObj.getBlockDensity(vec31, entity.getEntityBoundingBox());
double var36 = (1.0D - dr) * dens;
int damage = (int) ((var36 * var36 + var36) / 2.0D * 8.0D * size + 1D);
entity.attackEntityFrom(damagesource, damage);
Expand All @@ -92,20 +100,18 @@ public void doBlockExplosion()
}
for (int i = affectedBlockPositions.size() - 1; i >= 0; i--)
{
ChunkPosition chunkposition = (ChunkPosition) affectedBlockPositions.get(i);
int x = chunkposition.chunkPosX;
int y = chunkposition.chunkPosY;
int z = chunkposition.chunkPosZ;
Block block = worldObj.getBlock(x, y, z);
BlockPos blockposition = (BlockPos) affectedBlockPositions.get(i);

Block block = worldObj.getBlockState(blockposition).getBlock();
if (block != null)
{
if (block.canDropFromExplosion(this))
{
block.dropBlockAsItemWithChance(worldObj, x, y, z, worldObj.getBlockMetadata(x, y, z), 1F / explosionSize, 0);
block.dropBlockAsItemWithChance(worldObj, blockposition, worldObj.getBlockState(blockposition), 1F / explosionSize, 0);
}

worldObj.setBlock(x, y, z, Blocks.air, 0, 3);
block.onBlockDestroyedByExplosion(worldObj, x, y, z, this);
worldObj.setBlockToAir(blockposition);
block.onBlockDestroyedByExplosion(worldObj, blockposition, this);
}
}
}
Expand All @@ -115,7 +121,7 @@ public void doParticleExplosion(boolean smallparticles, boolean bigparticles)
worldObj.playSoundEffect(explosionX, explosionY, explosionZ, "random.explode", 4F, (1.0F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F) * 0.7F);
if (bigparticles)
{
worldObj.spawnParticle("hugeexplosion", explosionX, explosionY, explosionZ, 0.0D, 0.0D, 0.0D);
worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, explosionX, explosionY, explosionZ, 0.0D, 0.0D, 0.0D);
}
if (!smallparticles) return;

Expand All @@ -126,11 +132,11 @@ public void doParticleExplosion(boolean smallparticles, boolean bigparticles)

for (int i = affectedBlockPositions.size() - 1; i >= 0; i--)
{
ChunkPosition chunkposition = (ChunkPosition) affectedBlockPositions.get(i);
int j = chunkposition.chunkPosX;
int k = chunkposition.chunkPosY;
int l = chunkposition.chunkPosZ;
//int i1 = worldObj.getBlockId(j, k, l);
BlockPos chunkposition = (BlockPos) affectedBlockPositions.get(i);
int j = (int) chunkposition.getX();
int k = (int) chunkposition.getY();
int l = (int) chunkposition.getZ();
//Block i1 = worldObj.getBlockState(new BlockPos(j, k, l)).getBlock();
double px = j + worldObj.rand.nextFloat();
double py = k + worldObj.rand.nextFloat();
double pz = l + worldObj.rand.nextFloat();
Expand All @@ -146,16 +152,16 @@ public void doParticleExplosion(boolean smallparticles, boolean bigparticles)
dx *= d7;
dy *= d7;
dz *= d7;
worldObj.spawnParticle("explode", (px + explosionX * 1.0D) / 2D, (py + explosionY * 1.0D) / 2D, (pz + explosionZ * 1.0D) / 2D, dx, dy, dz);
worldObj.spawnParticle("smoke", px, py, pz, dx, dy, dz);
worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL, (px + explosionX * 1.0D) / 2D, (py + explosionY * 1.0D) / 2D, (pz + explosionZ * 1.0D) / 2D, dx, dy, dz);
worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, px, py, pz, dx, dy, dz);
}
}

@SuppressWarnings("unchecked")
protected void calculateBlockExplosion()
{
byte maxsize = 16;
Set<ChunkPosition> set = new HashSet<ChunkPosition>();
Set<BlockPos> set = new HashSet<BlockPos>();
int i;
int j;
int k;
Expand All @@ -182,22 +188,20 @@ protected void calculateBlockExplosion()
dx = explosionX;
dy = explosionY;
dz = explosionZ;

for (float f = 0.3F; strength > 0.0F; strength -= f * 0.75F)
{
int x = MathHelper.floor_double(dx);
int y = MathHelper.floor_double(dy);
int z = MathHelper.floor_double(dz);
Block block = worldObj.getBlock(x, y, z);
if (block != null)
Block block = worldObj.getBlockState(new BlockPos(x, y, z)).getBlock();

if (block != Blocks.air)
{
strength -= (block.getExplosionResistance(exploder, worldObj, x, y, z, explosionX, explosionY, explosionZ) + 0.3F) * f;
strength -= (block.getExplosionResistance(exploder)+0.3F)*f;
}

if (strength > 0.0F)
{
set.add(new ChunkPosition(x, y, z));
set.add(new BlockPos(x, y, z));
}

dx += rx * f;
Expand Down
30 changes: 17 additions & 13 deletions src/main/java/ckathode/weaponmod/BalkonsWeaponMod.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package ckathode.weaponmod;

import net.minecraft.block.BlockDispenser;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemModelMesher;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.oredict.ShapedOreRecipe;

import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -57,28 +63,28 @@
import ckathode.weaponmod.item.RangedCompFlintlock;
import ckathode.weaponmod.item.WMItem;
import ckathode.weaponmod.network.WMMessagePipeline;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;

@Mod(modid = BalkonsWeaponMod.MOD_ID, name = BalkonsWeaponMod.MOD_NAME, version = BalkonsWeaponMod.MOD_VERSION)
public class BalkonsWeaponMod
{
public static final String MOD_ID = "weaponmod";
public static final String MOD_NAME = "Balkon's WeaponMod";
public static final String MOD_VERSION = "v1.14.3";
public static final String MOD_VERSION = "v1.16";

@Instance("weaponmod")
public static BalkonsWeaponMod instance;

public static Logger modLog;

@SidedProxy(clientSide = "ckathode.weaponmod.WMClientProxy", serverSide = "ckathode.weaponmod.WMCommonProxy")
public static WMCommonProxy proxy;

Expand Down Expand Up @@ -192,7 +198,6 @@ public void preInitMod(FMLPreInitializationEvent event)
@EventHandler
public void initMod(FMLInitializationEvent event)
{
messagePipeline.initalize();
proxy.registerPackets(messagePipeline);
proxy.registerEventHandlers();
proxy.registerIcons();
Expand All @@ -205,7 +210,6 @@ public void initMod(FMLInitializationEvent event)
@EventHandler
public void postInitMod(FMLPostInitializationEvent event)
{
messagePipeline.postInitialize();
}

private void addModItems()
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/ckathode/weaponmod/PhysHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import ckathode.weaponmod.network.MsgExplosion;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;

public abstract class PhysHelper
{
Expand All @@ -19,7 +20,7 @@ public abstract class PhysHelper

public static AdvancedExplosion createStandardExplosion(World world, Entity entity, double d, double d1, double d2, float size)
{
AdvancedExplosion explosion = new AdvancedExplosion(world, entity, d, d1, d2, size);
AdvancedExplosion explosion = new AdvancedExplosion(world, entity, d, d1, d2, size, true, true);
explosion.doEntityExplosion();
explosion.doBlockExplosion();
explosion.doParticleExplosion(true, true);
Expand All @@ -29,7 +30,7 @@ public static AdvancedExplosion createStandardExplosion(World world, Entity enti

public static AdvancedExplosion createAdvancedExplosion(World world, Entity entity, double d, double d1, double d2, float size, boolean destroyBlocks, boolean spawnSmallParticles, boolean spawnBigParticles)
{
AdvancedExplosion explosion = new AdvancedExplosion(world, entity, d, d1, d2, size);
AdvancedExplosion explosion = new AdvancedExplosion(world, entity, d, d1, d2, size, true, true);
explosion.doEntityExplosion();
if (destroyBlocks)
{
Expand All @@ -42,7 +43,7 @@ public static AdvancedExplosion createAdvancedExplosion(World world, Entity enti

public static AdvancedExplosion createAdvancedExplosion(World world, Entity entity, DamageSource damagesource, double d, double d1, double d2, float size, boolean destroyBlocks, boolean spawnSmallParticles, boolean spawnBigParticles)
{
AdvancedExplosion explosion = new AdvancedExplosion(world, entity, d, d1, d2, size);
AdvancedExplosion explosion = new AdvancedExplosion(world, entity, d, d1, d2, size, true, true);
explosion.doEntityExplosion(damagesource);
if (destroyBlocks)
{
Expand All @@ -55,7 +56,7 @@ public static AdvancedExplosion createAdvancedExplosion(World world, Entity enti

public static AdvancedExplosion createAdvancedExplosion(World world, Entity entity, double d, double d1, double d2, float size, boolean destroyBlocks, boolean spawnParticles)
{
AdvancedExplosion explosion = new AdvancedExplosion(world, entity, d, d1, d2, size);
AdvancedExplosion explosion = new AdvancedExplosion(world, entity, d, d1, d2, size, true, true);
explosion.doEntityExplosion();
if (destroyBlocks)
{
Expand All @@ -71,7 +72,8 @@ private static void sendExplosion(World world, AdvancedExplosion explosion, bool
if (world instanceof WorldServer && !world.isRemote)
{
MsgExplosion msg = new MsgExplosion(explosion, smallparts, bigparts);
BalkonsWeaponMod.instance.messagePipeline.sendToAllAround(msg, new TargetPoint(world.provider.dimensionId, explosion.explosionX, explosion.explosionY, explosion.explosionZ, 64D));
Vec3 explostion_pos = explosion.getPosition();
BalkonsWeaponMod.instance.messagePipeline.sendToAllAround(msg, new TargetPoint(world.provider.getDimensionId(), explostion_pos.xCoord, explostion_pos.yCoord, explostion_pos.zCoord, 64D));
}
}

Expand Down Expand Up @@ -116,7 +118,8 @@ public static void knockBack(EntityLivingBase entityliving, EntityLivingBase att

public static void prepareKnockbackOnEntity(EntityLivingBase attacker, EntityLivingBase entity)
{
knockBackModifier = EnchantmentHelper.getKnockbackModifier(attacker, entity);
//knockBackModifier = EnchantmentHelper.getKnockbackModifier(attacker, entity);
knockBackModifier = EnchantmentHelper.getKnockbackModifier(attacker);
if (attacker.isSprinting())
{
knockBackModifier++;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ckathode/weaponmod/PlayerWeaponData.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private static String getPlayerName(EntityPlayer player)
String playername;
if (player.getGameProfile() != null)
{
playername = player.getCommandSenderName();
playername = player.getCommandSenderEntity().getName();
} else
{
playername = "[unknown]";
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/ckathode/weaponmod/WMClientEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
import ckathode.weaponmod.item.IItemWeapon;
import ckathode.weaponmod.item.RangedComponent;
import ckathode.weaponmod.network.MsgCannonFire;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class WMClientEventHandler
Expand Down
Loading