Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package TheMod;
- import net.minecraft.block.Block;
- import net.minecraft.block.BlockTNT;
- import net.minecraft.block.material.Material;
- import net.minecraft.block.properties.PropertyBool;
- import net.minecraft.block.state.IBlockState;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.resources.model.ModelResourceLocation;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.item.Item;
- import net.minecraft.util.BlockPos;
- import net.minecraft.world.Explosion;
- import net.minecraft.world.World;
- import net.minecraftforge.client.model.ModelLoader;
- import net.minecraftforge.fml.common.registry.GameRegistry;
- public class TNT extends BlockTNT {
- public static final PropertyBool EXPLODE = PropertyBool.create("explode");
- public TNT(String name, Material tnt)
- {
- super();
- this.setDefaultState(this.blockState.getBaseState().withProperty(EXPLODE, Boolean.valueOf(false)));
- this.setCreativeTab(Main.tabTheMod);
- this.setHardness(blockHardness);
- this.setStepSound(Block.soundTypeGrass);
- this.setUnlocalizedName(name);
- System.out.println("INITIALIZING BLOCK: " + name);
- GameRegistry.registerBlock(this, name);
- }
- public void RegisterRenderer(String modelName)
- {
- System.out.println("REGISTERING BLOCK RENDERER: " + modelName);
- ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(Main.Nuke), 0, new ModelResourceLocation(Main.MODID+":"+modelName, "inventory"));
- Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(Main.Nuke), 0, new ModelResourceLocation(Main.MODID+":"+modelName, "inventory"));
- }
- public void onBlockDestroyedByExplosion(World worldIn, BlockPos pos, Explosion explosionIn) {
- if (!worldIn.isRemote) {
- EntityNukePrimed Nuke = new EntityNukePrimed(worldIn, (double) ((float) pos.getX() + 0.5F), (double) pos.getY(), (double) ((float) pos.getZ() + 0.5F), explosionIn.getExplosivePlacedBy());
- Nuke.fuse = worldIn.rand.nextInt(Nuke.fuse / 4) + Nuke.fuse / 8;
- worldIn.spawnEntityInWorld(Nuke);
- }
- }
- public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
- {
- if (worldIn.isBlockPowered(pos))
- {
- this.onBlockDestroyedByPlayer(worldIn, pos, state.withProperty(EXPLODE, Boolean.valueOf(true)));
- worldIn.setBlockToAir(pos);
- }
- }
- public void explode(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase igniter) {
- if (!worldIn.isRemote) {
- if (((Boolean) state.getValue(EXPLODE)).booleanValue()) {
- EntityNukePrimed Nuke = new EntityNukePrimed(worldIn, (double) ((float) pos.getX() + 0.5F), (double) pos.getY(), (double) ((float) pos.getZ() + 0.5F), igniter);
- worldIn.spawnEntityInWorld(Nuke);
- worldIn.playSoundAtEntity(Nuke, "game.tnt.primed", 1.0F, 1.0F);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement