block of dynamite, classic TNT baseclass, cracking rec for crack diesel

This commit is contained in:
Boblet 2022-02-09 16:15:03 +01:00
parent ae2e169609
commit 68ed3f1d36
16 changed files with 343 additions and 10 deletions

View File

@ -485,6 +485,7 @@ public class ModBlocks {
public static Block crashed_balefire;
public static Block rejuvinator;
public static Block fireworks;
public static Block dynamite;
public static Block charge_dynamite;
public static Block charge_miner;
@ -1697,6 +1698,7 @@ public class ModBlocks {
mine_he = new Landmine(Material.iron).setBlockName("mine_he").setCreativeTab(MainRegistry.nukeTab).setHardness(1.0F).setBlockTextureName(RefStrings.MODID + ":mine_he");
mine_shrap = new Landmine(Material.iron).setBlockName("mine_shrap").setCreativeTab(MainRegistry.nukeTab).setHardness(1.0F).setBlockTextureName(RefStrings.MODID + ":mine_shrap");
mine_fat = new Landmine(Material.iron).setBlockName("mine_fat").setCreativeTab(MainRegistry.nukeTab).setHardness(1.0F).setBlockTextureName(RefStrings.MODID + ":mine_fat");
dynamite = new BlockDynamite().setBlockName("dynamite").setCreativeTab(MainRegistry.nukeTab).setHardness(1.0F).setBlockTextureName(RefStrings.MODID + ":dynamite");
machine_difurnace_off = new MachineDiFurnace(false).setBlockName("machine_difurnace_off").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
machine_difurnace_on = new MachineDiFurnace(true).setBlockName("machine_difurnace_on").setHardness(5.0F).setLightLevel(1.0F).setResistance(10.0F);

View File

@ -0,0 +1,13 @@
package com.hbm.blocks.bomb;
import com.hbm.entity.item.EntityTNTPrimedBase;
import net.minecraft.world.World;
public class BlockDynamite extends BlockTNTBase {
@Override
public void explodeEntity(World world, double x, double y, double z, EntityTNTPrimedBase entity) {
world.createExplosion(entity, x, y, z, 8F, true);
}
}

View File

@ -0,0 +1,125 @@
package com.hbm.blocks.bomb;
import java.util.Random;
import com.hbm.entity.item.EntityTNTPrimedBase;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Items;
import net.minecraft.util.IIcon;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
public abstract class BlockTNTBase extends Block {
@SideOnly(Side.CLIENT)
private IIcon topIcon;
@SideOnly(Side.CLIENT)
private IIcon bottomIcon;
public BlockTNTBase() {
super(Material.tnt);
this.setCreativeTab(CreativeTabs.tabRedstone);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return side == 0 ? this.bottomIcon : (side == 1 ? this.topIcon : this.blockIcon);
}
@Override
public void onBlockAdded(World world, int x, int y, int z) {
super.onBlockAdded(world, x, y, z);
if(world.isBlockIndirectlyGettingPowered(x, y, z)) {
this.onBlockDestroyedByPlayer(world, x, y, z, 1);
world.setBlockToAir(x, y, z);
}
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
if(world.isBlockIndirectlyGettingPowered(x, y, z)) {
this.onBlockDestroyedByPlayer(world, x, y, z, 1);
world.setBlockToAir(x, y, z);
}
}
@Override
public int quantityDropped(Random p_149745_1_) {
return 1;
}
@Override
public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) {
if(!world.isRemote) {
EntityTNTPrimedBase entitytntprimed = new EntityTNTPrimedBase(world, x + 0.5D, y + 0.5D, z + 0.5D, explosion.getExplosivePlacedBy(), this);
entitytntprimed.fuse = world.rand.nextInt(entitytntprimed.fuse / 4) + entitytntprimed.fuse / 8;
world.spawnEntityInWorld(entitytntprimed);
}
}
@Override
public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int meta) {
this.prime(world, x, y, z, meta, (EntityLivingBase) null);
}
public void prime(World world, int x, int y, int z, int meta, EntityLivingBase living) {
if(!world.isRemote) {
if((meta & 1) == 1) {
EntityTNTPrimedBase entitytntprimed = new EntityTNTPrimedBase(world, x + 0.5D, y + 0.5D, z + 0.5D, living, this);
world.spawnEntityInWorld(entitytntprimed);
world.playSoundAtEntity(entitytntprimed, "game.tnt.primed", 1.0F, 1.0F);
}
}
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.flint_and_steel) {
this.prime(world, x, y, z, 1, player);
world.setBlockToAir(x, y, z);
player.getCurrentEquippedItem().damageItem(1, player);
return true;
} else {
return super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ);
}
}
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
if(entity instanceof EntityArrow && !world.isRemote) {
EntityArrow entityarrow = (EntityArrow) entity;
if(entityarrow.isBurning()) {
this.prime(world, x, y, z, 1, entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase) entityarrow.shootingEntity : null);
world.setBlockToAir(x, y, z);
}
}
}
@Override
public boolean canDropFromExplosion(Explosion explosion) {
return false;
}
public abstract void explodeEntity(World world, double x, double y, double z, EntityTNTPrimedBase entity);
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister p_149651_1_) {
this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side");
this.topIcon = p_149651_1_.registerIcon(this.getTextureName() + "_top");
this.bottomIcon = p_149651_1_.registerIcon(this.getTextureName() + "_bottom");
}
}

