Added Lamp Powerer, doesn't work yet though

This commit is contained in:
Ellpeck 2015-07-07 11:31:13 +02:00
parent 14dea930a0
commit f483197a69
4 changed files with 127 additions and 1 deletions

View file

@ -148,7 +148,7 @@ public class BlockColoredLamp extends Block implements INameableItem{
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
BlockUtil.addInformation(InitBlocks.blockColoredLamp, list, 2, "");
BlockUtil.addInformation(InitBlocks.blockColoredLamp, list, 3, "");
}
@Override

View file

@ -0,0 +1,122 @@
package ellpeck.actuallyadditions.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.util.BlockUtil;
import ellpeck.actuallyadditions.util.INameableItem;
import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.WorldUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.List;
public class BlockLampPowerer extends Block implements INameableItem{
private IIcon frontIcon;
private IIcon topIcon;
public BlockLampPowerer(){
super(Material.rock);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
}
@Override
public String getName(){
return "blockLampPowerer";
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
int rotation = BlockPistonBase.determineOrientation(world, x, y, z, player);
world.setBlockMetadataWithNotify(x, y, z, rotation, 2);
}
@Override
public IIcon getIcon(int side, int meta){
if(side == 0 || side == 1) return this.topIcon;
if(side == 3) return this.frontIcon;
return this.blockIcon;
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){
int meta = world.getBlockMetadata(x, y, z);
if(side != meta && (side == 0 || side == 1)) return this.topIcon;
if(side == meta) return this.frontIcon;
return this.blockIcon;
}
@Override
public void onBlockAdded(World world, int x, int y, int z){
this.updateLamp(world, x, y, z);
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block){
this.updateLamp(world, x, y, z);
}
private void updateLamp(World world, int x, int y, int z){
if(!world.isRemote){
ChunkCoordinates coords = WorldUtil.getCoordsFromSide(ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)), x, y, z);
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName());
this.frontIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Front");
this.topIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Top");
}
public static class TheItemBlock extends ItemBlock{
private Block theBlock;
public TheItemBlock(Block block){
super(block);
this.theBlock = block;
this.setHasSubtypes(false);
this.setMaxDamage(0);
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.uncommon;
}
@Override
public String getUnlocalizedName(ItemStack stack){
return this.getUnlocalizedName();
}
@Override
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
BlockUtil.addInformation(theBlock, list, 1, "");
}
@Override
public int getMetadata(int meta){
return meta;
}
}
}

View file

@ -76,6 +76,7 @@ public class InitBlocks{
public static Block blockColoredLamp;
public static Block blockColoredLampOn;
public static Block blockLampPowerer;
public static void init(){
ModUtil.LOGGER.info("Initializing Blocks...");
@ -97,6 +98,8 @@ public class InitBlocks{
BlockUtil.register(blockColoredLamp, BlockColoredLamp.TheItemBlock.class);
blockColoredLampOn = new BlockColoredLamp(true);
BlockUtil.register(blockColoredLampOn, BlockColoredLamp.TheItemBlock.class, false);
blockLampPowerer = new BlockLampPowerer();
BlockUtil.register(blockLampPowerer, BlockLampPowerer.TheItemBlock.class);
blockEnergizer = new BlockEnergizer(true);
BlockUtil.register(blockEnergizer, BlockEnergizer.TheItemBlock.class);

View file

@ -63,6 +63,7 @@ tooltip.actuallyadditions.blockCoalGenerator.desc=Produces Energy from Coal and
tooltip.actuallyadditions.blockColoredLamp.desc.1=Sneak-Right-Click to turn me on!
tooltip.actuallyadditions.blockColoredLamp.desc.2=Right-Click me with a Dye to dye me!
tooltip.actuallyadditions.blockColoredLamp.desc.3=Use a Lamp Powerer to toggle me with Redstone!
tile.actuallyadditions.blockColoredLampWhite.name=White Lamp
tile.actuallyadditions.blockColoredLampOrange.name=Orange Lamp