mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
plug and play graphite drilling funsies
This commit is contained in:
parent
7a80e8d74f
commit
73fb241c2c
@ -8,6 +8,7 @@ import com.hbm.blocks.gas.*;
|
||||
import com.hbm.blocks.machine.*;
|
||||
import com.hbm.blocks.machine.pile.BlockGraphite;
|
||||
import com.hbm.blocks.machine.pile.BlockGraphiteDrilled;
|
||||
import com.hbm.blocks.machine.pile.BlockGraphiteRod;
|
||||
import com.hbm.blocks.machine.rbmk.*;
|
||||
import com.hbm.blocks.network.*;
|
||||
import com.hbm.blocks.test.*;
|
||||
@ -1355,7 +1356,10 @@ public class ModBlocks {
|
||||
block_fallout = new BlockHazardFalling().addRadiation(ItemHazard.fo * ItemHazard.block).toBlock().setStepSound(Block.soundTypeGravel).setBlockName("block_fallout").setCreativeTab(MainRegistry.blockTab).setHardness(0.2F).setBlockTextureName(RefStrings.MODID + ":ash");
|
||||
block_foam = new BlockGeneric(Material.craftedSnow).setBlockName("block_foam").setCreativeTab(MainRegistry.blockTab).setStepSound(Block.soundTypeSnow).setHardness(0.5F).setResistance(0.0F).setBlockTextureName(RefStrings.MODID + ":foam");
|
||||
block_graphite = new BlockGraphite(Material.iron, 30, 5).setBlockName("block_graphite").setCreativeTab(MainRegistry.blockTab).setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F);
|
||||
block_graphite_drilled = new BlockGraphiteDrilled(Material.iron, 30, 5).setBlockName("block_graphite_drilled").setCreativeTab(null).setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":block_graphite");
|
||||
block_graphite_drilled = new BlockGraphiteDrilled(Material.iron, 30, 5).setBlockName("block_graphite_drilled").setCreativeTab(null).setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F);
|
||||
block_graphite_fuel = new BlockGraphiteDrilled(Material.iron, 30, 5).setBlockName("block_graphite_fuel").setCreativeTab(null).setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F);
|
||||
block_graphite_rod = new BlockGraphiteRod(Material.iron, 30, 5).setBlockName("block_graphite_rod").setCreativeTab(null).setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F);
|
||||
block_graphite_source = new BlockGraphiteDrilled(Material.iron, 30, 5).setBlockName("block_graphite_source").setCreativeTab(null).setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F);
|
||||
block_boron = new BlockBeaconable(Material.iron).setBlockName("block_boron").setCreativeTab(MainRegistry.blockTab).setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":block_boron");
|
||||
block_lanthanium = new BlockBeaconable(Material.iron).setBlockName("block_lanthanium").setCreativeTab(MainRegistry.blockTab).setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":block_lanthanium");
|
||||
block_actinium = new BlockBeaconable(Material.iron).setBlockName("block_actinium").setCreativeTab(MainRegistry.blockTab).setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":block_actinium");
|
||||
@ -2277,6 +2281,9 @@ public class ModBlocks {
|
||||
GameRegistry.registerBlock(block_foam, block_foam.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(block_graphite, block_graphite.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(block_graphite_drilled, block_graphite_drilled.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(block_graphite_fuel, block_graphite_fuel.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(block_graphite_rod, block_graphite_rod.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(block_graphite_source, block_graphite_source.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(block_boron, block_boron.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(block_insulator, block_insulator.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(block_fiberglass, block_fiberglass.getUnlocalizedName());
|
||||
|
||||
@ -33,13 +33,8 @@ public class BlockGraphite extends BlockFlammable implements IToolable {
|
||||
world.setBlock(x, y, z, ModBlocks.block_graphite_drilled, side / 2, 3);
|
||||
PacketDispatcher.wrapper.sendToAllAround(new ParticleBurstPacket(x, y, z, Block.getIdFromBlock(this), 0), new TargetPoint(world.provider.dimensionId, x, y, z, 50));
|
||||
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, this.stepSound.func_150496_b(), (this.stepSound.getVolume() + 1.0F) / 2.0F, this.stepSound.getPitch() * 0.8F);
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(side);
|
||||
EntityItem dust = new EntityItem(world, x + 0.5D + dir.offsetX * 0.75D, y + 0.5D + dir.offsetY * 0.75D, z + 0.5D + dir.offsetZ * 0.75D, new ItemStack(ModItems.powder_coal));
|
||||
dust.motionX = dir.offsetX * 0.25;
|
||||
dust.motionY = dir.offsetY * 0.25;
|
||||
dust.motionZ = dir.offsetZ * 0.25;
|
||||
world.spawnEntityInWorld(dust);
|
||||
|
||||
BlockGraphiteRod.ejectItem(world, x, y, z, ForgeDirection.getOrientation(side), new ItemStack(ModItems.powder_coal));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -1,39 +1,53 @@
|
||||
package com.hbm.blocks.machine.pile;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.blocks.generic.BlockFlammable;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.lib.RefStrings;
|
||||
|
||||
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.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockGraphiteDrilled extends BlockFlammable {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon holeIcon;
|
||||
public class BlockGraphiteDrilled extends BlockGraphiteDrilledBase {
|
||||
|
||||
public BlockGraphiteDrilled(Material mat, int en, int flam) {
|
||||
super(mat, en, flam);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
super.registerBlockIcons(iconRegister);
|
||||
this.holeIcon = iconRegister.registerIcon(RefStrings.MODID + ":block_graphite_drilled");
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
|
||||
if(player.getHeldItem() != null) {
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if(checkInteraction(world, x, y, z, meta, player, ModItems.pile_rod_uranium, ModBlocks.block_graphite_fuel)) return true;
|
||||
if(checkInteraction(world, x, y, z, meta, player, ModItems.pile_rod_source, ModBlocks.block_graphite_source)) return true;
|
||||
if(checkInteraction(world, x, y, z, meta, player, ModItems.pile_rod_boron, ModBlocks.block_graphite_rod)) return true;
|
||||
if(checkInteraction(world, x, y, z, 0, player, ModItems.ingot_graphite, ModBlocks.block_graphite)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
private boolean checkInteraction(World world, int x, int y, int z, int meta, EntityPlayer player, Item item, Block block) {
|
||||
|
||||
int cfg = metadata & 4;
|
||||
if(player.getHeldItem().getItem() == item) {
|
||||
player.getHeldItem().stackSize--;
|
||||
world.setBlock(x, y, z, block, meta, 3);
|
||||
|
||||
world.playSoundEffect(x + 0.5, y + 1.5, z + 0.5, "hbm:item.upgradePlug", 1.0F, 1.0F);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if(side == cfg * 2 || side == cfg * 2 + 1)
|
||||
return this.holeIcon;
|
||||
|
||||
return this.blockIcon;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,53 @@
|
||||
package com.hbm.blocks.machine.pile;
|
||||
|
||||
import com.hbm.blocks.generic.BlockFlammable;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.lib.RefStrings;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public abstract class BlockGraphiteDrilledBase extends BlockFlammable {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon sideIcon;
|
||||
|
||||
public BlockGraphiteDrilledBase(Material mat, int en, int flam) {
|
||||
super(mat, en, flam);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
super.registerBlockIcons(iconRegister);
|
||||
this.sideIcon = iconRegister.registerIcon(RefStrings.MODID + ":block_graphite");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
|
||||
int cfg = metadata & 4;
|
||||
|
||||
if(side == cfg * 2 || side == cfg * 2 + 1)
|
||||
return this.blockIcon;
|
||||
|
||||
return this.sideIcon;
|
||||
}
|
||||
|
||||
protected static void ejectItem(World world, int x, int y, int z, ForgeDirection dir, ItemStack stack) {
|
||||
|
||||
EntityItem dust = new EntityItem(world, x + 0.5D + dir.offsetX * 0.75D, y + 0.5D + dir.offsetY * 0.75D, z + 0.5D + dir.offsetZ * 0.75D, stack);
|
||||
dust.motionX = dir.offsetX * 0.25;
|
||||
dust.motionY = dir.offsetY * 0.25;
|
||||
dust.motionZ = dir.offsetZ * 0.25;
|
||||
world.spawnEntityInWorld(dust);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package com.hbm.blocks.machine.pile;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class BlockGraphiteDrilledTE extends BlockGraphiteDrilledBase implements ITileEntityProvider {
|
||||
|
||||
public BlockGraphiteDrilledTE(Material mat, int en, int flam) {
|
||||
super(mat, en, flam);
|
||||
this.isBlockContainer = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
super.onBlockAdded(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block b, int m) {
|
||||
super.breakBlock(world, x, y, z, b, m);
|
||||
world.removeTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public boolean onBlockEventReceived(World world, int x, int y, int z, int i, int j) {
|
||||
super.onBlockEventReceived(world, x, y, z, i, j);
|
||||
TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
return tileentity != null ? tileentity.receiveClientEvent(i, j) : false;
|
||||
}*/ //do we even need this? the TE doesn't implement it, so i guess not
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
package com.hbm.blocks.machine.pile;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.ParticleBurstPacket;
|
||||
|
||||
import api.hbm.block.IToolable;
|
||||
import api.hbm.block.IToolable.ToolType;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockGraphiteRod extends BlockGraphiteDrilledBase implements IToolable {
|
||||
|
||||
public BlockGraphiteRod(Material mat, int en, int flam) {
|
||||
super(mat, en, flam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
|
||||
if(player.isSneaking())
|
||||
return false;
|
||||
|
||||
if(world.isRemote)
|
||||
return true;
|
||||
|
||||
int oldMeta = world.getBlockMetadata(x, y, z);
|
||||
int newMeta = oldMeta ^ 4; //toggle bit #3
|
||||
int pureMeta = oldMeta & 4; //in case the bit was set
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, newMeta, 3);
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(pureMeta);
|
||||
|
||||
if(dir == ForgeDirection.UNKNOWN)
|
||||
return true;
|
||||
|
||||
for(int i = -1; i <= 1; i += 1) {
|
||||
|
||||
int ix = x + dir.offsetX * i;
|
||||
int iy = y + dir.offsetY * i;
|
||||
int iz = z + dir.offsetZ * i;
|
||||
|
||||
while(world.getBlock(ix, iy, iz) == this && world.getBlockMetadata(ix, iy, iz) == oldMeta) {
|
||||
|
||||
world.setBlockMetadataWithNotify(ix, iy, iz, newMeta, 3);
|
||||
|
||||
ix += dir.offsetX * i;
|
||||
iy += dir.offsetY * i;
|
||||
iz += dir.offsetZ * i;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
||||
|
||||
if(tool != ToolType.SCREWDRIVER)
|
||||
return false;
|
||||
|
||||
if(!world.isRemote) {
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z) & 4;
|
||||
world.setBlock(x, y, z, ModBlocks.block_graphite_drilled, meta, 3);
|
||||
this.ejectItem(world, x, y, z, ForgeDirection.getOrientation(side), new ItemStack(ModItems.pile_rod_boron));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user