Merge pull request #2052 from Lazzzycatwastaken/zg

Naval mine updat
This commit is contained in:
HbmMods 2025-04-06 23:00:46 +02:00 committed by GitHub
commit 097907820b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 94 additions and 6 deletions

View File

@ -6,11 +6,7 @@ import com.hbm.blocks.ModBlocks;
import com.hbm.config.ServerConfig;
import com.hbm.explosion.ExplosionLarge;
import com.hbm.explosion.vanillant.ExplosionVNT;
import com.hbm.explosion.vanillant.standard.BlockAllocatorStandard;
import com.hbm.explosion.vanillant.standard.BlockProcessorStandard;
import com.hbm.explosion.vanillant.standard.EntityProcessorCrossSmooth;
import com.hbm.explosion.vanillant.standard.ExplosionEffectWeapon;
import com.hbm.explosion.vanillant.standard.PlayerProcessorStandard;
import com.hbm.explosion.vanillant.standard.*;
import com.hbm.interfaces.IBomb;
import com.hbm.items.ModItems;
import com.hbm.items.weapon.sedna.factory.XFactoryCatapult;
@ -179,7 +175,7 @@ public class Landmine extends BlockContainer implements IBomb {
ExplosionLarge.spawnShrapnels(world, x + 0.5, y + 0.5, z + 0.5, 5);
} else if(this == ModBlocks.mine_naval) {
ExplosionVNT vnt = new ExplosionVNT(world, x + 5, y + 5, z + 5, 25F);
vnt.setBlockAllocator(new BlockAllocatorStandard(64));
vnt.setBlockAllocator(new BlockAllocatorWater(32));
vnt.setBlockProcessor(new BlockProcessorStandard());
vnt.setEntityProcessor(new EntityProcessorCrossSmooth(0.5, ServerConfig.MINE_NAVAL_DAMAGE.get()).setupPiercing(5F, 0.2F));
vnt.setPlayerProcessor(new PlayerProcessorStandard());

View File

@ -0,0 +1,78 @@
package com.hbm.explosion.vanillant.standard;
import java.util.HashSet;
import com.hbm.explosion.vanillant.ExplosionVNT;
import com.hbm.explosion.vanillant.interfaces.IBlockAllocator;
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;
public class BlockAllocatorWater implements IBlockAllocator {
protected int resolution;
public BlockAllocatorWater(int resolution) {
this.resolution = resolution;
}
@Override
public HashSet<ChunkPosition> allocate(ExplosionVNT explosion, World world, double x, double y, double z, float size) {
HashSet<ChunkPosition> affectedBlocks = new HashSet<>();
for (int i = 0; i < this.resolution; ++i) {
for (int j = 0; j < this.resolution; ++j) {
for (int k = 0; k < this.resolution; ++k) {
if (i == 0 || i == this.resolution - 1 || j == 0 || j == this.resolution - 1 || k == 0 || k == this.resolution - 1) {
double d0 = (float) i / ((float) this.resolution - 1.0F) * 2.0F - 1.0F;
double d1 = (float) j / ((float) this.resolution - 1.0F) * 2.0F - 1.0F;
double d2 = (float) k / ((float) this.resolution - 1.0F) * 2.0F - 1.0F;
double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
d0 /= d3;
d1 /= d3;
d2 /= d3;
float powerRemaining = size * (0.7F + world.rand.nextFloat() * 0.6F);
double currentX = x;
double currentY = y;
double currentZ = z;
for (float stepSize = 0.3F; powerRemaining > 0.0F; powerRemaining -= stepSize * 0.75F) {
int blockX = MathHelper.floor_double(currentX);
int blockY = MathHelper.floor_double(currentY);
int blockZ = MathHelper.floor_double(currentZ);
Block block = world.getBlock(blockX, blockY, blockZ);
Material material = block.getMaterial();
// im braindead and copy code 🧃🐱👤
if (material != Material.air && !material.isLiquid()) {
float blockResistance = explosion.exploder != null ?
explosion.exploder.func_145772_a(explosion.compat, world, blockX, blockY, blockZ, block) :
block.getExplosionResistance(null, world, blockX, blockY, blockZ, x, y, z);
powerRemaining -= (blockResistance + 0.3F) * stepSize;
}
if (powerRemaining > 0.0F &&
(explosion.exploder == null || explosion.exploder.func_145774_a(explosion.compat, world, blockX, blockY, blockZ, block, powerRemaining)) &&
!material.isLiquid()) {
affectedBlocks.add(new ChunkPosition(blockX, blockY, blockZ));
}
currentX += d0 * (double) stepSize;
currentY += d1 * (double) stepSize;
currentZ += d2 * (double) stepSize;
}
}
}
}
}
return affectedBlocks;
}
}

View File

@ -509,6 +509,20 @@ public class ItemRenderLibrary {
GL11.glEnable(GL11.GL_CULL_FACE);
}});
renderers.put(Item.getItemFromBlock(ModBlocks.mine_naval), new ItemRenderBase() {
public void renderInventory() {
GL11.glTranslated(0, 2, -1);
GL11.glScaled(5, 5, 5);
}
public void renderCommon() {
GL11.glTranslated(0, 0, 0);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glShadeModel(GL11.GL_SMOOTH);
bindTexture(ResourceManager.mine_naval_tex);
ResourceManager.mine_naval.renderAll();
GL11.glEnable(GL11.GL_CULL_FACE);
}});
renderers.put(Item.getItemFromBlock(ModBlocks.mine_fat), new ItemRenderBase() {
public void renderInventory() {
GL11.glTranslated(0, -1, 0);