Broken chains
@ -0,0 +1,149 @@
|
|||||||
|
package com.zivilon.cinder_loe.blocks;
|
||||||
|
|
||||||
|
import com.zivilon.cinder_loe.LoECreativeTabs;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import lotr.common.block.LOTRBlockOrcChain;
|
||||||
|
import net.minecraft.block.*;
|
||||||
|
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.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CinderChain extends LOTRBlockOrcChain {
|
||||||
|
|
||||||
|
public static final String[] chainTypes = {"bronze", "gold", "silver", "iron"};
|
||||||
|
@SideOnly(value= Side.CLIENT)
|
||||||
|
private IIcon[] iconMiddle;
|
||||||
|
@SideOnly(value=Side.CLIENT)
|
||||||
|
private IIcon[] iconTop;
|
||||||
|
@SideOnly(value=Side.CLIENT)
|
||||||
|
private IIcon[] iconBottom;
|
||||||
|
@SideOnly(value=Side.CLIENT)
|
||||||
|
private IIcon[] iconSingle;
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
private IIcon[] iconItem;
|
||||||
|
|
||||||
|
|
||||||
|
public CinderChain() {
|
||||||
|
this.setCreativeTab(LoECreativeTabs.tabDecoLoE);
|
||||||
|
this.setHardness(1.0f);
|
||||||
|
this.setStepSound(Block.soundTypeMetal);
|
||||||
|
setBlockName("lotr:cinderchain");
|
||||||
|
setBlockTextureName("lotr:cinderchain");
|
||||||
|
float f = 0.2f;
|
||||||
|
this.setBlockBounds(0.5f - f, 0.0f, 0.5f - f, 0.5f + f, 1.0f, 0.5f + f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||||
|
|
||||||
|
this.iconItem = new IIcon[chainTypes.length];
|
||||||
|
|
||||||
|
for (int i = 0; i < chainTypes.length; ++i) {
|
||||||
|
this.iconItem[i] = iconRegister.registerIcon(this.getTextureName() + "_" + chainTypes[i] + "_item");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.iconMiddle = new IIcon[chainTypes.length];
|
||||||
|
this.iconTop = new IIcon[chainTypes.length];
|
||||||
|
this.iconBottom = new IIcon[chainTypes.length];
|
||||||
|
this.iconSingle = new IIcon[chainTypes.length];
|
||||||
|
|
||||||
|
for (int i = 0; i < chainTypes.length; ++i) {
|
||||||
|
this.iconMiddle[i] = iconRegister.registerIcon(this.getTextureName() + "_" + chainTypes[i] + "_mid");
|
||||||
|
this.iconTop[i] = iconRegister.registerIcon(this.getTextureName() + "_" + chainTypes[i] + "_top");
|
||||||
|
this.iconBottom[i] = iconRegister.registerIcon(this.getTextureName() + "_" + chainTypes[i] + "_bottom");
|
||||||
|
this.iconSingle[i] = iconRegister.registerIcon(this.getTextureName() + "_" + chainTypes[i] + "_single");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||||
|
Block above = world.getBlock(x, y + 1, z);
|
||||||
|
Block below = world.getBlock(x, y - 1, z);
|
||||||
|
boolean chainAbove = above instanceof CinderChain;
|
||||||
|
boolean chainBelow = below instanceof CinderChain;
|
||||||
|
|
||||||
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
|
if (chainAbove && chainBelow) {
|
||||||
|
return this.iconMiddle[meta];
|
||||||
|
}
|
||||||
|
if (chainAbove) {
|
||||||
|
return this.iconBottom[meta];
|
||||||
|
}
|
||||||
|
if (chainBelow) {
|
||||||
|
return this.iconTop[meta];
|
||||||
|
}
|
||||||
|
return this.iconSingle[meta];
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(value=Side.CLIENT)
|
||||||
|
public IIcon getIcon(int i, int j) {
|
||||||
|
return i == 1 ? this.iconItem[0] : this.iconItem[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(value=Side.CLIENT)
|
||||||
|
public String getItemIconName() {
|
||||||
|
return this.getTextureName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int damageDropped(int meta) {
|
||||||
|
return meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
|
||||||
|
for (int i = 0; i < chainTypes.length; ++i) {
|
||||||
|
list.add(new ItemStack(item, 1, i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) {
|
||||||
|
// The metadata provided here is the metadata of the block being placed (from the item stack).
|
||||||
|
return metadata; // Return the metadata of the block that should be placed.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canPlaceBlockAt(World world, int x, int y, int z) {
|
||||||
|
Block blockAbove = world.getBlock(x, y + 1, z);
|
||||||
|
int metaAbove = world.getBlockMetadata(x, y + 1, z);
|
||||||
|
|
||||||
|
// Get the metadata of the block to be placed (already handled by onBlockPlaced)
|
||||||
|
int currentMeta = world.getBlockMetadata(x, y, z); // Metadata of the block being placed
|
||||||
|
|
||||||
|
// Check if the block above is a chain block and if the metadata matches
|
||||||
|
if (blockAbove instanceof CinderChain) {
|
||||||
|
if (metaAbove != currentMeta) {
|
||||||
|
return false; // Prevent placement of different types of chains
|
||||||
|
}
|
||||||
|
return true; // Same type, allow placement
|
||||||
|
}
|
||||||
|
|
||||||
|
// Other checks for fences, walls, slabs, etc.
|
||||||
|
if (blockAbove instanceof BlockFence || blockAbove instanceof BlockWall) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (blockAbove instanceof BlockSlab && !blockAbove.isOpaqueCube() && (metaAbove & 8) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (blockAbove instanceof BlockStairs && (metaAbove & 4) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the block above is solid on the bottom
|
||||||
|
return blockAbove.isSideSolid(world, x, y + 1, z, ForgeDirection.DOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,64 @@
|
|||||||
|
package com.zivilon.cinder_loe.blocks;
|
||||||
|
|
||||||
|
import com.zivilon.cinder_loe.LoECreativeTabs;
|
||||||
|
import com.zivilon.cinder_loe.util.Utilities;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import lotr.common.LOTRCreativeTabs;
|
||||||
|
import lotr.common.block.LOTRBlockBrickBase;
|
||||||
|
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 java.lang.reflect.Field;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CinderFurBlock extends Block {
|
||||||
|
protected IIcon[] brickIcons;
|
||||||
|
protected String[] brickNames;
|
||||||
|
|
||||||
|
|
||||||
|
public CinderFurBlock() {
|
||||||
|
super(Material.cloth);
|
||||||
|
this.setCreativeTab(LoECreativeTabs.tabBlockLoE);
|
||||||
|
setBlockTextureName("lotr:cinderfur");
|
||||||
|
setBlockName("lotr:cinderfur");
|
||||||
|
setStepSound(Block.soundTypeCloth);
|
||||||
|
this.setBrickNames("brown", "gray", "black", "white", "obsidian", "bearblack", "bearbrown", "lion", "lioness");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setBrickNames(String ... names) {
|
||||||
|
this.brickNames = names;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public void registerBlockIcons(IIconRegister iconregister) {
|
||||||
|
this.brickIcons = new IIcon[this.brickNames.length];
|
||||||
|
for (int i = 0; i < this.brickNames.length; ++i) {
|
||||||
|
String texturePath = this.getTextureName() + "_" + this.brickNames[i];
|
||||||
|
System.out.println("Registering texture: " + texturePath); // Debug log
|
||||||
|
this.brickIcons[i] = iconregister.registerIcon(texturePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public IIcon getIcon(int side, int meta) {
|
||||||
|
return this.brickIcons[meta];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int damageDropped(int meta) {
|
||||||
|
return meta;
|
||||||
|
}
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
|
||||||
|
for (int i = 0; i < this.brickNames.length; ++i) {
|
||||||
|
list.add(new ItemStack(item, 1, i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
package com.zivilon.cinder_loe.items;
|
||||||
|
|
||||||
|
import com.zivilon.cinder_loe.LoECreativeTabs;
|
||||||
|
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 java.util.List;
|
||||||
|
|
||||||
|
public class CinderFurItem extends Item {
|
||||||
|
public IIcon[] icons;
|
||||||
|
|
||||||
|
public CinderFurItem() {
|
||||||
|
super();
|
||||||
|
this.setCreativeTab(LoECreativeTabs.tabMiscLoE);
|
||||||
|
setHasSubtypes(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerIcons(IIconRegister iconRegister) {
|
||||||
|
icons = new IIcon[7];
|
||||||
|
for (int i = 0; i < 7; i++) {
|
||||||
|
icons[i] = iconRegister.registerIcon("lotr:cinder_fur_item_" + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUnlocalizedName(ItemStack item) {
|
||||||
|
return "item.cinder_fur_item_" + item.getItemDamage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IIcon getIconIndex(ItemStack item) {
|
||||||
|
return getIcon(item, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IIcon getIcon(ItemStack stack, int renderPass) {
|
||||||
|
int dmg = stack.getItemDamage();
|
||||||
|
|
||||||
|
// Ensure dmg is within the expected range of subtypes
|
||||||
|
if (dmg < 7) {
|
||||||
|
return icons[dmg];
|
||||||
|
}
|
||||||
|
return icons[0]; // Default to 0 if out of bounds
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getSubItems(Item item, CreativeTabs tab, List list) {
|
||||||
|
for (int i = 0; i < 7; i++) {
|
||||||
|
list.add(new ItemStack(item, 1, i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 955 B |
|
After Width: | Height: | Size: 980 B |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 228 B |
|
Before Width: | Height: | Size: 237 B |
|
Before Width: | Height: | Size: 266 B |
|
Before Width: | Height: | Size: 266 B |
|
Before Width: | Height: | Size: 215 B |
|
Before Width: | Height: | Size: 212 B |
|
Before Width: | Height: | Size: 235 B |
|
Before Width: | Height: | Size: 235 B |
|
Before Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 5.3 KiB |
|
After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 941 B |
|
After Width: | Height: | Size: 933 B |
|
After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 365 B |
|
Before Width: | Height: | Size: 328 B |
|
Before Width: | Height: | Size: 5.0 KiB |