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

Commit

Permalink
Added Nether Coal - Closes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
renevo committed Mar 18, 2016
1 parent b370486 commit 7eda390
Show file tree
Hide file tree
Showing 27 changed files with 175 additions and 47 deletions.
2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mod_version=1.3.3
mod_version=1.3.4
minecraft_version=1.8.9
forge_version=11.15.1.1764
mappings=stable_20
Expand Down
Binary file added images/nether_coal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/nether_coal_block.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/nether_coal_block_time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/nether_coal_crafting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/nether_coal_sample_farm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/nether_coal_time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/ores.psd
Binary file not shown.
30 changes: 30 additions & 0 deletions src/main/java/com/renevo/nethercore/FuelHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.renevo.nethercore;

import com.renevo.nethercore.blocks.NetherCoreBlocks;
import com.renevo.nethercore.item.NetherCoreItems;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.IFuelHandler;

public class FuelHandler implements IFuelHandler {

@Override
public int getBurnTime(ItemStack itemStack) {
if (itemStack == null) {
return 0;
}

Item item = itemStack.getItem();

if (item == NetherCoreItems.netherCoal) {
return 1600 * 2; // coal x 2
}

if (item instanceof ItemBlock && ((ItemBlock)item).getBlock() == NetherCoreBlocks.blockNetherCoal) {
return 16000 * 2; // coal_block x 2
}

return 0;
}
}
7 changes: 7 additions & 0 deletions src/main/java/com/renevo/nethercore/NetherCoreRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static void registerSmelting() {
GameRegistry.addSmelting(NetherCoreItems.stoneCobble, NetherCoreItems.stone, 0.2F);
GameRegistry.addSmelting(NetherCoreItems.stoneBrick, NetherCoreItems.stoneBrickCracked, 0.0F);

// collides with Soul Shards - The old way, need to adjust if present
GameRegistry.addSmelting(Blocks.soul_sand, NetherCoreItems.soulGlass, 0.0F);

// TODO: option to disable this
Expand All @@ -44,6 +45,11 @@ public static void registerOreDictionary() {
OreDictionary.registerOre("oreNetherLapis", NetherCoreItems.netherOreLapis.copy());
OreDictionary.registerOre("oreNetherDiamond", NetherCoreItems.netherOreDiamond.copy());
OreDictionary.registerOre("oreNetherEmerald", NetherCoreItems.netherOreEmerald.copy());
OreDictionary.registerOre("oreNetherNetherCoal", NetherCoreItems.netherOreNetherCoal.copy());
}

public static void registerFuels() {
GameRegistry.registerFuelHandler(new FuelHandler());
}

public static void registerRecipes() {
Expand Down Expand Up @@ -111,6 +117,7 @@ public static void registerRecipes() {
'R', Items.blaze_rod,
'B', Blocks.nether_brick);

addCompressedRecipe(new ItemStack(NetherCoreItems.netherCoal), NetherCoreItems.netherCoalBlock);
addCompressedRecipe(new ItemStack(Blocks.netherrack), NetherCoreItems.compressedNetherrackSingle);
addCompressedRecipe(NetherCoreItems.compressedNetherrackSingle, NetherCoreItems.compressedNetherrackDouble);
addCompressedRecipe(NetherCoreItems.compressedNetherrackDouble, NetherCoreItems.compressedNetherrackTriple);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.IStringSerializable;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import slimeknights.mantle.block.EnumBlock;

public class BlockCompressedNetherrack extends EnumBlock<BlockCompressedNetherrack.CompressionDepth> {
Expand All @@ -29,10 +31,16 @@ public BlockCompressedNetherrack(Material material) {
setCreativeTab(NetherCoreRegistry.tabNetherCore);
}

@Override
public boolean canCreatureSpawn(IBlockAccess blockAccess, BlockPos blockPos, EntityLiving.SpawnPlacementType spawnPlacementType) {
return false;
}

@Override
public boolean isFireSource(World world, BlockPos blockPos, EnumFacing facing) {
return facing == EnumFacing.UP;
}

public enum CompressionDepth implements IStringSerializable, EnumBlock.IEnumMeta {
SINGLE,
DOUBLE,
Expand Down
28 changes: 13 additions & 15 deletions src/main/java/com/renevo/nethercore/blocks/BlockNetherGrass.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,6 @@ public BlockNetherGrass() {
this.setCreativeTab(NetherCoreRegistry.tabNetherCore);
}

public boolean canSustainPlant(IBlockAccess blockAccess, BlockPos blockPos, EnumFacing facing, IPlantable iPlant) {
IBlockState plant = iPlant.getPlant(blockAccess, blockPos.offset(facing));

if (plant.getBlock() == Blocks.nether_wart) {
return true;
}

if (plant.getBlock() instanceof BlockBush) {
return true;
}

return super.canSustainPlant(blockAccess, blockPos, facing, iPlant);
}

public void updateTick(World world, BlockPos blockPos, IBlockState blockState, Random random) {
if (!world.isRemote) {
if (world.provider.doesWaterVaporize()) {
Expand All @@ -65,13 +51,25 @@ public void updateTick(World world, BlockPos blockPos, IBlockState blockState, R
for (int i = 0; i < rate; ++i) {
BlockPos blockpos = blockPos.add(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1);
Block blockOnTop = world.getBlockState(blockpos.up()).getBlock();
if (blockOnTop.isOpaqueCube()) {
continue; // just don't process
}

IBlockState iblockstate = world.getBlockState(blockpos);
if (iblockstate.getBlock() == Blocks.netherrack && !blockOnTop.isOpaqueCube()) {

if (iblockstate.getBlock() == Blocks.netherrack) {
world.setBlockState(blockpos, NetherCoreBlocks.blockNetherGrass.getDefaultState());
if (blockOnTop.isAir(world, blockpos.up())) {
world.setBlockState(blockpos.up(), Blocks.fire.getDefaultState());
}
}

if (iblockstate.getBlock() == NetherCoreBlocks.blockNetherOre && iblockstate.getBlock().getMetaFromState(iblockstate) == BlockNetherOre.OreTypes.COAL.getMeta()) {
world.setBlockState(blockpos, NetherCoreBlocks.blockNetherOre.getDefaultState().withProperty(BlockNetherOre.TYPE, BlockNetherOre.OreTypes.NETHERCOAL));
if (blockOnTop.isAir(world, blockpos.up())) {
world.setBlockState(blockpos.up(), Blocks.fire.getDefaultState());
}
}
}
}
}
Expand Down
41 changes: 28 additions & 13 deletions src/main/java/com/renevo/nethercore/blocks/BlockNetherOre.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package com.renevo.nethercore.blocks;

import com.renevo.nethercore.NetherCoreRegistry;
import com.renevo.nethercore.item.NetherCoreItems;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLiving;
import net.minecraft.init.Items;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.MathHelper;
import net.minecraft.util.*;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import slimeknights.mantle.block.EnumBlock;
Expand All @@ -36,6 +35,11 @@ public BlockNetherOre(Material material) {
setCreativeTab(NetherCoreRegistry.tabNetherCore);
}

@Override
public boolean isFireSource(World world, BlockPos blockPos, EnumFacing facing) {
return facing == EnumFacing.UP;
}

@Override
public int getExpDrop(IBlockAccess world, BlockPos blockPos, int fortune) {
OreTypes meta = OreTypes.values()[this.getMetaFromState(world.getBlockState(blockPos))];
Expand All @@ -54,6 +58,8 @@ public int getExpDrop(IBlockAccess world, BlockPos blockPos, int fortune) {
return MathHelper.getRandomIntegerInRange(rand, 3, 7);
case EMERALD:
return MathHelper.getRandomIntegerInRange(rand, 3, 7);
case NETHERCOAL: // bit of a bump from vanilla
return MathHelper.getRandomIntegerInRange(rand, 1, 3);
}

return xp;
Expand All @@ -73,6 +79,8 @@ public Item getItemDropped(IBlockState blockState, Random random, int p_getItemD
return Items.diamond;
case EMERALD:
return Items.emerald;
case NETHERCOAL:
return NetherCoreItems.netherCoal;
}

return Item.getItemFromBlock(this);
Expand All @@ -84,15 +92,20 @@ public int quantityDropped(IBlockState blockState, int bonus, Random random) {

Item dropped = this.getItemDropped(blockState, random, 0);
if (dropped == Items.dye) {
dropCount = 4 + random.nextInt(5) /* nether bonus */ + quantityDroppedWithBonus(4 + random.nextInt(5), bonus, random);
dropCount = 4 + random.nextInt(5) + quantityDroppedWithBonus(4 + random.nextInt(5), bonus, random);
}

if (dropped == Items.diamond || dropped == Items.emerald || dropped == Items.coal) {
dropCount = 1 /* nether bonus */ + quantityDroppedWithBonus(1, bonus, random);
dropCount = 1 + quantityDroppedWithBonus(1, bonus, random);
}

if (dropped == Items.redstone) {
dropCount = 4 + random.nextInt(2) /* nether bonus */ + quantityDroppedWithBonus(4 + random.nextInt(2), bonus, random);
dropCount = 4 + random.nextInt(2) + quantityDroppedWithBonus(4 + random.nextInt(2), bonus, random);
}

// no bonus
if (dropped == NetherCoreItems.netherCoal) {
dropCount = quantityDroppedWithBonus(1, bonus, random);
}

return dropCount;
Expand All @@ -118,11 +131,6 @@ public int getDamageValue(World world, BlockPos blockPos) {
return this.getMetaFromState(world.getBlockState(blockPos));
}

@Override
public EnumWorldBlockLayer getBlockLayer() {
return EnumWorldBlockLayer.CUTOUT_MIPPED;
}

public int quantityDroppedWithBonus(int baseRate, int bonus, Random random) {
if (bonus > 0) {
int i = random.nextInt(bonus + 2) - 1;
Expand All @@ -136,14 +144,21 @@ public int quantityDroppedWithBonus(int baseRate, int bonus, Random random) {
}
}

@Override
public boolean canCreatureSpawn(IBlockAccess blockAccess, BlockPos blockPos, EntityLiving.SpawnPlacementType spawnPlacementType) {
OreTypes meta = OreTypes.values()[this.getMetaFromState(blockAccess.getBlockState(blockPos))];
return meta != OreTypes.NETHERCOAL;
}

public enum OreTypes implements IStringSerializable, EnumBlock.IEnumMeta {
COAL,
IRON,
GOLD,
REDSTONE,
LAPIS,
DIAMOND,
EMERALD;
EMERALD,
NETHERCOAL;

public final int meta;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.renevo.nethercore.blocks;

import com.renevo.nethercore.NetherCoreRegistry;
import com.renevo.nethercore.item.ItemStoneSlab;
import com.renevo.nethercore.tileentity.TileEntityNetherFurnace;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSlab;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemSlab;
import net.minecraftforge.fml.common.registry.GameRegistry;
Expand Down Expand Up @@ -39,6 +42,8 @@ private NetherCoreBlocks() {
public static BlockLightRod blockLightRod;
public static BlockOpaqueGlass blockSoulGlass;

public static Block blockNetherCoal;


public static void init() {
blockNetherOre = registerEnumBlock(new BlockNetherOre(), "ore");
Expand Down Expand Up @@ -67,6 +72,8 @@ public static void init() {
blockLightRod = registerBlock(new BlockLightRod(), "nether_rod");
blockSoulGlass = registerBlock(new BlockOpaqueGlass(), "soul_glass");

blockNetherCoal = registerBlock(new Block(Material.rock, MapColor.redColor).setHardness(5.0F).setResistance(10.0F).setStepSound(soundTypeNetherStone).setCreativeTab(NetherCoreRegistry.tabNetherCore), "nether_coal_block");

GameRegistry.registerTileEntity(TileEntityNetherFurnace.class, "nether_furnace");
}

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/renevo/nethercore/common/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,14 @@ public void registerModels() {
itemToAdd = Item.getItemFromBlock(NetherCoreBlocks.blockSoulGlass);
ModelLoader.setCustomModelResourceLocation(itemToAdd, 0, new ModelResourceLocation(Util.getResource("soul_glass"), "inventory"));

itemToAdd = Item.getItemFromBlock(NetherCoreBlocks.blockNetherCoal);
ModelLoader.setCustomModelResourceLocation(itemToAdd, 0, new ModelResourceLocation(Util.getResource("nether_coal_block"), "inventory"));

// items
itemToAdd = NetherCoreItems.netherSpore;
ModelLoader.setCustomModelResourceLocation(itemToAdd, 0, new ModelResourceLocation(Util.getResource("nether_spore"), "inventory"));

itemToAdd = NetherCoreItems.netherCoal;
ModelLoader.setCustomModelResourceLocation(itemToAdd, 0, new ModelResourceLocation(Util.getResource("nether_coal"), "inventory"));
}
}
4 changes: 1 addition & 3 deletions src/main/java/com/renevo/nethercore/common/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
public class CommonProxy {

public void preInit() {
// blocks, items, worldgen, etc...
NetherCoreBlocks.init();
NetherCoreItems.init();

Expand All @@ -27,15 +26,14 @@ public void preInit() {
}

public void init() {
// recipes
NetherCoreRegistry.registerRecipes();
NetherCoreRegistry.registerSmelting();

NetworkRegistry.INSTANCE.registerGuiHandler(NetherCore.instance, new GuiHandler());
}

public void postInit() {
// fuels, integrations
NetherCoreRegistry.registerFuels();
NetherCoreRegistry.registerIntegrations();
}

Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/renevo/nethercore/item/ItemNetherCoal.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.renevo.nethercore.item;

import com.renevo.nethercore.NetherCoreRegistry;

public class ItemNetherCoal extends ItemMeta {
public ItemNetherCoal() {
this.setCreativeTab(NetherCoreRegistry.tabNetherCore);
}
}
13 changes: 11 additions & 2 deletions src/main/java/com/renevo/nethercore/item/NetherCoreItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import net.minecraftforge.fml.common.registry.GameRegistry;

public final class NetherCoreItems {
private NetherCoreItems() {}
private NetherCoreItems() {
}

public static Item netherSpore;
public static Item netherCoal;

// item block stacks
public static ItemStack netherOreCoal;
Expand All @@ -19,6 +21,7 @@ private NetherCoreItems() {}
public static ItemStack netherOreLapis;
public static ItemStack netherOreDiamond;
public static ItemStack netherOreEmerald;
public static ItemStack netherOreNetherCoal;

public static ItemStack compressedNetherrackSingle;
public static ItemStack compressedNetherrackDouble;
Expand Down Expand Up @@ -57,8 +60,11 @@ private NetherCoreItems() {}
public static ItemStack netherRod;
public static ItemStack soulGlass;

public static ItemStack netherCoalBlock;

public static void init() {
GameRegistry.registerItem(netherSpore = new ItemNetherSpore().setUnlocalizedName(Util.prefix("nether_spore")), "nether_spore");
GameRegistry.registerItem(netherSpore = new ItemNetherSpore().setUnlocalizedName(Util.prefix("nether_spore")), "nether_spore");
GameRegistry.registerItem(netherCoal = new ItemNetherCoal().setUnlocalizedName(Util.prefix("nether_coal")), "nether_coal");

// item blocks
netherOreCoal = new ItemStack(NetherCoreBlocks.blockNetherOre, 1, BlockNetherOre.OreTypes.COAL.getMeta());
Expand All @@ -68,6 +74,7 @@ public static void init() {
netherOreLapis = new ItemStack(NetherCoreBlocks.blockNetherOre, 1, BlockNetherOre.OreTypes.LAPIS.getMeta());
netherOreDiamond = new ItemStack(NetherCoreBlocks.blockNetherOre, 1, BlockNetherOre.OreTypes.DIAMOND.getMeta());
netherOreEmerald = new ItemStack(NetherCoreBlocks.blockNetherOre, 1, BlockNetherOre.OreTypes.EMERALD.getMeta());
netherOreNetherCoal = new ItemStack(NetherCoreBlocks.blockNetherOre, 1, BlockNetherOre.OreTypes.NETHERCOAL.getMeta());

compressedNetherrackSingle = new ItemStack(NetherCoreBlocks.blockCompressedNetherrack, 1, BlockCompressedNetherrack.CompressionDepth.SINGLE.getMeta());
compressedNetherrackDouble = new ItemStack(NetherCoreBlocks.blockCompressedNetherrack, 1, BlockCompressedNetherrack.CompressionDepth.DOUBLE.getMeta());
Expand Down Expand Up @@ -105,5 +112,7 @@ public static void init() {

netherRod = new ItemStack(NetherCoreBlocks.blockLightRod);
soulGlass = new ItemStack(NetherCoreBlocks.blockSoulGlass);

netherCoalBlock = new ItemStack(NetherCoreBlocks.blockNetherCoal);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"forge_marker": 1,
"defaults": {
"transform": "forge:default-block",
"model": "minecraft:cube_all",
"textures": {
"all": "nethercore:blocks/nether_coal",
"particle": "#all"
}
},
"variants": {
"inventory": [{}],
"normal": [{}]
}
}
Loading

0 comments on commit 7eda390

Please sign in to comment.