Updated newly returned blocks to 1.7

This commit is contained in:
Francesco Macagno 2015-07-22 21:22:43 -07:00
parent f3caf63489
commit 3aa1839115
12 changed files with 338 additions and 419 deletions

View file

@ -173,7 +173,7 @@ public class BlockAir extends Block
}
int xn_blockId = world.getBlockId(x - 1, y, z);
boolean xn_isAir = WarpDriveConfig.isAirBlock(world, xn_blockId, x - 1, y, z);
int xn_concentration = (xn_blockId != this.blockID) ? 0 : world.getBlockMetadata(x - 1, y, z);
int xn_concentration = (xn_blockId != this) ? 0 : world.getBlockMetadata(x - 1, y, z);
if (xn_isAir) {
air_count++;
if (xn_concentration > 0) {
@ -184,7 +184,7 @@ public class BlockAir extends Block
}
int yp_blockId = world.getBlockId(x, y + 1, z);
boolean yp_isAir = WarpDriveConfig.isAirBlock(world, yp_blockId, x, y + 1, z);
int yp_concentration = (yp_blockId != this.blockID) ? 0 : world.getBlockMetadata(x, y + 1, z);
int yp_concentration = (yp_blockId != this) ? 0 : world.getBlockMetadata(x, y + 1, z);
if (yp_isAir) {
air_count++;
if (yp_concentration > 0) {
@ -195,7 +195,7 @@ public class BlockAir extends Block
}
int yn_blockId = world.getBlockId(x, y - 1, z);
boolean yn_isAir = WarpDriveConfig.isAirBlock(world, yn_blockId, x, y - 1, z);
int yn_concentration = (yn_blockId != this.blockID) ? 0 : world.getBlockMetadata(x, y - 1, z);
int yn_concentration = (yn_blockId != this) ? 0 : world.getBlockMetadata(x, y - 1, z);
if (yn_isAir) {
air_count++;
if (yn_concentration > 0) {
@ -206,7 +206,7 @@ public class BlockAir extends Block
}
int zp_blockId = world.getBlockId(x, y, z + 1);
boolean zp_isAir = WarpDriveConfig.isAirBlock(world, zp_blockId, x, y, z + 1);
int zp_concentration = (zp_blockId != this.blockID) ? 0 : world.getBlockMetadata(x, y, z + 1);
int zp_concentration = (zp_blockId != this) ? 0 : world.getBlockMetadata(x, y, z + 1);
if (zp_isAir) {
air_count++;
if (zp_concentration > 0) {
@ -217,7 +217,7 @@ public class BlockAir extends Block
}
int zn_blockId = world.getBlockId(x, y, z - 1);
boolean zn_isAir = WarpDriveConfig.isAirBlock(world, zn_blockId, x, y, z - 1);
int zn_concentration = (zn_blockId != this.blockID) ? 0 : world.getBlockMetadata(x, y, z - 1);
int zn_concentration = (zn_blockId != this) ? 0 : world.getBlockMetadata(x, y, z - 1);
if (zn_isAir) {
air_count++;
if (zn_concentration > 0) {
@ -263,62 +263,62 @@ public class BlockAir extends Block
// Check and setup air to adjacent blocks
if (xp_isAir) {
if (xp_blockId == this.blockID) {
if (xp_blockId == this) {
if (xp_concentration != mid_concentration && xp_concentration != 15) {
world.setBlockMetadataWithNotify(x + 1, y, z, mid_concentration, 2);
}
} else {
world.setBlock(x + 1, y, z, this.blockID, mid_concentration, 2);
world.setBlock(x + 1, y, z, this, mid_concentration, 2);
}
}
if (xn_isAir) {
if (xn_blockId == this.blockID) {
if (xn_blockId == this) {
if (xn_concentration != mid_concentration && xn_concentration != 15) {
world.setBlockMetadataWithNotify(x - 1, y, z, mid_concentration, 2);
}
} else {
world.setBlock(x - 1, y, z, this.blockID, mid_concentration, 2);
world.setBlock(x - 1, y, z, this, mid_concentration, 2);
}
}
if (yp_isAir) {
if (yp_blockId == this.blockID) {
if (yp_blockId == this) {
if (yp_concentration != mid_concentration && yp_concentration != 15) {
world.setBlockMetadataWithNotify(x, y + 1, z, mid_concentration, 2);
}
} else {
world.setBlock(x, y + 1, z, this.blockID, mid_concentration, 2);
world.setBlock(x, y + 1, z, this, mid_concentration, 2);
}
}
if (yn_isAir) {
if (yn_blockId == this.blockID) {
if (yn_blockId == this) {
if (yn_concentration != mid_concentration && yn_concentration != 15) {
world.setBlockMetadataWithNotify(x, y - 1, z, mid_concentration, 2);
}
} else {
world.setBlock(x, y - 1, z, this.blockID, mid_concentration, 2);
world.setBlock(x, y - 1, z, this, mid_concentration, 2);
}
}
if (zp_isAir) {
if (zp_blockId == this.blockID) {
if (zp_blockId == this) {
if (zp_concentration != mid_concentration && zp_concentration != 15) {
world.setBlockMetadataWithNotify(x, y, z + 1, mid_concentration, 2);
}
} else {
world.setBlock(x, y, z + 1, this.blockID, mid_concentration, 2);
world.setBlock(x, y, z + 1, this, mid_concentration, 2);
}
}
if (zn_isAir) {
if (zn_blockId == this.blockID) {
if (zn_blockId == this) {
if (zn_concentration != mid_concentration && zn_concentration != 15) {
world.setBlockMetadataWithNotify(x, y, z - 1, mid_concentration, 2);
}
} else {
world.setBlock(x, y, z - 1, this.blockID, mid_concentration, 2);
world.setBlock(x, y, z - 1, this, mid_concentration, 2);
}
}
}

View file

@ -1,98 +1,86 @@
package cr0s.WarpDrive.block;
package cr0s.warpdrive.block;
import java.util.List;
import cpw.mods.fml.common.registry.GameRegistry;
import cr0s.WarpDrive.WarpDrive;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.util.IIcon;
import net.minecraftforge.oredict.ShapedOreRecipe;
import cpw.mods.fml.common.registry.GameRegistry;
import cr0s.warpdrive.WarpDrive;
public class BlockDecorative extends Block {
public static enum decorativeTypes {
Plain, Energized, Network
};
public class BlockDecorative extends Block
{
public static enum decorativeTypes { Plain , Energized , Network };
private ItemStack[] isCache = new ItemStack[decorativeTypes.values().length];
private Icon[] iconBuffer = new Icon[decorativeTypes.values().length];
public BlockDecorative(int par1)
{
super(par1, Material.iron);
private IIcon[] iconBuffer = new IIcon[decorativeTypes.values().length];
public BlockDecorative() {
super(Material.iron);
setHardness(0.5f);
setStepSound(Block.soundMetalFootstep);
setStepSound(Block.soundTypeMetal);
setCreativeTab(WarpDrive.warpdriveTab);
}
public boolean isValidDamage(int damage)
{
public boolean isValidDamage(int damage) {
return damage >= 0 && damage < decorativeTypes.values().length;
}
@Override
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for(decorativeTypes val: decorativeTypes.values())
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for (decorativeTypes val : decorativeTypes.values())
par3List.add(new ItemStack(par1, 1, val.ordinal()));
}
}
@Override
public void registerIcons(IconRegister ir)
{
for(decorativeTypes val: decorativeTypes.values())
public void registerBlockIcons(IIconRegister ir) {
for (decorativeTypes val : decorativeTypes.values())
iconBuffer[val.ordinal()] = ir.registerIcon("warpdrive:decorative" + val.toString());
}
@Override
public Icon getIcon(int side, int damage)
{
if(isValidDamage(damage))
public IIcon getIcon(int side, int damage) {
if (isValidDamage(damage))
return iconBuffer[damage];
return iconBuffer[0];
}
@Override
public int damageDropped(int damage)
{
public int damageDropped(int damage) {
return damage;
}
public ItemStack getIS(int damage)
{
if(!isValidDamage(damage))
public ItemStack getIS(int damage) {
if (!isValidDamage(damage))
return null;
if(isCache[damage] == null)
if (isCache[damage] == null)
isCache[damage] = getISNoCache(damage);
return isCache[damage];
}
public ItemStack getISNoCache(int damage, int amount)
{
if(!isValidDamage(damage))
public ItemStack getISNoCache(int damage, int amount) {
if (!isValidDamage(damage))
return null;
return new ItemStack(WarpDrive.decorativeBlock,amount,damage);
return new ItemStack(WarpDrive.decorativeBlock, amount, damage);
}
public ItemStack getISNoCache(int damage)
{
return getISNoCache(damage,1);
public ItemStack getISNoCache(int damage) {
return getISNoCache(damage, 1);
}
public void initRecipes()
{
GameRegistry.addRecipe(new ShapedOreRecipe(getISNoCache(0,8),false, "sss","scs","sss",
's', Block.stone,
'c', WarpDrive.componentItem.getIS(0)));
GameRegistry.addRecipe(new ShapedOreRecipe(getISNoCache(2,8),false, "sss","scs","sss",
's', getIS(0),
'c', WarpDrive.componentItem.getIS(5)));
public void initRecipes() {
GameRegistry.addRecipe(new ShapedOreRecipe(getISNoCache(0, 8), false, "sss", "scs", "sss", 's', Blocks.stone, 'c', WarpDrive.componentItem.getIS(0)));
GameRegistry.addRecipe(new ShapedOreRecipe(getISNoCache(2, 8), false, "sss", "scs", "sss", 's', getIS(0), 'c', WarpDrive.componentItem.getIS(5)));
}
}

View file

@ -1,57 +1,52 @@
package cr0s.WarpDrive.block;
package cr0s.warpdrive.block;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import cr0s.WarpDrive.WarpDrive;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
public class BlockTransportBeacon extends Block {
public BlockTransportBeacon(int par1) {
super(par1, Material.iron);
setHardness(0.5F);
setStepSound(Block.soundMetalFootstep);
public BlockTransportBeacon() {
super(Material.iron);
setHardness(0.5F);
setStepSound(Block.soundTypeMetal);
setCreativeTab(WarpDrive.warpdriveTab);
setUnlocalizedName("warpdrive.blocks.transportBeacon");
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) {
return null;
}
return null;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister) {
this.blockIcon = par1IconRegister.registerIcon("warpdrive:transportBeacon");
}
public void registerBlockIcons(IIconRegister par1IconRegister) {
this.blockIcon = par1IconRegister.registerIcon("warpdrive:transportBeacon");
}
@Override
public boolean isOpaqueCube() {
return false;
}
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int getRenderType() {
return 2;
}
@Override
public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3) {
float f = 0.065F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.6F, 0.5F + f);
@Override
public int getRenderType() {
return 2;
}
return super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3);
}
@Override
public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3) {
float f = 0.065F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.6F, 0.5F + f);
return super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3);
}
}

View file

@ -1,38 +1,35 @@
package cr0s.WarpDrive.block;
package cr0s.warpdrive.block;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBlockDecorative extends ItemBlock
{
public class ItemBlockDecorative extends ItemBlock {
public ItemBlockDecorative(int par1)
{
super(par1);
public ItemBlockDecorative(Block bl) {
super(bl);
setHasSubtypes(true);
setUnlocalizedName("warpdrive.block.decorative");
}
@Override
public int getMetadata (int damage)
{
public int getMetadata(int damage) {
return damage;
}
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for(int i = 0; i < BlockDecorative.decorativeTypes.values().length;i++)
par3List.add(new ItemStack(par1,1,i));
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for (int i = 0; i < BlockDecorative.decorativeTypes.values().length; i++)
par3List.add(new ItemStack(par1, 1, i));
}
@Override
public String getUnlocalizedName(ItemStack itemstack)
{
if(itemstack == null)
public String getUnlocalizedName(ItemStack itemstack) {
if (itemstack == null)
return getUnlocalizedName();
return "tile.warpdrive.decorative." + BlockDecorative.decorativeTypes.values()[itemstack.getItemDamage()].toString();
}

View file

@ -1,36 +1,28 @@
package cr0s.WarpDrive.machines;
package cr0s.warpdrive.machines;
import cr0s.WarpDrive.machines.WarpBlockContainer;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class BlockChunkLoader extends WarpBlockContainer
{
Icon iconBuffer;
public class BlockChunkLoader extends WarpBlockContainer {
IIcon iconBuffer;
public BlockChunkLoader(int par1)
{
super(par1);
setUnlocalizedName("warpdrive.machines.ChunkLoader");
public BlockChunkLoader() {
}
@Override
public TileEntity createNewTileEntity(World world)
{
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntityChunkLoader();
}
@Override
public void registerIcons(IconRegister ir)
{
public void registerBlockIcons(IIconRegister ir) {
iconBuffer = ir.registerIcon("warpdrive:chunkLoader");
}
@Override
public Icon getIcon(int side, int damage)
{
public IIcon getIcon(int side, int damage) {
return iconBuffer;
}

View file

@ -1,38 +1,33 @@
package cr0s.WarpDrive.machines;
package cr0s.warpdrive.machines;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import cr0s.WarpDrive.WarpDrive;
import cr0s.warpdrive.WarpDrive;
public class BlockLaserReactorMonitor extends BlockContainer {
public BlockLaserReactorMonitor(int id, int texture, Material material) {
super(id, material);
setHardness(0.5F);
setStepSound(Block.soundMetalFootstep);
public BlockLaserReactorMonitor(int texture, Material material) {
super(material);
setHardness(0.5F);
setStepSound(Block.soundTypeMetal);
setCreativeTab(WarpDrive.warpdriveTab);
setUnlocalizedName("warpdrive.machines.LaserReactorMonitor");
}
public BlockLaserReactorMonitor(int id, Material material) {
this(id, 0, material);
}
}
public BlockLaserReactorMonitor(Material material) {
this(0, material);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister) {
// Solid textures
blockIcon = par1IconRegister.registerIcon("warpdrive:reactorMonitor");
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
// Solid textures
blockIcon = par1IconRegister.registerIcon("warpdrive:reactorMonitor");
}
@Override
public TileEntity createNewTileEntity(World var1) {
return new TileEntityLaserReactorMonitor();
}
@Override
public TileEntity createNewTileEntity(World var1, int i) {
return new TileEntityLaserReactorMonitor();
}
}

View file

@ -1,66 +1,62 @@
package cr0s.WarpDrive.machines;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import cr0s.WarpDrive.WarpDrive;
package cr0s.warpdrive.machines;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
public class BlockLaserTreeFarm extends BlockContainer {
private Icon[] iconBuffer;
private IIcon[] iconBuffer;
public BlockLaserTreeFarm(int id, int texture, Material material) {
super(id, material);
setHardness(0.5F);
setStepSound(Block.soundMetalFootstep);
public BlockLaserTreeFarm(int texture, Material material) {
super(material);
setHardness(0.5F);
setStepSound(Block.soundTypeMetal);
setCreativeTab(WarpDrive.warpdriveTab);
setUnlocalizedName("warpdrive.machines.LaserTreeFarm");
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister) {
iconBuffer = new Icon[2];
// Solid textures
iconBuffer[0] = par1IconRegister.registerIcon("warpdrive:particleBoosterTopBottom");
iconBuffer[1] = par1IconRegister.registerIcon("warpdrive:laserTreeFarmSide0");
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
iconBuffer = new IIcon[2];
// Solid textures
iconBuffer[0] = par1IconRegister.registerIcon("warpdrive:particleBoosterTopBottom");
iconBuffer[1] = par1IconRegister.registerIcon("warpdrive:laserTreeFarmSide0");
}
@Override
public Icon getIcon(int side, int metadata) {
if (side == 0 || side == 1) {
return iconBuffer[0];
}
@Override
public IIcon getIcon(int side, int metadata) {
if (side == 0 || side == 1) {
return iconBuffer[0];
}
return iconBuffer[1];
}
@Override
public TileEntity createNewTileEntity(World var1) {
return new TileEntityLaserTreeFarm();
}
return iconBuffer[1];
}
/**
* Returns the quantity of items to drop on block destruction.
*/
@Override
public int quantityDropped(Random par1Random) {
return 1;
}
@Override
public TileEntity createNewTileEntity(World var1, int i) {
return new TileEntityLaserTreeFarm();
}
/**
* Returns the ID of the items to drop on destruction.
*/
@Override
public int idDropped(int par1, Random par2Random, int par3) {
return this.blockID;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
@Override
public int quantityDropped(Random par1Random) {
return 1;
}
/**
* Returns the ID of the items to drop on destruction.
*/
@Override
public Item getItemDropped(int par1, Random par2Random, int par3) {
return Item.getItemFromBlock(this);
}
}

View file

@ -1,63 +1,58 @@
package cr0s.WarpDrive.machines;
package cr0s.warpdrive.machines;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class BlockPowerLaser extends WarpBlockContainer {
static Icon[] iconBuffer = new Icon[16];
public BlockPowerLaser(int id) {
super(id);
setUnlocalizedName("warpdrive.power.Laser");
static IIcon[] iconBuffer = new IIcon[16];
public BlockPowerLaser() {
setResistance(100.0F);
}
}
@Override
public TileEntity createNewTileEntity(World world) {
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntityPowerLaser();
}
private static boolean isActive(int side, int meta) {
if (side == 3 && meta == 1) {
return true;
}
if (side == 2 && meta == 2) {
return true;
}
if (side == 4 && meta == 4) {
return true;
}
if (side == 5 && meta == 3) {
return true;
}
return false;
}
@Override
@SideOnly(Side.CLIENT)
public Icon getIcon(int side, int meta) {
public IIcon getIcon(int side, int meta) {
if (side == 0 || side == 1) {
return iconBuffer[0];
return iconBuffer[0];
}
if(isActive(side,meta)) {
return iconBuffer[2];
if (isActive(side, meta)) {
return iconBuffer[2];
}
return iconBuffer[1];
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister) {
iconBuffer[0] = par1IconRegister.registerIcon("warpdrive:powerLaserTopBottom");
iconBuffer[1] = par1IconRegister.registerIcon("warpdrive:powerLaserSides");
iconBuffer[2] = par1IconRegister.registerIcon("warpdrive:powerLaserActive");
public void registerBlockIcons(IIconRegister par1IconRegister) {
iconBuffer[0] = par1IconRegister.registerIcon("warpdrive:powerLaserTopBottom");
iconBuffer[1] = par1IconRegister.registerIcon("warpdrive:powerLaserSides");
iconBuffer[2] = par1IconRegister.registerIcon("warpdrive:powerLaserActive");
}
}

View file

@ -1,42 +1,39 @@
package cr0s.WarpDrive.machines;
package cr0s.warpdrive.machines;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class BlockPowerReactor extends WarpBlockContainer {
Icon[] iconBuffer = new Icon[17];
public BlockPowerReactor(int id) {
super(id);
setUnlocalizedName("warpdrive.power.Reactor");
}
IIcon[] iconBuffer = new IIcon[17];
public BlockPowerReactor() {
super();
}
@Override
public TileEntity createNewTileEntity(World world) {
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntityPowerReactor();
}
@Override
public void breakBlock(World w,int x,int y,int z, int oid,int om) {
public void breakBlock(World w, int x, int y, int z, Block oid, int om) {
super.breakBlock(w, x, y, z, oid, om);
int[] xo = {-2, 2, 0, 0};
int[] zo = { 0, 0,-2, 2};
for(int i = 0; i < 4; i++) {
TileEntity te = w.getBlockTileEntity(x+xo[i], y, z+zo[i]);
if(te instanceof TileEntityPowerLaser) {
((TileEntityPowerLaser)te).unlink();
int[] xo = { -2, 2, 0, 0 };
int[] zo = { 0, 0, -2, 2 };
for (int i = 0; i < 4; i++) {
TileEntity te = w.getTileEntity(x + xo[i], y, z + zo[i]);
if (te instanceof TileEntityPowerLaser) {
((TileEntityPowerLaser) te).unlink();
}
}
}
@Override
@SideOnly(Side.CLIENT)
public Icon getIcon(int side, int meta) {
public IIcon getIcon(int side, int meta) {
if (side == 0 || side == 1) {
return iconBuffer[16];
}
@ -45,26 +42,25 @@ public class BlockPowerReactor extends WarpBlockContainer {
}
return iconBuffer[0];
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister) {
public void registerBlockIcons(IIconRegister par1IconRegister) {
iconBuffer[16] = par1IconRegister.registerIcon("warpdrive:reactorTB");
iconBuffer[0] = par1IconRegister.registerIcon("warpdrive:reactorSide00");
iconBuffer[1] = par1IconRegister.registerIcon("warpdrive:reactorSide01");
iconBuffer[2] = par1IconRegister.registerIcon("warpdrive:reactorSide02");
iconBuffer[3] = par1IconRegister.registerIcon("warpdrive:reactorSide03");
iconBuffer[4] = par1IconRegister.registerIcon("warpdrive:reactorSide10");
iconBuffer[5] = par1IconRegister.registerIcon("warpdrive:reactorSide11");
iconBuffer[6] = par1IconRegister.registerIcon("warpdrive:reactorSide12");
iconBuffer[7] = par1IconRegister.registerIcon("warpdrive:reactorSide13");
iconBuffer[8] = par1IconRegister.registerIcon("warpdrive:reactorSide20");
iconBuffer[9] = par1IconRegister.registerIcon("warpdrive:reactorSide21");
iconBuffer[0] = par1IconRegister.registerIcon("warpdrive:reactorSide00");
iconBuffer[1] = par1IconRegister.registerIcon("warpdrive:reactorSide01");
iconBuffer[2] = par1IconRegister.registerIcon("warpdrive:reactorSide02");
iconBuffer[3] = par1IconRegister.registerIcon("warpdrive:reactorSide03");
iconBuffer[4] = par1IconRegister.registerIcon("warpdrive:reactorSide10");
iconBuffer[5] = par1IconRegister.registerIcon("warpdrive:reactorSide11");
iconBuffer[6] = par1IconRegister.registerIcon("warpdrive:reactorSide12");
iconBuffer[7] = par1IconRegister.registerIcon("warpdrive:reactorSide13");
iconBuffer[8] = par1IconRegister.registerIcon("warpdrive:reactorSide20");
iconBuffer[9] = par1IconRegister.registerIcon("warpdrive:reactorSide21");
iconBuffer[10] = par1IconRegister.registerIcon("warpdrive:reactorSide22");
iconBuffer[11] = par1IconRegister.registerIcon("warpdrive:reactorSide23");
iconBuffer[12] = par1IconRegister.registerIcon("warpdrive:reactorSide30");
iconBuffer[13] = par1IconRegister.registerIcon("warpdrive:reactorSide31");
iconBuffer[14] = par1IconRegister.registerIcon("warpdrive:reactorSide32");
iconBuffer[15] = par1IconRegister.registerIcon("warpdrive:reactorSide33");
}
}
}

View file

@ -1,54 +1,49 @@
package cr0s.WarpDrive.machines;
package cr0s.warpdrive.machines;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import cpw.mods.fml.common.FMLCommonHandler;
public class BlockPowerStore extends WarpBlockContainer {
private Icon iconBuffer;
public BlockPowerStore(int par1) {
super(par1);
setUnlocalizedName("warpdrive.power.Store");
private IIcon iconBuffer;
public BlockPowerStore() {
}
@Override
public TileEntity createNewTileEntity(World world) {
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntityPowerStore();
}
@Override
@SideOnly(Side.CLIENT)
public Icon getIcon(int side, int meta) {
public IIcon getIcon(int side, int meta) {
return iconBuffer;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister) {
iconBuffer = par1IconRegister.registerIcon("warpdrive:powerStore");
}
public void registerBlockIcons(IIconRegister par1IconRegister) {
iconBuffer = par1IconRegister.registerIcon("warpdrive:powerStore");
}
/**
* Called upon block activation (right click on the block.)
*/
@Override
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
return false;
}
/**
* Called upon block activation (right click on the block.)
*/
@Override
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
return false;
}
WarpEnergyTE te = (WarpEnergyTE)par1World.getBlockTileEntity(par2, par3, par4);
if (te != null && (par5EntityPlayer.getHeldItem() == null)) {
par5EntityPlayer.addChatMessage(te.getStatus());
return true;
}
WarpEnergyTE te = (WarpEnergyTE) par1World.getTileEntity(par2, par3, par4);
if (te != null && (par5EntityPlayer.getHeldItem() == null)) {
par5EntityPlayer.addChatMessage(new ChatComponentText(te.getStatus()));
return true;
}
return false;
}
return false;
}
}

View file

@ -1,47 +1,39 @@
package cr0s.WarpDrive.machines;
package cr0s.warpdrive.machines;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import cr0s.WarpDrive.WarpDrive;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class BlockTransporter extends WarpBlockContainer {
private Icon[] iconBuffer;
public BlockTransporter(int par1, Material par2Material) {
super(par1, par2Material);
setUnlocalizedName("warpdrive.machines.Transporter");
private IIcon[] iconBuffer;
public BlockTransporter(Material par2Material) {
super(par2Material);
}
@Override
public TileEntity createNewTileEntity(World world) {
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntityTransporter();
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister) {
iconBuffer = new Icon[3];
// Solid textures
iconBuffer[0] = par1IconRegister.registerIcon("warpdrive:transporterBottom");
iconBuffer[1] = par1IconRegister.registerIcon("warpdrive:transporterTop");
iconBuffer[2] = par1IconRegister.registerIcon("warpdrive:transporterSide");
}
public void registerBlockIcons(IIconRegister par1IconRegister) {
iconBuffer = new IIcon[3];
// Solid textures
iconBuffer[0] = par1IconRegister.registerIcon("warpdrive:transporterBottom");
iconBuffer[1] = par1IconRegister.registerIcon("warpdrive:transporterTop");
iconBuffer[2] = par1IconRegister.registerIcon("warpdrive:transporterSide");
}
@Override
public Icon getIcon(int side, int metadata) {
if (side == 0 || side == 1) {
return iconBuffer[side];
}
@Override
public IIcon getIcon(int side, int metadata) {
if (side == 0 || side == 1) {
return iconBuffer[side];
}
return iconBuffer[2];
}
return iconBuffer[2];
}
}

View file

@ -1,85 +1,63 @@
package cr0s.WarpDrive.machines;
package cr0s.warpdrive.machines;
import cpw.mods.fml.common.FMLCommonHandler;
import cr0s.WarpDrive.WarpDrive;
import cr0s.WarpDrive.api.IBlockUpdateDetector;
import cr0s.WarpDrive.api.IUpgradable;
import cr0s.WarpDrive.data.EnumUpgradeTypes;
import cr0s.WarpDrive.item.ItemWarpUpgrade;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IBlockUpdateDetector;
public abstract class WarpBlockContainer extends BlockContainer {
protected WarpBlockContainer(int par1) {
super(par1, Material.iron);
protected WarpBlockContainer() {
super(Material.iron);
}
protected WarpBlockContainer(int par1, Material m) {
super(par1, m);
protected WarpBlockContainer(Material m) {
super(m);
setHardness(0.5F);
setStepSound(Block.soundMetalFootstep);
setStepSound(Block.soundTypeMetal);
setCreativeTab(WarpDrive.warpdriveTab);
}
@Override
public void onBlockAdded(World w, int x, int y, int z) {
super.onBlockAdded(w, x, y, z);
TileEntity te = w.getBlockTileEntity(x, y, z);
TileEntity te = w.getTileEntity(x, y, z);
if (te instanceof IBlockUpdateDetector) {
((IBlockUpdateDetector)te).updatedNeighbours();
((IBlockUpdateDetector) te).updatedNeighbours();
}
}
/* FIXME untested
/*
* FIXME untested
*
* @Override public boolean onBlockActivated(World world, int x, int y, int
* z, EntityPlayer player, int par6, float par7, float par8, float par9) {
* if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { return
* false; }
*
* boolean hasResponse = false; TileEntity te = world.getBlockTileEntity(x,
* y, z); if(te != null && te instanceof IUpgradable) { IUpgradable
* upgradable = (IUpgradable)te; ItemStack is =
* player.inventory.getCurrentItem(); if(is != null) { Item i =
* is.getItem(); if(i instanceof ItemWarpUpgrade) {
* if(upgradable.takeUpgrade
* (EnumUpgradeTypes.values()[is.getItemDamage()],false)) {
* if(!player.capabilities.isCreativeMode)
* player.inventory.decrStackSize(player.inventory.currentItem, 1);
* player.addChatMessage("Upgrade accepted"); } else {
* player.addChatMessage("Upgrade declined"); } hasResponse = true; } } }
*
* return hasResponse; } /*
*/
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
return false;
}
boolean hasResponse = false;
TileEntity te = world.getBlockTileEntity(x, y, z);
if(te != null && te instanceof IUpgradable)
{
IUpgradable upgradable = (IUpgradable)te;
ItemStack is = player.inventory.getCurrentItem();
if(is != null)
{
Item i = is.getItem();
if(i instanceof ItemWarpUpgrade)
{
if(upgradable.takeUpgrade(EnumUpgradeTypes.values()[is.getItemDamage()],false))
{
if(!player.capabilities.isCreativeMode)
player.inventory.decrStackSize(player.inventory.currentItem, 1);
player.addChatMessage("Upgrade accepted");
}
else
{
player.addChatMessage("Upgrade declined");
}
hasResponse = true;
}
}
}
return hasResponse;
}
/**/
@Override
public void onNeighborBlockChange(World w, int x, int y, int z, int b) {
public void onNeighborBlockChange(World w, int x, int y, int z, Block b) {
super.onNeighborBlockChange(w, x, y, z, b);
TileEntity te = w.getBlockTileEntity(x, y, z);
TileEntity te = w.getTileEntity(x, y, z);
if (te instanceof IBlockUpdateDetector) {
((IBlockUpdateDetector)te).updatedNeighbours();
((IBlockUpdateDetector) te).updatedNeighbours();
}
}
}