some fixes, finalized ExVNT code

This commit is contained in:
Boblet 2022-03-08 16:36:57 +01:00
parent 47be4e97b6
commit 70299728da
8 changed files with 80 additions and 56 deletions

View File

@ -1,7 +1,6 @@
package com.hbm.blocks.bomb;
import com.hbm.explosion.ExplosionLarge;
import com.hbm.explosion.ExplosionNT;
import com.hbm.explosion.vanillant.ExplosionVNT;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.world.World;
@ -15,9 +14,9 @@ public class BlockChargeC4 extends BlockChargeBase {
safe = true;
world.setBlockToAir(x, y, z);
safe = false;
ExplosionNT exp = new ExplosionNT(world, null, x + 0.5, y + 0.5, z + 0.5, 4F);
exp.explode();
ExplosionLarge.spawnParticles(world, x + 0.5, y + 0.5, z + 0.5, 20);
ExplosionVNT xnt = new ExplosionVNT(world, x + 0.5, y + 0.5, z + 0.5, 10F).makeStandard();
xnt.explode();
return BombReturnCode.DETONATED;
}

View File

@ -56,7 +56,7 @@ public class EntityMinerRocket extends Entity {
if(dataWatcher.getWatchableObjectInt(16) == 1) {
if(ticksExisted % 2 == 0)
if(!worldObj.isRemote && ticksExisted % 4 == 0)
ExplosionLarge.spawnShock(worldObj, posX, posY, posZ, 1 + rand.nextInt(3), 1 + rand.nextGaussian());
timer++;

View File

@ -10,6 +10,7 @@ import net.minecraft.entity.EntityLeashKnot;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.boss.IBossDisplayData;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
@ -148,6 +149,12 @@ public class EntityQuackos extends EntityDuck implements IBossDisplayData {
}
}
/**
* BOW
*/
@Override
public void onDeath(DamageSource sourceOrRatherLackThereof) { }
@Override
protected void updateLeashedState() {

View File

@ -11,11 +11,24 @@ import net.minecraft.world.World;
public class BlockProcessorStandard implements IBlockProcessor {
protected IDropChanceMutator chance;
protected IFortuneMutator fortune;
protected IBlockMutator convert;
public BlockProcessorStandard() { }
public BlockProcessorStandard(IDropChanceMutator chance) {
public BlockProcessorStandard withChance(IDropChanceMutator chance) {
this.chance = chance;
return this;
}
public BlockProcessorStandard withFortune(IFortuneMutator fortune) {
this.fortune = fortune;
return this;
}
public BlockProcessorStandard withBlockEffect(IBlockMutator convert) {
this.convert = convert;
return this;
}
@Override
@ -23,27 +36,46 @@ public class BlockProcessorStandard implements IBlockProcessor {
Iterator iterator = affectedBlocks.iterator();
float dropChance = 1.0F / explosion.size;
while(iterator.hasNext()) {
ChunkPosition chunkposition = (ChunkPosition) iterator.next();
int blockX = chunkposition.chunkPosX;
int blockY = chunkposition.chunkPosY;
int blockZ = chunkposition.chunkPosZ;
Block block = world.getBlock(blockX, blockY, blockZ);
if(block.getMaterial() != Material.air) {
if(block.canDropFromExplosion(null)) {
if(chance != null) {
dropChance = chance.mutateDropChance(explosion, block, blockX, blockY, blockZ, dropChance);
}
block.dropBlockAsItemWithChance(world, blockX, blockY, blockZ, world.getBlockMetadata(blockX, blockY, blockZ), dropChance, 0);
int dropFortune = fortune == null ? 0 : fortune.mutateFortune(explosion, block, blockX, blockY, blockZ);
block.dropBlockAsItemWithChance(world, blockX, blockY, blockZ, world.getBlockMetadata(blockX, blockY, blockZ), dropChance, dropFortune);
}
block.onBlockExploded(world, blockX, blockY, blockZ, null);
}
}
if(this.convert != null) {
iterator = affectedBlocks.iterator();
while(iterator.hasNext()) {
ChunkPosition chunkposition = (ChunkPosition) iterator.next();
int blockX = chunkposition.chunkPosX;
int blockY = chunkposition.chunkPosY;
int blockZ = chunkposition.chunkPosZ;
Block block = world.getBlock(blockX, blockY, blockZ);
if(block.getMaterial() == Material.air) {
this.convert.mutateAtPosition(explosion, blockX, blockY, blockZ);
}
}
}
}
public BlockProcessorStandard setNoDrop() {

View File

@ -32,7 +32,7 @@ public class ExplosionVNT {
protected float size;
public Entity exploder;
public Explosion compat;
public Explosion compat; //TODO: override and implement getters for the EVNT's data
public ExplosionVNT(World world, double x, double y, double z, float size) {
this(world, x, y, z, size, null);
@ -55,13 +55,13 @@ public class ExplosionVNT {
boolean processEntities = entityProcessor != null && playerProcessor != null;
HashSet<ChunkPosition> affectedBlocks = null;
HashMap<EntityPlayer, Vec3> affectedEntities = null;
HashMap<EntityPlayer, Vec3> affectedPlayers = null;
if(processBlocks) affectedBlocks = blockAllocator.allocate(this, world, posX, posY, posZ, size);
if(processEntities) affectedEntities = entityProcessor.process(this, world, posX, posY, posZ, size);
if(processEntities) affectedPlayers = entityProcessor.process(this, world, posX, posY, posZ, size);
if(processBlocks) blockProcessor.process(this, world, posX, posY, posZ, affectedBlocks);
if(processEntities) playerProcessor.process(this, world, posX, posY, posZ, affectedEntities);
if(processEntities) playerProcessor.process(this, world, posX, posY, posZ, affectedPlayers);
if(sfx != null) {
for(IExplosionSFX fx : sfx) {
@ -90,4 +90,12 @@ public class ExplosionVNT {
this.sfx = sfx;
return this;
}
public ExplosionVNT makeStandard() {
this.setBlockAllocator(new BlockAllocatorStandard());
this.setBlockProcessor(new BlockProcessorStandard());
this.setEntityProcessor(new EntityProcessorStandard());
this.setPlayerProcessor(new PlayerProcessorStandard());
return this;
}
}

View File

@ -0,0 +1,6 @@
package com.hbm.explosion.vanillant;
public interface IBlockMutator {
public int mutateAtPosition(ExplosionVNT explosion, int x, int y, int z);
}

View File

@ -0,0 +1,8 @@
package com.hbm.explosion.vanillant;
import net.minecraft.block.Block;
public interface IFortuneMutator {
public int mutateFortune(ExplosionVNT explosion, Block block, int x, int y, int z);
}

View File

@ -1,12 +1,12 @@
package com.hbm.util;
import com.hbm.config.GeneralConfig;
import com.hbm.entity.mob.EntityDuck;
import com.hbm.entity.mob.EntityNuclearCreeper;
import com.hbm.entity.mob.EntityQuackos;
import com.hbm.extprop.HbmLivingProps;
import com.hbm.handler.HazmatRegistry;
import com.hbm.handler.radiation.ChunkRadiationManager;
import com.hbm.lib.ModDamageSource;
import com.hbm.potion.HbmPotion;
import com.hbm.util.ArmorRegistry.HazardClass;
@ -23,7 +23,6 @@ import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ChatStyle;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
public class ContaminationUtil {
@ -44,44 +43,6 @@ public class ContaminationUtil {
return 1;
}
/// RADIATION ///
private static void applyRadData(Entity e, float f) {
if(!(e instanceof EntityLivingBase))
return;
if(isRadImmune(e))
return;
EntityLivingBase entity = (EntityLivingBase)e;
if(e instanceof EntityPlayer && ((EntityPlayer)e).capabilities.isCreativeMode)
return;
if(e instanceof EntityPlayer && e.ticksExisted < 200)
return;
f *= calculateRadiationMod(entity);
HbmLivingProps.incrementRadiation(entity, f);
}
private static void applyRadDirect(Entity e, float f) {
if(!(e instanceof EntityLivingBase))
return;
EntityLivingBase entity = (EntityLivingBase)e;
if(isRadImmune(e))
return;
if(e instanceof EntityPlayer && ((EntityPlayer)e).capabilities.isCreativeMode)
return;
HbmLivingProps.incrementRadiation(entity, f);
}
public static float getRads(Entity e) {
if(!(e instanceof EntityLivingBase))
@ -135,6 +96,9 @@ public class ContaminationUtil {
if(!(e instanceof EntityLivingBase))
return;
if(e instanceof EntityDuck || e instanceof EntityOcelot)
return;
if(e instanceof EntityPlayer && ((EntityPlayer)e).capabilities.isCreativeMode)
return;