Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

Commit

Permalink
Added COCOA LIGHTS! Closes #14
Browse files Browse the repository at this point in the history
Finally got this in.
  • Loading branch information
renevo committed Sep 11, 2013
1 parent ca3a6c2 commit daa56d0
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/common/burptech/block/BlockIlluminatedCocoa.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package burptech.block;

import burptech.BurpTechCore;
import net.minecraft.block.BlockCocoa;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class BlockIlluminatedCocoa extends BlockCocoa
{
public BlockIlluminatedCocoa(int blockId, boolean illuminated)
{
super(blockId);

if (illuminated)
{
this.setLightValue(.9375F);
} else
{
this.setTickRandomly(true);
}
}

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
if (blockID == BurpTechCore.configuration.blocks.illuminatedCocoaOn.blockID)
return true;

int meta = world.getBlockMetadata(x, y, z);

ItemStack currentItem = player.getCurrentEquippedItem();

if (currentItem == null)
return true;

if (currentItem.itemID == Item.glowstone.itemID && ((meta & 12) >> 2) == 2)
{
world.setBlock(x, y, z, BurpTechCore.configuration.blocks.illuminatedCocoaOn.blockID, meta, 1 | 2 | 4);
if (!player.capabilities.isCreativeMode)
{
currentItem.stackSize--;
}
}

return true;
}
}
29 changes: 29 additions & 0 deletions src/common/burptech/block/Blocks.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package burptech.block;

import burptech.BurpTechCore;
import burptech.lib.Constants;
import net.minecraft.block.Block;
import net.minecraftforge.common.*;

/*
Expand All @@ -9,6 +12,11 @@ public class Blocks
{
Configuration configuration;

public Block illuminatedCocoaOn;
public Block illuminatedCocoaOff;

public Property enableIlluminatedCocoa;

/*
* Default constructor
*/
Expand All @@ -19,6 +27,27 @@ public Blocks(Configuration configuration)

public void create()
{
enableIlluminatedCocoa = configuration.get(Constants.CONFIG_CATEGORY_TWEAKS, "IlluminatedCocoaPlants", true);
enableIlluminatedCocoa.comment = "When enabled, allows you to right click a grown cocoa plant with glowstone to turn it into a lamp";

if (enableIlluminatedCocoa.getBoolean(true))
{
BurpTechCore.log.info("Adding Illuminated Cocoa Plants");
AddIlluminatedCocoa(Constants.BLOCK_START + 0);
}
}

private void AddIlluminatedCocoa(int defaultBlockID)
{
Property illuminatedCocoaOnBlockId = configuration.getBlock("IlluminatedCocoa", defaultBlockID, "The ID for the Illuminated Cocoa Plants. (Replaces default BlockCocoa)");

int illuminatedCocoaPlantID = illuminatedCocoaOnBlockId.getInt();
if (illuminatedCocoaPlantID != 0)
{
illuminatedCocoaOn = new BlockIlluminatedCocoa(illuminatedCocoaPlantID, true).setHardness(0.2F).setResistance(5.0F).setStepSound(Block.soundWoodFootstep).setUnlocalizedName("cocoa").setTextureName("cocoa");
int cocoaPlantID = Block.cocoaPlant.blockID;
Block.blocksList[cocoaPlantID] = null;
illuminatedCocoaOff = new BlockIlluminatedCocoa(cocoaPlantID, false).setHardness(0.2F).setResistance(5.0F).setStepSound(Block.soundWoodFootstep).setUnlocalizedName("cocoa").setTextureName("cocoa");
}
}
}
6 changes: 6 additions & 0 deletions src/common/burptech/lib/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,10 @@ public final class Constants
*/
public static final int GUI_ENDER_RUCKSACK_ID = 3;


/**
* Block starting ID for defaults
*/
public static final int BLOCK_START = 900;

}

0 comments on commit daa56d0

Please sign in to comment.