mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Merge remote-tracking branch 'HbmMods/master'
This commit is contained in:
commit
6b49faa862
@ -350,6 +350,7 @@ public class WeaponRecipes {
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.nuclear_waste_pearl), new Object[] { "WWW", "WFW", "WWW", 'W', ModItems.nuclear_waste_tiny, 'F', ModBlocks.block_fallout });
|
||||
//CraftingManager.addRecipeAuto(new ItemStack(ModItems.grenade_nuke), new Object[] { "CGC", "CGC", "PAP", 'C', ModBlocks.det_charge, 'G', ModItems.grenade_mk2, 'P', ALLOY.plate(), 'A', Blocks.anvil });
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.stick_dynamite, 4), new Object[] { " S ", "PDP", "PDP", 'S', ModItems.safety_fuse, 'P', Items.paper, 'D', ModItems.ball_dynamite });
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.stick_tnt, 4), new Object[] { "PDP", "PDP", 'P', Items.paper, 'D', ModItems.ball_tnt });
|
||||
|
||||
|
||||
//IF Grenades
|
||||
|
||||
@ -54,11 +54,11 @@ public class BlockAllocatorStandard implements IBlockAllocator {
|
||||
Block block = world.getBlock(blockX, blockY, blockZ);
|
||||
|
||||
if(block.getMaterial() != Material.air) {
|
||||
float blockResistance = block.getExplosionResistance(explosion.exploder, world, blockX, blockY, blockZ, x, y, z);
|
||||
float blockResistance = explosion.exploder != null ? explosion.exploder.func_145772_a(explosion.compat, world, blockX, blockY, blockZ, block) : block.getExplosionResistance(explosion.exploder, world, blockX, blockY, blockZ, x, y, z);
|
||||
powerRemaining -= (blockResistance + 0.3F) * stepSize;
|
||||
}
|
||||
|
||||
if(powerRemaining > 0.0F) {
|
||||
if(powerRemaining > 0.0F && (explosion.exploder == null || explosion.exploder.func_145774_a(explosion.compat, world, blockX, blockY, blockZ, block, powerRemaining))) {
|
||||
affectedBlocks.add(new ChunkPosition(blockX, blockY, blockZ));
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@ import java.util.Iterator;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
@ -0,0 +1,73 @@
|
||||
package com.hbm.explosion.vanillant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.enchantment.EnchantmentProtection;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
public class EntityProcessorStandard implements IEntityProcessor {
|
||||
|
||||
@Override
|
||||
public HashMap<EntityPlayer, Vec3> process(ExplosionVNT explosion, World world, double x, double y, double z, float size) {
|
||||
|
||||
HashMap<EntityPlayer, Vec3> affectedPlayers = new HashMap();
|
||||
|
||||
size *= 2.0F;
|
||||
|
||||
double minX = x - (double) size - 1.0D;
|
||||
double maxX = x + (double) size + 1.0D;
|
||||
double minY = y - (double) size - 1.0D;
|
||||
double maxY = y + (double) size + 1.0D;
|
||||
double minZ = z - (double) size - 1.0D;
|
||||
double maxZ = z + (double) size + 1.0D;
|
||||
|
||||
List list = world.getEntitiesWithinAABBExcludingEntity(explosion.exploder, AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ));
|
||||
|
||||
ForgeEventFactory.onExplosionDetonate(world, explosion.compat, list, size);
|
||||
Vec3 vec3 = Vec3.createVectorHelper(x, y, z);
|
||||
|
||||
for(int index = 0; index < list.size(); ++index) {
|
||||
|
||||
Entity entity = (Entity) list.get(index);
|
||||
double distanceScaled = entity.getDistance(x, y, z) / size;
|
||||
|
||||
if(distanceScaled <= 1.0D) {
|
||||
|
||||
double deltaX = entity.posX - x;
|
||||
double deltaY = entity.posY + entity.getEyeHeight() - y;
|
||||
double deltaZ = entity.posZ - z;
|
||||
double distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ);
|
||||
|
||||
if(distance != 0.0D) {
|
||||
|
||||
deltaX /= distance;
|
||||
deltaY /= distance;
|
||||
deltaZ /= distance;
|
||||
|
||||
double density = world.getBlockDensity(vec3, entity.boundingBox);
|
||||
double knockback = (1.0D - distanceScaled) * density;
|
||||
|
||||
entity.attackEntityFrom(DamageSource.setExplosionSource(explosion.compat), (float) ((int) ((knockback * knockback + knockback) / 2.0D * 8.0D * size + 1.0D)));
|
||||
double enchKnockback = EnchantmentProtection.func_92092_a(entity, knockback);
|
||||
|
||||
entity.motionX += deltaX * enchKnockback;
|
||||
entity.motionY += deltaY * enchKnockback;
|
||||
entity.motionZ += deltaZ * enchKnockback;
|
||||
|
||||
if(entity instanceof EntityPlayer) {
|
||||
affectedPlayers.put((EntityPlayer) entity, Vec3.createVectorHelper(deltaX * knockback, deltaY * knockback, deltaZ * knockback));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return affectedPlayers;
|
||||
}
|
||||
}
|
||||
@ -4,8 +4,10 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
@ -17,9 +19,9 @@ public class ExplosionVNT {
|
||||
|
||||
//explosions only need one of these, in the unlikely event that we do need to combine different types we can just write a wrapper that acts as a chainloader
|
||||
private IBlockAllocator blockAllocator;
|
||||
private IEntityAllocator entityAllocator;
|
||||
private IBlockProcessor blockProcessor;
|
||||
private IEntityProcessor entityProcessor;
|
||||
private IBlockProcessor blockProcessor;
|
||||
private IPlayerProcessor playerProcessor;
|
||||
//since we want to reduce each effect to the bare minimum (sound, particles, etc. being separate) we definitely need multiple most of the time
|
||||
private IExplosionSFX[] sfx;
|
||||
|
||||
@ -30,6 +32,8 @@ public class ExplosionVNT {
|
||||
protected float size;
|
||||
public Entity exploder;
|
||||
|
||||
public Explosion compat;
|
||||
|
||||
public ExplosionVNT(World world, double x, double y, double z, float size) {
|
||||
this(world, x, y, z, size, null);
|
||||
}
|
||||
@ -41,21 +45,23 @@ public class ExplosionVNT {
|
||||
this.posZ = z;
|
||||
this.size = size;
|
||||
this.exploder = exploder;
|
||||
|
||||
this.compat = new Explosion(world, exploder, x, y, z, size);
|
||||
}
|
||||
|
||||
public void explode() {
|
||||
|
||||
boolean processBlocks = blockAllocator != null && blockProcessor != null;
|
||||
boolean processEntities = entityAllocator != null && entityProcessor != null;
|
||||
boolean processEntities = entityProcessor != null && playerProcessor != null;
|
||||
|
||||
HashSet<ChunkPosition> affectedBlocks = null;
|
||||
HashMap<Entity, Vec3> affectedEntities = null;
|
||||
HashMap<EntityPlayer, Vec3> affectedEntities = null;
|
||||
|
||||
if(processBlocks) affectedBlocks = blockAllocator.allocate(this, world, posX, posY, posZ, size);
|
||||
if(processEntities) affectedEntities = entityAllocator.allocate(this, world, posX, posY, posZ, size);
|
||||
if(processEntities) affectedEntities = entityProcessor.process(this, world, posX, posY, posZ, size);
|
||||
|
||||
if(processBlocks) blockProcessor.process(this, world, posX, posY, posZ, affectedBlocks);
|
||||
if(processEntities) entityProcessor.process(this, world, posX, posY, posZ, affectedEntities);
|
||||
if(processEntities) playerProcessor.process(this, world, posX, posY, posZ, affectedEntities);
|
||||
|
||||
if(sfx != null) {
|
||||
for(IExplosionSFX fx : sfx) {
|
||||
@ -68,16 +74,16 @@ public class ExplosionVNT {
|
||||
this.blockAllocator = blockAllocator;
|
||||
return this;
|
||||
}
|
||||
public ExplosionVNT setEntityAllocator(IEntityAllocator entityAllocator) {
|
||||
this.entityAllocator = entityAllocator;
|
||||
public ExplosionVNT setEntityProcessor(IEntityProcessor entityProcessor) {
|
||||
this.entityProcessor = entityProcessor;
|
||||
return this;
|
||||
}
|
||||
public ExplosionVNT setBlockProcessor(IBlockProcessor blockProcessor) {
|
||||
this.blockProcessor = blockProcessor;
|
||||
return this;
|
||||
}
|
||||
public ExplosionVNT setEntityprocessor(IEntityProcessor entityProcessor) {
|
||||
this.entityProcessor = entityProcessor;
|
||||
public ExplosionVNT setPlayerProcessor(IPlayerProcessor playerProcessor) {
|
||||
this.playerProcessor = playerProcessor;
|
||||
return this;
|
||||
}
|
||||
public ExplosionVNT setSFX(IExplosionSFX... sfx) {
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
package com.hbm.explosion.vanillant;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IEntityAllocator {
|
||||
|
||||
public HashMap<Entity, Vec3> allocate(ExplosionVNT explosion, World world, double x, double y, double z, float size);
|
||||
}
|
||||
@ -1,14 +1,12 @@
|
||||
package com.hbm.explosion.vanillant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IEntityProcessor {
|
||||
|
||||
public void process(ExplosionVNT explosion, World world, double x, double y, double z, HashMap<Entity, Vec3> affectedBlocks);
|
||||
public HashMap<EntityPlayer, Vec3> process(ExplosionVNT explosion, World world, double x, double y, double z, float size);
|
||||
}
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
package com.hbm.explosion.vanillant;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IExplosionSFX {
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
package com.hbm.explosion.vanillant;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IPlayerProcessor {
|
||||
|
||||
public void process(ExplosionVNT explosion, World world, double x, double y, double z, HashMap<EntityPlayer, Vec3> affectedPlayers);
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package com.hbm.explosion.vanillant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.hbm.packet.ExplosionKnockbackPacket;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class PlayerProcessorStandard implements IPlayerProcessor {
|
||||
|
||||
@Override
|
||||
public void process(ExplosionVNT explosion, World world, double x, double y, double z, HashMap<EntityPlayer, Vec3> affectedPlayers) {
|
||||
|
||||
for(Entry<EntityPlayer, Vec3> entry : affectedPlayers.entrySet()) {
|
||||
if(entry.getKey() instanceof EntityPlayerMP) {
|
||||
PacketDispatcher.wrapper.sendTo(new ExplosionKnockbackPacket(entry.getValue()), (EntityPlayerMP)entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1686,6 +1686,7 @@ public class ModItems {
|
||||
public static Item crucible;
|
||||
|
||||
public static Item stick_dynamite;
|
||||
public static Item stick_tnt;
|
||||
|
||||
public static Item grenade_generic;
|
||||
public static Item grenade_strong;
|
||||
@ -4343,6 +4344,7 @@ public class ModItems {
|
||||
crucible = new ItemCrucible(5000, 1F, matCrucible).setUnlocalizedName("crucible").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":crucible");
|
||||
|
||||
stick_dynamite = new ItemGrenade(3).setUnlocalizedName("stick_dynamite").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":stick_dynamite");
|
||||
stick_tnt = new Item().setUnlocalizedName("stick_tnt").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":stick_tnt");
|
||||
|
||||
grenade_generic = new ItemGrenade(4).setUnlocalizedName("grenade_generic").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":grenade_generic");
|
||||
grenade_strong = new ItemGrenade(5).setUnlocalizedName("grenade_strong").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":grenade_strong");
|
||||
@ -7282,6 +7284,7 @@ public class ModItems {
|
||||
|
||||
//Grenades
|
||||
GameRegistry.registerItem(stick_dynamite, stick_dynamite.getUnlocalizedName()); //heave-ho!
|
||||
GameRegistry.registerItem(stick_tnt, stick_tnt.getUnlocalizedName());
|
||||
GameRegistry.registerItem(grenade_generic, grenade_generic.getUnlocalizedName());
|
||||
GameRegistry.registerItem(grenade_strong, grenade_strong.getUnlocalizedName());
|
||||
GameRegistry.registerItem(grenade_frag, grenade_frag.getUnlocalizedName());
|
||||
|
||||
@ -469,6 +469,7 @@ public class CraftingManager {
|
||||
addShapelessAuto(new ItemStack(ModBlocks.charge_dynamite, 1), new Object[] { ModItems.stick_dynamite, ModItems.stick_dynamite, ModItems.stick_dynamite, ModItems.ducttape });
|
||||
addRecipeAuto(new ItemStack(ModBlocks.charge_miner, 1), new Object[] { " F ", "FCF", " F ", 'F', Items.flint, 'C', ModBlocks.charge_dynamite });
|
||||
addRecipeAuto(new ItemStack(ModBlocks.dynamite, 1), new Object[] { "DDD", "DSD", "DDD", 'D', ModItems.stick_dynamite, 'S', Items.string });
|
||||
addRecipeAuto(new ItemStack(ModBlocks.tnt, 1), new Object[] { "DDD", "DSD", "DDD", 'D', ModItems.stick_tnt, 'S', Items.string });
|
||||
|
||||
addRecipeAuto(ItemBattery.getEmptyBattery(ModItems.battery_generic), new Object[] { " A ", "PRP", "PRP", 'A', ModItems.wire_aluminium, 'P', AL.plate(), 'R', REDSTONE.dust() });
|
||||
addRecipeAuto(ItemBattery.getEmptyBattery(ModItems.battery_advanced), new Object[] { " A ", "PSP", "PLP", 'A', ModItems.wire_red_copper, 'P', CU.plate(), 'S', "sulfur", 'L', PB.dust() });
|
||||
|
||||
55
src/main/java/com/hbm/packet/ExplosionKnockbackPacket.java
Normal file
55
src/main/java/com/hbm/packet/ExplosionKnockbackPacket.java
Normal file
@ -0,0 +1,55 @@
|
||||
package com.hbm.packet;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
public class ExplosionKnockbackPacket implements IMessage {
|
||||
|
||||
float motionX;
|
||||
float motionY;
|
||||
float motionZ;
|
||||
|
||||
public ExplosionKnockbackPacket() { }
|
||||
|
||||
public ExplosionKnockbackPacket(Vec3 vec) {
|
||||
this.motionX = (float) vec.xCoord;
|
||||
this.motionY = (float) vec.xCoord;
|
||||
this.motionZ = (float) vec.xCoord;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.motionX = buf.readFloat();
|
||||
this.motionY = buf.readFloat();
|
||||
this.motionZ = buf.readFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeFloat(this.motionX);
|
||||
buf.writeFloat(this.motionY);
|
||||
buf.writeFloat(this.motionZ);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<ExplosionKnockbackPacket, IMessage> {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IMessage onMessage(ExplosionKnockbackPacket m, MessageContext ctx) {
|
||||
|
||||
EntityPlayer thePlayer = Minecraft.getMinecraft().thePlayer;
|
||||
thePlayer.motionX += m.motionX;
|
||||
thePlayer.motionY += m.motionY;
|
||||
thePlayer.motionZ += m.motionZ;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -97,6 +97,8 @@ public class PacketDispatcher {
|
||||
wrapper.registerMessage(AnvilCraftPacket.Handler.class, AnvilCraftPacket.class, i++, Side.SERVER);
|
||||
//Sends a funi text to display like a music disc announcement
|
||||
wrapper.registerMessage(TEDoorAnimationPacket.Handler.class, TEDoorAnimationPacket.class, i++, Side.CLIENT);
|
||||
//Sends a funi text to display like a music disc announcement
|
||||
wrapper.registerMessage(ExplosionKnockbackPacket.Handler.class, ExplosionKnockbackPacket.class, i++, Side.CLIENT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2597,6 +2597,7 @@ item.steel_plate.name=Stahlbrustpanzer
|
||||
item.steel_shovel.name=Stahlschaufel
|
||||
item.steel_sword.name=Stahlschwert
|
||||
item.stick_dynamite.name=Stange Dynamit
|
||||
item.stick_tnt.name=Stange TNT
|
||||
item.stopsign.name=Stopschild-Streitaxt
|
||||
item.sulfur.name=Schwefel
|
||||
item.survey_scanner.name=Tiefenscanner
|
||||
|
||||
@ -2927,6 +2927,7 @@ item.steel_plate.name=Steel Chestplate
|
||||
item.steel_shovel.name=Steel Shovel
|
||||
item.steel_sword.name=Steel Sword
|
||||
item.stick_dynamite.name=Stick of Dynamite
|
||||
item.stick_tnt.name=Stick of TNT
|
||||
item.stopsign.name=Stop Sign Battle Axe
|
||||
item.sulfur.name=Sulfur
|
||||
item.survey_scanner.name=Survey Scanner
|
||||
|
||||
BIN
src/main/resources/assets/hbm/textures/items/stick_tnt.png
Normal file
BIN
src/main/resources/assets/hbm/textures/items/stick_tnt.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 242 B |
Loading…
x
Reference in New Issue
Block a user