View File

@ -0,0 +1,114 @@
package com.hbm.entity.item;
import com.hbm.blocks.bomb.BlockTNTBase;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
public class EntityTNTPrimedBase extends Entity {
public int fuse;
private EntityLivingBase tntPlacedBy;
public BlockTNTBase bomb;
public EntityTNTPrimedBase(World world) {
super(world);
this.preventEntitySpawning = true;
this.setSize(0.98F, 0.98F);
this.yOffset = this.height / 2.0F;
}
public EntityTNTPrimedBase(World world, double x, double y, double z, EntityLivingBase entity, BlockTNTBase bomb) {
this(world);
this.setPosition(x, y, z);
float f = (float) (Math.random() * Math.PI * 2.0D);
this.motionX = (double) (-((float) Math.sin((double) f)) * 0.02F);
this.motionY = 0.2D;
this.motionZ = (double) (-((float) Math.cos((double) f)) * 0.02F);
this.fuse = 80;
this.prevPosX = x;
this.prevPosY = y;
this.prevPosZ = z;
this.tntPlacedBy = entity;
this.bomb = bomb;
}
@Override
protected void entityInit() { }
@Override
protected boolean canTriggerWalking() {
return false;
}
@Override
public boolean canBeCollidedWith() {
return !this.isDead;
}
@Override
public void onUpdate() {
if(bomb == null) {
this.setDead();
return;
}
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.motionY -= 0.04D;
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.98D;
this.motionY *= 0.98D;
this.motionZ *= 0.98D;
if(this.onGround) {
this.motionX *= 0.7D;
this.motionZ *= 0.7D;
this.motionY *= -0.5D;
}
if(this.fuse-- <= 0) {
this.setDead();
if(!this.worldObj.isRemote) {
this.explode();
}
} else {
this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
}
}
private void explode() {
this.bomb.explodeEntity(worldObj, posX, posZ, posZ, this);
}
@Override
protected void writeEntityToNBT(NBTTagCompound nbt) {
nbt.setByte("Fuse", (byte) this.fuse);
nbt.setInteger("Tile", Block.getIdFromBlock(bomb));
}
@Override
protected void readEntityFromNBT(NBTTagCompound nbt) {
this.fuse = nbt.getByte("Fuse");
this.bomb = (BlockTNTBase) Block.getBlockById(nbt.getInteger("Tile"));
}
@Override
@SideOnly(Side.CLIENT)
public float getShadowSize() {
return 0.0F;
}
public EntityLivingBase getTntPlacedBy() {
return this.tntPlacedBy;
}
}

View File

