Skip to content

Commit

Permalink
Add charcoal, coke storage blocks.
Browse files Browse the repository at this point in the history
Signed-off-by: King Lemming <kinglemming@gmail.com>
  • Loading branch information
KingLemming committed Jan 2, 2018
1 parent 87e1838 commit 5d90508
Show file tree
Hide file tree
Showing 9 changed files with 324 additions and 18 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ dependencies {
compile "cofh:CoFHCore:${config.mc_version}-${config.cofh_core_version}:deobf"
}

version = "${project.config.mod_version}." + (System.getenv("BUILD_NUMBER") ?: "22")
version = "${project.config.mod_version}." + (System.getenv("BUILD_NUMBER") ?: "1")

println config.mc_version + "-" + config.forge_version
// Setup the Forge/Minecraft plugin data. Specify the preferred Forge/Minecraft version here.
Expand Down
249 changes: 249 additions & 0 deletions src/main/java/cofh/thermalfoundation/block/BlockStorageResource.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
package cofh.thermalfoundation.block;

import cofh.core.block.BlockCore;
import cofh.core.render.IModelRegister;
import cofh.core.util.core.IInitializer;
import cofh.thermalfoundation.ThermalFoundation;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.init.Items;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.Explosion;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import static cofh.core.util.helpers.ItemHelper.registerWithHandlers;
import static cofh.core.util.helpers.RecipeHelper.addStorageRecipe;

public class BlockStorageResource extends BlockCore implements IInitializer, IModelRegister {

public static final PropertyEnum<Type> VARIANT = PropertyEnum.create("type", Type.class);

public BlockStorageResource() {

super(Material.ROCK, MapColor.BLACK, "thermalfoundation");

setUnlocalizedName("storage");
setCreativeTab(ThermalFoundation.tabCommon);

setHardness(5.0F);
setResistance(10.0F);
setSoundType(SoundType.STONE);
setDefaultState(getBlockState().getBaseState().withProperty(VARIANT, Type.CHARCOAL));

setHarvestLevel("pickaxe", 0);
}

@Override
protected BlockStateContainer createBlockState() {

return new BlockStateContainer(this, VARIANT);
}

@Override
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> items) {

for (int i = 0; i < Type.METADATA_LOOKUP.length; i++) {
items.add(new ItemStack(this, 1, i));
}
}

/* TYPE METHODS */
@Override
public IBlockState getStateFromMeta(int meta) {

return this.getDefaultState().withProperty(VARIANT, Type.byMetadata(meta));
}

@Override
public int getMetaFromState(IBlockState state) {

return state.getValue(VARIANT).getMetadata();
}

@Override
public int damageDropped(IBlockState state) {

return state.getValue(VARIANT).getMetadata();
}

/* BLOCK METHODS */
@Override
public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) {

return true;
}

@Override
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) {

return state.getValue(VARIANT).getLight();
}

@Override
public float getBlockHardness(IBlockState state, World world, BlockPos pos) {

return state.getValue(VARIANT).getHardness();
}

@Override
public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion) {

IBlockState state = world.getBlockState(pos);
return state.getValue(VARIANT).getResistance();
}

/* IModelRegister */
@Override
@SideOnly (Side.CLIENT)
public void registerModels() {

for (int i = 0; i < Type.values().length; i++) {
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), i, new ModelResourceLocation(modName + ":" + name + "_resource", "type=" + Type.byMetadata(i).getName()));
}
}

/* IInitializer */
@Override
public boolean initialize() {

this.setRegistryName("storage_resource");
ForgeRegistries.BLOCKS.register(this);

ItemBlockStorageResource itemBlock = new ItemBlockStorageResource(this);
itemBlock.setRegistryName(this.getRegistryName());
ForgeRegistries.ITEMS.register(itemBlock);

blockCharcoal = new ItemStack(this, 1, Type.CHARCOAL.getMetadata());
blockCoke = new ItemStack(this, 1, Type.COKE.getMetadata());

registerWithHandlers("blockCharcoal", blockCharcoal);
registerWithHandlers("blockCoke", blockCoke);

ThermalFoundation.proxy.addIModelRegister(this);

return true;
}

@Override
public boolean register() {

addStorageRecipe(blockCharcoal, new ItemStack(Items.COAL, 1, 1));
addStorageRecipe(blockCoke, "fuelCoke");

return true;
}

/* TYPE */
public enum Type implements IStringSerializable {

// @formatter:off
CHARCOAL(0, "charcoal"),
COKE(1, "coke");
// @formatter: on

private static final Type[] METADATA_LOOKUP = new Type[values().length];
private final int metadata;
private final String name;
private final int light;
private final float hardness;
private final float resistance;
private final EnumRarity rarity;

Type(int metadata, String name, int light, float hardness, float resistance, EnumRarity rarity) {

this.metadata = metadata;
this.name = name;
this.light = light;
this.hardness = hardness;
this.resistance = resistance;
this.rarity = rarity;
}

Type(int metadata, String name, int light, float hardness, float resistance) {

this(metadata, name, light, hardness, resistance, EnumRarity.COMMON);
}

Type(int metadata, String name, float hardness, float resistance) {
this(metadata, name, 0, hardness, resistance, EnumRarity.COMMON);
}

Type(int metadata, String name, int light) {

this(metadata, name, light, 5.0F, 6.0F, EnumRarity.COMMON);
}

Type(int metadata, String name) {

this(metadata, name, 0, 5.0F, 6.0F, EnumRarity.COMMON);
}

public int getMetadata() {
return this.metadata;
}

@Override
public String getName() {

return this.name;
}

public int getLight() {

return this.light;
}

public float getHardness() {

return this.hardness;
}

public float getResistance() {

return this.resistance;
}

public EnumRarity getRarity() {

return this.rarity;
}

public static Type byMetadata(int metadata) {

if (metadata < 0 || metadata >= METADATA_LOOKUP.length) {
metadata = 0;
}
return METADATA_LOOKUP[metadata];
}

static {
for (Type type : values()) {
METADATA_LOOKUP[type.getMetadata()] = type;
}
}
}

