-Added colored Lamps

This commit is contained in:
Ellpeck 2015-06-28 21:28:58 +02:00
parent a0adaf7ce1
commit d5930da5e3
67 changed files with 288 additions and 10 deletions

View file

@ -0,0 +1,169 @@
package ellpeck.actuallyadditions.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.blocks.metalists.TheColoredLampColors;
import ellpeck.actuallyadditions.util.BlockUtil;
import ellpeck.actuallyadditions.util.INameableItem;
import ellpeck.actuallyadditions.util.ModUtil;
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.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import java.util.List;
import java.util.Random;
public class BlockColoredLamp extends Block implements INameableItem{
public static TheColoredLampColors[] allLampTypes = TheColoredLampColors.values();
private IIcon[] textures = new IIcon[allLampTypes.length];
private boolean isOn;
public BlockColoredLamp(boolean isOn){
super(Material.redstoneLight);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(0.5F);
this.isOn = isOn;
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z){
return this.isOn ? 15 : 0;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ){
//Turning On
if(player.isSneaking()){
if(!world.isRemote){
world.setBlock(x, y, z, this.isOn ? InitBlocks.blockColoredLamp : InitBlocks.blockColoredLampOn, world.getBlockMetadata(x, y, z), 2);
}
return true;
}
//Changing Colors
int[] oreIDs = OreDictionary.getOreIDs(player.getCurrentEquippedItem());
if(oreIDs.length > 0){
for(int oreID : oreIDs){
String name = OreDictionary.getOreName(oreID);
TheColoredLampColors color = TheColoredLampColors.getColorFromDyeName(name);
if(color != null){
if(world.getBlockMetadata(x, y, z) != color.ordinal()){
if(!world.isRemote){
world.setBlockMetadataWithNotify(x, y, z, color.ordinal(), 2);
if(!player.capabilities.isCreativeMode) player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
return true;
}
}
}
}
return false;
}
@Override
public String getName(){
return this.isOn ? "blockColoredLampOn" : "blockColoredLamp";
}
@Override
public String getOredictName(){
return "";
}
@Override
public IIcon getIcon(int side, int meta){
return meta >= allLampTypes.length ? null : textures[meta];
}
@SuppressWarnings("all")
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list){
for (int j = 0; j < allLampTypes.length; j++){
list.add(new ItemStack(item, 1, j));
}
}
@Override
public Item getItemDropped(int par1, Random rand, int par3){
return Item.getItemFromBlock(InitBlocks.blockColoredLamp);
}
@Override
@SideOnly(Side.CLIENT)
public Item getItem(World world, int x, int y, int z){
return Item.getItemFromBlock(InitBlocks.blockColoredLamp);
}
@Override
public ItemStack createStackedBlock(int meta){
return new ItemStack(InitBlocks.blockColoredLamp, 1, meta);
}
@Override
public int damageDropped(int meta){
return meta;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
for(int i = 0; i < allLampTypes.length; i++){
this.textures[i] = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + ((INameableItem)InitBlocks.blockColoredLamp).getName() + allLampTypes[i].name + (isOn ? "On" : ""));
}
}
public static class TheItemBlock extends ItemBlock{
private Block theBlock;
public TheItemBlock(Block block){
super(block);
this.theBlock = block;
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare;
}
@Override
public String getUnlocalizedName(ItemStack stack){
return InitBlocks.blockColoredLamp.getUnlocalizedName() + allLampTypes[stack.getItemDamage()].getName();
}
@Override
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
BlockUtil.addInformation(InitBlocks.blockColoredLamp, list, 2, "");
}
@Override
public int getMetadata(int damage){
return damage;
}
@Override
public String getItemStackDisplayName(ItemStack stack){
if(stack.getItemDamage() >= allLampTypes.length) return null;
return StatCollector.translateToLocal(this.getUnlocalizedName(stack) + ".name") + (((BlockColoredLamp)this.theBlock).isOn ? " (" + StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + ".onSuffix.desc") + ")" : "");
}
}
}

