-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7473396
commit 8cbee26
Showing
4 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.myname.mymodid.base; | ||
|
||
import cpw.mods.fml.relauncher.Side; | ||
import cpw.mods.fml.relauncher.SideOnly; | ||
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.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.IIcon; | ||
import net.minecraft.world.World; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
public class CustomBlock extends Block { | ||
public String name; | ||
Item item; | ||
HashMap<Integer, String> subblocks; | ||
protected IIcon[] icons; | ||
|
||
public CustomBlock(String name, Material material, HashMap subblocks) { | ||
super(material); | ||
this.name = name; | ||
this.subblocks = subblocks; | ||
icons = new IIcon[subblocks.size()]; | ||
} | ||
|
||
@Override | ||
public String getUnlocalizedName() { | ||
return "stones:"+name; | ||
} | ||
|
||
@SideOnly(Side.CLIENT) | ||
@Override | ||
public IIcon getIcon(int side, int meta) { | ||
if (meta <= this.icons.length) | ||
return this.icons[meta]; | ||
else | ||
return this.icons[0]; | ||
} | ||
|
||
@Override | ||
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) { | ||
for (int i = 0; i < this.subblocks.size(); ++i) { | ||
list.add(new ItemStack(item, 1, i)); | ||
} | ||
} | ||
|
||
public void setDrop(Item item){ | ||
this.item = item; | ||
} | ||
|
||
@Override | ||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int meta, int fortune) { | ||
ArrayList<ItemStack> drops = new ArrayList<>(); | ||
ItemStack itemStack = new ItemStack(this, 1, meta); | ||
drops.add(itemStack); | ||
return drops; | ||
} | ||
|
||
@SideOnly(Side.CLIENT) | ||
public void registerBlockIcons(IIconRegister icon) { | ||
for (int i = 0; i < this.icons.length; ++i) { | ||
this.icons[i] = icon.registerIcon("stones:"+name+"_"+this.subblocks.get(i)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.myname.mymodid.base; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.item.ItemBlock; | ||
import net.minecraft.item.ItemSeeds; | ||
|
||
public class CustomItem extends ItemBlock { | ||
public CustomItem(Block block) { | ||
super(block); | ||
this.setHasSubtypes(true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.myname.mymodid.blocks; | ||
|
||
import com.myname.mymodid.base.CustomBlock; | ||
import com.myname.mymodid.base.CustomItem; | ||
import cpw.mods.fml.common.registry.GameRegistry; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.material.Material; | ||
import net.minecraft.init.Items; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemBlock; | ||
|
||
import java.util.HashMap; | ||
|
||
public class CustomStone{ | ||
static HashMap<Integer, String> subblocks = new HashMap<>(); | ||
public enum Stones { | ||
BRICKS, | ||
CHISELED; | ||
|
||
Stones() { | ||
subblocks.put(this.ordinal(), this.name()); | ||
} | ||
} | ||
|
||
public static void register(){ | ||
Stones.values(); | ||
CustomBlock block = new CustomBlock("custom_block", Material.rock, subblocks); | ||
//ItemBlock item = new CustomItem(block); | ||
//block.setDrop(item); | ||
//GameRegistry.registerItem(item, block.name); | ||
GameRegistry.registerBlock(block, block.name); | ||
} | ||
} | ||
|