/* REFERENCES */
public static ItemStack blockCharcoal;
public static ItemStack blockCoke;
// TODO: Rosin/Tar?
// TODO: Slags?

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package cofh.thermalfoundation.block;

import cofh.core.block.ItemBlockCore;
import cofh.core.util.helpers.ItemHelper;
import cofh.thermalfoundation.block.BlockStorageResource.Type;
import net.minecraft.block.Block;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;

public class ItemBlockStorageResource extends ItemBlockCore {

public ItemBlockStorageResource(Block block) {

super(block);
setHasSubtypes(true);
setMaxDamage(0);
}

@Override
public String getUnlocalizedName(ItemStack stack) {

return "tile.thermalfoundation.storage." + Type.byMetadata(ItemHelper.getItemDamage(stack)).getName() + ".name";
}

@Override
public EnumRarity getRarity(ItemStack stack) {

return Type.byMetadata(ItemHelper.getItemDamage(stack)).getRarity();
}

}
3 changes: 3 additions & 0 deletions src/main/java/cofh/thermalfoundation/init/TFBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static void preInit() {
blockOreFluid = new BlockOreFluid();
blockStorage = new BlockStorage();
blockStorageAlloy = new BlockStorageAlloy();
blockStorageResource = new BlockStorageResource();
blockGlass = new BlockGlass();
blockGlassAlloy = new BlockGlassAlloy();
blockRockwool = new BlockRockwool();
Expand All @@ -31,6 +32,7 @@ public static void preInit() {
initList.add(blockOreFluid);
initList.add(blockStorage);
initList.add(blockStorageAlloy);
initList.add(blockStorageResource);
initList.add(blockGlass);
initList.add(blockGlassAlloy);
initList.add(blockRockwool);
Expand All @@ -57,6 +59,7 @@ public void registerRecipes(RegistryEvent.Register<IRecipe> event) {
public static BlockOreFluid blockOreFluid;
public static BlockStorage blockStorage;
public static BlockStorageAlloy blockStorageAlloy;
public static BlockStorageResource blockStorageResource;
public static BlockGlass blockGlass;
public static BlockGlassAlloy blockGlassAlloy;
public static BlockRockwool blockRockwool;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"forge_marker": 1,
"defaults": {
"model": "cube_all",
"transform": "forge:default-block"
},
"variants": {
"type": {
"charcoal": {
"textures": {
"all": "thermalfoundation:blocks/storage/block_charcoal"
}
},
"coke": {
"textures": {
"all": "thermalfoundation:blocks/storage/block_coke"
}
}
}
}
}
36 changes: 19 additions & 17 deletions src/main/resources/assets/thermalfoundation/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -591,20 +591,22 @@ tile.thermalfoundation.rockwool.silver.name=Light Gray Rockwool
tile.thermalfoundation.rockwool.white.name=White Rockwool
tile.thermalfoundation.rockwool.yellow.name=Yellow Rockwool

tile.thermalfoundation.storage.aluminum.name=Aluminum Block
tile.thermalfoundation.storage.bronze.name=Bronze Block
tile.thermalfoundation.storage.constantan.name=Constantan Block
tile.thermalfoundation.storage.copper.name=Copper Block
tile.thermalfoundation.storage.electrum.name=Electrum Block
tile.thermalfoundation.storage.enderium.name=Enderium Block
tile.thermalfoundation.storage.invar.name=Invar Block
tile.thermalfoundation.storage.iridium.name=Iridium Block
tile.thermalfoundation.storage.lead.name=Lead Block
tile.thermalfoundation.storage.lumium.name=Lumium Block
tile.thermalfoundation.storage.mithril.name=Mana Infused Block
tile.thermalfoundation.storage.nickel.name=Nickel Block
tile.thermalfoundation.storage.platinum.name=Platinum Block
tile.thermalfoundation.storage.signalum.name=Signalum Block
tile.thermalfoundation.storage.silver.name=Silver Block
tile.thermalfoundation.storage.steel.name=Steel Block
tile.thermalfoundation.storage.tin.name=Tin Block
tile.thermalfoundation.storage.aluminum.name=Block of Aluminum
tile.thermalfoundation.storage.bronze.name=Block of Bronze
tile.thermalfoundation.storage.charcoal.name=Block of Charcoal
tile.thermalfoundation.storage.coke.name=Block of Coal Coke
tile.thermalfoundation.storage.constantan.name=Block of Constantan
tile.thermalfoundation.storage.copper.name=Block of Copper
tile.thermalfoundation.storage.electrum.name=Block of Electrum
tile.thermalfoundation.storage.enderium.name=Block of Enderium
tile.thermalfoundation.storage.invar.name=Block of Invar
tile.thermalfoundation.storage.iridium.name=Block of Iridium
tile.thermalfoundation.storage.lead.name=Block of Lead
tile.thermalfoundation.storage.lumium.name=Block of Lumium
tile.thermalfoundation.storage.mithril.name=Block of Mana Infused Metal
tile.thermalfoundation.storage.nickel.name=Block of Nickel
tile.thermalfoundation.storage.platinum.name=Block of Platinum
tile.thermalfoundation.storage.signalum.name=Block of Signalum
tile.thermalfoundation.storage.silver.name=Block of Silver
tile.thermalfoundation.storage.steel.name=Block of Steel
tile.thermalfoundation.storage.tin.name=Block of Tin
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5d90508

Please sign in to comment.