View file

@ -14,7 +14,9 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
import java.util.List;
import java.util.Random;
@ -36,6 +38,11 @@ public class BlockPlant extends BlockCrops implements INameableItem{
this.addDropAmount = addDropAmount;
}
@Override
public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z){
return EnumPlantType.Crop;
}
@Override
public int quantityDropped(int meta, int fortune, Random random){
return meta >= 7 ? random.nextInt(addDropAmount)+minDropAmount : super.quantityDropped(meta, fortune, random);

View file

@ -73,7 +73,10 @@ public class InitBlocks{
public static Block blockTestifiBucksGreenStairs;
public static Block blockTestifiBucksWhiteStairs;
public static Block blockTestifiBucksGreenSlab;
public static Block blockTestifibucksWhiteSlab;
public static Block blockTestifiBucksWhiteSlab;
public static Block blockColoredLamp;
public static Block blockColoredLampOn;
public static void init(){
Util.logInfo("Initializing Blocks...");
@ -88,8 +91,13 @@ public class InitBlocks{
BlockUtil.register(blockTestifiBucksWhiteStairs, BlockStair.TheItemBlock.class);
blockTestifiBucksGreenSlab = new BlockSlabs("blockTestifiBucksGreenSlab", blockTestifiBucksGreenWall);
BlockUtil.register(blockTestifiBucksGreenSlab, BlockSlabs.TheItemBlock.class);
blockTestifibucksWhiteSlab = new BlockSlabs("blockTestifibucksWhiteSlab", blockTestifiBucksWhiteWall);
BlockUtil.register(blockTestifibucksWhiteSlab, BlockSlabs.TheItemBlock.class);
blockTestifiBucksWhiteSlab = new BlockSlabs("blockTestifiBucksWhiteSlab", blockTestifiBucksWhiteWall);
BlockUtil.register(blockTestifiBucksWhiteSlab, BlockSlabs.TheItemBlock.class);
blockColoredLamp = new BlockColoredLamp(false);
BlockUtil.register(blockColoredLamp, BlockColoredLamp.TheItemBlock.class, BlockColoredLamp.allLampTypes);
blockColoredLampOn = new BlockColoredLamp(true);
BlockUtil.register(blockColoredLampOn, BlockColoredLamp.TheItemBlock.class, false, BlockColoredLamp.allLampTypes);
blockEnergizer = new BlockEnergizer(true);
BlockUtil.register(blockEnergizer, BlockEnergizer.TheItemBlock.class);

View file

@ -0,0 +1,47 @@
package ellpeck.actuallyadditions.blocks.metalists;
import ellpeck.actuallyadditions.util.INameableItem;
public enum TheColoredLampColors implements INameableItem{
WHITE("White"),
ORANGE("Orange"),
MAGENTA("Magenta"),
LIGHT_BLUE("LightBlue"),
YELLOW("Yellow"),
LIME("Lime"),
PINK("Pink"),
GRAY("Gray"),
LIGHT_GRAY("LightGray"),
CYAN("Cyan"),
PURPLE("Purple"),
BLUE("Blue"),
BROWN("Brown"),
GREEN("Green"),
RED("Red"),
BLACK("Black");
public String name;
TheColoredLampColors(String name){
this.name = name;
}
@Override
public String getName(){
return name;
}
@Override
public String getOredictName(){
return "blockColoredLamp" + this.getName();
}
public static TheColoredLampColors getColorFromDyeName(String color){
String actualName = color.substring(3);
for(int i = 0; i < values().length; i++){
if(values()[i].getName().equals(actualName)) return values()[i];
}
return null;
}
}

View file

@ -69,7 +69,8 @@ public class CreativeTab extends CreativeTabs{
add(InitBlocks.blockTestifiBucksGreenStairs);
add(InitBlocks.blockTestifiBucksWhiteStairs);
add(InitBlocks.blockTestifiBucksGreenSlab);
add(InitBlocks.blockTestifibucksWhiteSlab);
add(InitBlocks.blockTestifiBucksWhiteSlab);
add(InitBlocks.blockColoredLamp);
add(InitItems.itemDrill);
add(InitItems.itemDrillUpgradeSpeed);

View file

@ -7,8 +7,7 @@ import ellpeck.actuallyadditions.achievement.InitAchievements;
public class PickupEvent{
@SubscribeEvent
public void onCraftedEvent(PlayerEvent.ItemPickupEvent event){
public void onPickupEvent(PlayerEvent.ItemPickupEvent event){
CraftEvent.checkAchievements(event.pickedUp.getEntityItem(), event, InitAchievements.PICKUP_ACH);
}
}

View file

@ -232,8 +232,7 @@ public class GuiInputter extends GuiContainer{
this.setVariable(this.fieldPullStart, 2);
this.setVariable(this.fieldPullEnd, 3);
}
else
PacketHandler.theNetwork.sendToServer(new PacketGuiButton(x, y, z, world, button.id, Minecraft.getMinecraft().thePlayer));
else PacketHandler.theNetwork.sendToServer(new PacketGuiButton(x, y, z, world, button.id, Minecraft.getMinecraft().thePlayer));
}
public static class SmallerButton extends GuiButton{

View file

@ -39,6 +39,7 @@ public class NEIActuallyAdditionsConfig implements IConfigureNEI{
API.hideItem(new ItemStack(InitBlocks.blockFlax));
API.hideItem(new ItemStack(InitBlocks.blockCoffee));
API.hideItem(new ItemStack(InitBlocks.blockWildPlant, 1, Util.WILDCARD));
API.hideItem(new ItemStack(InitBlocks.blockColoredLampOn, 1, Util.WILDCARD));
}
@Override

View file

@ -44,7 +44,7 @@ public class BlockUtil{
public static final ArrayList<Block> wailaRegisterList = new ArrayList<Block>();
public static void register(Block block, Class<? extends ItemBlock> itemBlock, boolean addTab, Enum[] list){
if(addTab) block.setCreativeTab(CreativeTab.instance);
block.setCreativeTab(addTab ? CreativeTab.instance : null);
block.setBlockName(createUnlocalizedName(block));
GameRegistry.registerBlock(block, itemBlock, ((INameableItem)block).getName());
if(list != null){

View file

@ -40,7 +40,7 @@ public class ItemUtil{
}
public static void register(Item item, boolean addTab, Enum[] list){
if(addTab) item.setCreativeTab(CreativeTab.instance);
item.setCreativeTab(addTab ? CreativeTab.instance : null);
item.setUnlocalizedName(createUnlocalizedName(item));
GameRegistry.registerItem(item, ((INameableItem)item).getName());
if(list != null){

View file

@ -61,6 +61,26 @@ tooltip.actuallyadditions.itemBattery.desc=Stores RF! Charge in an Energizer! Di
tile.actuallyadditions.blockCoalGenerator.name=Coal Generator
tooltip.actuallyadditions.blockCoalGenerator.desc=Produces Energy from Coal and other flammable Materials
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!
tile.actuallyadditions.blockColoredLampWhite.name=White Lamp
tile.actuallyadditions.blockColoredLampOrange.name=Orange Lamp
tile.actuallyadditions.blockColoredLampMagenta.name=Magenta Lamp
tile.actuallyadditions.blockColoredLampYellow.name=Yellow Lamp
tile.actuallyadditions.blockColoredLampLightBlue.name=Light Blue Lamp
tile.actuallyadditions.blockColoredLampBlue.name=Blue Lamp
tile.actuallyadditions.blockColoredLampGray.name=Gray Lamp
tile.actuallyadditions.blockColoredLampLightGray.name=Light Gray Lamp
tile.actuallyadditions.blockColoredLampGreen.name=Green Lamp
tile.actuallyadditions.blockColoredLampBlack.name=Black Lamp
tile.actuallyadditions.blockColoredLampBrown.name=Brown Lamp
tile.actuallyadditions.blockColoredLampRed.name=Red Lamp
tile.actuallyadditions.blockColoredLampLime.name=Lime Lamp
tile.actuallyadditions.blockColoredLampPink.name=Pink Lamp
tile.actuallyadditions.blockColoredLampCyan.name=Cyan Lamp
tile.actuallyadditions.blockColoredLampPurple.name=Purple Lamp
item.actuallyadditions.itemBucketCanolaOil.name=Canola Oil Bucket
tooltip.actuallyadditions.itemBucketCanolaOil.desc=A Bucket filled with Canola Oil
item.actuallyadditions.itemBucketOil.name=Oil Bucket
@ -144,6 +164,20 @@ tooltip.actuallyadditions.blockWildRice.desc=Grows in the Wild... Gets you Rice
tooltip.actuallyadditions.blockWildCoffee.desc=Grows in the Wild... Gets you Coffee Seeds!
tooltip.actuallyadditions.blockWildFlax.desc=Grows in the Wild... Gets you Flax Seeds!
tile.actuallyadditions.blockTestifiBucksGreenWall.name=Green TestifiBucks Wall
tile.actuallyadditions.blockTestifiBucksWhiteWall.name=White TestifiBucks Wall
tile.actuallyadditions.blockTestifiBucksGreenStairs.name=Green TestifiBucks Stairs
tile.actuallyadditions.blockTestifiBucksWhiteStairs.name=White TestifiBucks Stairs
tile.actuallyadditions.blockTestifiBucksGreenSlab.name=Green TestifiBucks Slab
tile.actuallyadditions.blockTestifiBucksWhiteSlab.name=White TestifiBucks Slab
tooltip.actuallyadditions.blockTestifiBucksGreenWall.desc=A Green Wall used in a TestifiBucks
tooltip.actuallyadditions.blockTestifiBucksWhiteWall.desc=A White Wall used in a TestifiBucks
tooltip.actuallyadditions.blockTestifiBucksGreenStairs.desc=A Green Stair used in a TestifiBucks
tooltip.actuallyadditions.blockTestifiBucksWhiteStairs.desc=A White Stair used in a TestifiBucks
tooltip.actuallyadditions.blockTestifiBucksGreenSlab.desc=A Green Slab used in a TestifiBucks
tooltip.actuallyadditions.blockTestifiBucksWhiteSlab.desc=A White Slab used in a TestifiBucks
item.actuallyadditions.itemCanolaSeed.name=Canola Seeds
tooltip.actuallyadditions.itemCanolaSeed.desc=Grows on Farmland! Makes Canola!
item.actuallyadditions.itemMiscCanola.name=Canola
@ -219,6 +253,8 @@ tooltip.actuallyadditions.itemDrillUpgrade.desc=Sneak-Right-Click the Drill to a
tile.actuallyadditions.blockMiscEnderCasing.name=Ender Casing
tooltip.actuallyadditions.blockMiscEnderCasing.desc=Extremely sturdy casing, used for crafting
tooltip.actuallyadditions.onSuffix.desc=On
tooltip.actuallyadditions.phantom.connected.desc=<Block connected!>
tooltip.actuallyadditions.phantom.stored.desc=<Block stored to this Connector!>
tooltip.actuallyadditions.phantom.unbound.desc=The Connection was cleared!

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 533 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 623 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 554 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 625 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 544 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 569 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 595 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 772 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 794 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 756 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 794 B

View file

@ -0,0 +1,11 @@
{
"animation": {
"frametime": 1,
"frames": [
0,
1,
2,
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 407 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B