@ -934,7 +934,7 @@ public class AssemblerRecipes {
new OreDictStack(ANY_CONCRETE.any(), 8),
new OreDictStack(NB.ingot(), 2),
new OreDictStack(AL.plate(), 12),
new OreDictStack(ANY_TAR.any(), 8),
new OreDictStack(ANY_PLASTIC.ingot(), 4),
new ComparableStack(ModItems.hull_big_steel, 3),
new ComparableStack(ModItems.catalyst_clay, 4),
new ComparableStack(ModItems.coil_copper, 4),

View File

@ -110,12 +110,13 @@ public class RefineryRecipes {
}
public static void registerCracking() {
cracking.put(Fluids.OIL, new Pair(new FluidStack(Fluids.CRACKOIL, oil_crack_oil), new FluidStack(Fluids.PETROLEUM, oil_crack_petro)));
cracking.put(Fluids.BITUMEN, new Pair(new FluidStack(Fluids.OIL, bitumen_crack_oil), new FluidStack(Fluids.AROMATICS, bitumen_crack_aroma)));
cracking.put(Fluids.SMEAR, new Pair(new FluidStack(Fluids.NAPHTHA, smear_crack_napht), new FluidStack(Fluids.PETROLEUM, smear_crack_petro)));
cracking.put(Fluids.GAS, new Pair(new FluidStack(Fluids.PETROLEUM, gas_crack_petro), new FluidStack(Fluids.UNSATURATEDS, gas_crack_unsat)));
cracking.put(Fluids.DIESEL, new Pair(new FluidStack(Fluids.KEROSENE, diesel_crack_kero), new FluidStack(Fluids.PETROLEUM, diesel_crack_petro)));
cracking.put(Fluids.KEROSENE, new Pair(new FluidStack(Fluids.PETROLEUM, kero_crack_petro), new FluidStack(Fluids.NONE, 0)));
cracking.put(Fluids.OIL, new Pair(new FluidStack(Fluids.CRACKOIL, oil_crack_oil), new FluidStack(Fluids.PETROLEUM, oil_crack_petro)));
cracking.put(Fluids.BITUMEN, new Pair(new FluidStack(Fluids.OIL, bitumen_crack_oil), new FluidStack(Fluids.AROMATICS, bitumen_crack_aroma)));
cracking.put(Fluids.SMEAR, new Pair(new FluidStack(Fluids.NAPHTHA, smear_crack_napht), new FluidStack(Fluids.PETROLEUM, smear_crack_petro)));
cracking.put(Fluids.GAS, new Pair(new FluidStack(Fluids.PETROLEUM, gas_crack_petro), new FluidStack(Fluids.UNSATURATEDS, gas_crack_unsat)));
cracking.put(Fluids.DIESEL, new Pair(new FluidStack(Fluids.KEROSENE, diesel_crack_kero), new FluidStack(Fluids.PETROLEUM, diesel_crack_petro)));
cracking.put(Fluids.DIESEL_CRACK, new Pair(new FluidStack(Fluids.KEROSENE, diesel_crack_kero), new FluidStack(Fluids.PETROLEUM, diesel_crack_petro)));
cracking.put(Fluids.KEROSENE, new Pair(new FluidStack(Fluids.PETROLEUM, kero_crack_petro), new FluidStack(Fluids.NONE, 0)));
}
public static Quintet<FluidStack, FluidStack, FluidStack, FluidStack, ItemStack> getRefinery(FluidType oil) {

View File

@ -41,9 +41,7 @@ import com.hbm.blocks.generic.BlockBobble.TileEntityBobble;
import com.hbm.blocks.generic.BlockLoot.TileEntityLoot;
import com.hbm.entity.effect.*;
import com.hbm.entity.grenade.*;
import com.hbm.entity.item.EntityFireworks;
import com.hbm.entity.item.EntityMinecartTest;
import com.hbm.entity.item.EntityMovingItem;
import com.hbm.entity.item.*;
import com.hbm.entity.logic.*;
import com.hbm.entity.missile.*;
import com.hbm.entity.mob.*;
@ -575,6 +573,7 @@ public class ClientProxy extends ServerProxy {
RenderingRegistry.registerEntityRenderingHandler(EntityMinecartTest.class, new RenderMinecartTest());
//items
RenderingRegistry.registerEntityRenderingHandler(EntityMovingItem.class, new RenderMovingItem());
RenderingRegistry.registerEntityRenderingHandler(EntityTNTPrimedBase.class, new RenderTNTPrimedBase());
//mobs
RenderingRegistry.registerEntityRenderingHandler(EntityNuclearCreeper.class, new RenderNuclearCreeper());
RenderingRegistry.registerEntityRenderingHandler(EntityTaintedCreeper.class, new RenderTaintedCreeper());

View File

@ -468,6 +468,7 @@ public class CraftingManager {
addRecipeAuto(new ItemStack(ModBlocks.emp_bomb, 1), new Object[] { "LML", "LCL", "LML", 'L', PB.plate(), 'M', ModItems.magnetron, 'C', ModItems.circuit_gold });
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(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() });

View File

@ -480,6 +480,7 @@ public class MainRegistry {
EntityRegistry.registerModEntity(EntityGrenadeDynamite.class, "entity_grenade_dynamite", 163, this, 250, 1, true);
EntityRegistry.registerModEntity(EntitySiegeLaser.class, "entity_ntm_siege_laser", 164, this, 1000, 1, true);
EntityRegistry.registerModEntity(EntitySiegeDropship.class, "entity_ntm_siege_dropship", 165, this, 1000, 1, true);
EntityRegistry.registerModEntity(EntityTNTPrimedBase.class, "entity_ntm_tnt_primed", 166, this, 1000, 1, true);
EntityRegistry.registerGlobalEntityID(EntityNuclearCreeper.class, "entity_mob_nuclear_creeper", EntityRegistry.findGlobalUniqueEntityId(), 0x204131, 0x75CE00);
EntityRegistry.registerGlobalEntityID(EntityTaintedCreeper.class, "entity_mob_tainted_creeper", EntityRegistry.findGlobalUniqueEntityId(), 0x813b9b, 0xd71fdd);

View File

@ -0,0 +1,75 @@
package com.hbm.render.entity.item;
import org.lwjgl.opengl.GL11;
import com.hbm.entity.item.EntityTNTPrimedBase;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.util.ResourceLocation;
public class RenderTNTPrimedBase extends Render {
private RenderBlocks blockRenderer = new RenderBlocks();
public RenderTNTPrimedBase() {
this.shadowSize = 0.5F;
}
public void doRender(EntityTNTPrimedBase tnt, double x, double y, double z, float f0, float f1) {
GL11.glPushMatrix();
GL11.glTranslatef((float) x, (float) y, (float) z);
float f2;
if((float) tnt.fuse - f1 + 1.0F < 10.0F) {
f2 = 1.0F - ((float) tnt.fuse - f1 + 1.0F) / 10.0F;
if(f2 < 0.0F) {
f2 = 0.0F;
}
if(f2 > 1.0F) {
f2 = 1.0F;
}
f2 *= f2;
f2 *= f2;
float scale = 1.0F + f2 * 0.3F;
GL11.glScalef(scale, scale, scale);
}
f2 = (1.0F - ((float) tnt.fuse - f1 + 1.0F) / 100.0F) * 0.8F;
this.bindEntityTexture(tnt);
this.blockRenderer.renderBlockAsItem(tnt.bomb, 0, tnt.getBrightness(f1));
if(tnt.fuse / 5 % 2 == 0) {
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA);
GL11.glColor4f(1.0F, 1.0F, 1.0F, f2);
this.blockRenderer.renderBlockAsItem(tnt.bomb, 0, 1.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
GL11.glPopMatrix();
}
protected ResourceLocation getEntityTexture(EntityTNTPrimedBase tnt) {
return TextureMap.locationBlocksTexture;
}
protected ResourceLocation getEntityTexture(Entity entity) {
return this.getEntityTexture((EntityTNTPrimedBase) entity);
}
public void doRender(Entity entity, double x, double y, double z, float f0, float f1) {
this.doRender((EntityTNTPrimedBase) entity, x, y, z, f0, f1);
}
}

View File

@ -3079,6 +3079,7 @@ tile.ducrete_smooth.name=Ducrete
tile.dummy_block.name=Dummyblock
tile.dummy_port.name=Dummyblock (Stromanschluss)
tile.dungeon_chain.name=Metallkette
tile.dynamite.name=Dynamit
tile.emp_bomb.name=EMP-Ladung
tile.factory_advanced_conductor.name=Fortgeschrittener Fabriksstromanschluss
tile.factory_advanced_core.name=Fortgeschrittene Fabrikkernkomponente

View File

@ -3405,6 +3405,7 @@ tile.ducrete_smooth.name=Ducrete
tile.dummy_block.name=Dummy Block
tile.dummy_port.name=Dummy Block (Electricity Port)
tile.dungeon_chain.name=Metal Chain
tile.dynamite.name=Dynamite
tile.emp_bomb.name=EMP Device
tile.factory_advanced_conductor.name=Advanced Factory Electricity Port
tile.factory_advanced_core.name=Advanced Factory Core Component

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 446 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 330 B