mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-18 11:29:23 +00:00
Work on items from wood - part 2
This commit is contained in:
1 parent
38c1aa5b4b
commit
cee31027e6
28 files changed
+1020
-680
No files matched your search
@@ -56,15 +56,11 @@ public class ExtraTrees extends AbstractMod {
|
||||
public static Item itemMisc;
|
||||
public static Item itemFood;
|
||||
public static Block blockStairs;
|
||||
//public static Block blockLog;
|
||||
public static BlockCarpentry blockCarpentry;
|
||||
//public static Block blockPlanks;
|
||||
public static Block blockMachine;
|
||||
public static Block blockFence;
|
||||
public static BlockCarpentry blockPanel;
|
||||
public static Block blockKitchen;
|
||||
public static Block blockSlab;
|
||||
public static Block blockDoubleSlab;
|
||||
public static Item itemHammer;
|
||||
public static Item itemDurableHammer;
|
||||
public static Block blockGate;
|
||||
|
||||
@@ -1,160 +0,0 @@
|
||||
package binnie.extratrees.block;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.block.IBlockMetadata;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import forestry.api.core.Tabs;
|
||||
import net.minecraft.block.BlockWoodSlab;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlockETSlab extends BlockWoodSlab implements IBlockMetadata {
|
||||
public BlockETSlab(final boolean par2) {
|
||||
this.setCreativeTab(Tabs.tabArboriculture);
|
||||
this.setHardness(2.0f).setResistance(5.0f);
|
||||
setSoundType(SoundType.WOOD);
|
||||
// if (!this.field_150004_a) {
|
||||
// this.useNeighborBrightness = true;
|
||||
// }
|
||||
this.setLightOpacity(0);
|
||||
this.setRegistryName("slabs" + (par2 ? "Double" : "Single"));
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public ArrayList<ItemStack> getDrops(final World world, final int x, final int y, final int z, final int blockMeta, final int fortune) {
|
||||
// final ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
||||
// drops.addAll(BlockMetadata.getBlockDropped((IBlockMetadata) ExtraTrees.blockSlab, world, x, y, z, blockMeta));
|
||||
// if (this.field_150004_a) {
|
||||
// drops.addAll(BlockMetadata.getBlockDropped((IBlockMetadata) ExtraTrees.blockSlab, world, x, y, z, blockMeta));
|
||||
// }
|
||||
// return drops;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean removedByPlayer(final World world, final EntityPlayer player, final int x, final int y, final int z) {
|
||||
// return BlockMetadata.breakBlock(this, player, world, x, y, z);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(final World var1, final int i) {
|
||||
return new TileEntityMetadata();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean hasTileEntity(final int meta) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean onBlockEventReceived(final World par1World, final int par2, final int par3, final int par4, final int par5, final int par6) {
|
||||
// super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6);
|
||||
// final TileEntity tileentity = par1World.getTileEntity(par2, par3, par4);
|
||||
// return tileentity != null && tileentity.receiveClientEvent(par5, par6);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getPlacedMeta(final ItemStack stack, final World world, final int x, final int y, final int z, final ForgeDirection clickedBlock) {
|
||||
// return TileEntityMetadata.getItemDamage(stack);
|
||||
// }
|
||||
|
||||
//TODO
|
||||
@Override
|
||||
public boolean isDouble() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlacedMeta(ItemStack p0, World p1, BlockPos pos, EnumFacing p5) {
|
||||
return TileEntityMetadata.getItemDamage(p0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDroppedMeta(final int blockMeta, final int tileMeta) {
|
||||
return tileMeta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockName(final ItemStack par1ItemStack) {
|
||||
final int meta = TileEntityMetadata.getItemDamage(par1ItemStack);
|
||||
return Binnie.Language.localise(ExtraTrees.instance, "block.woodslab.name", PlankType.ExtraTreePlanks.values()[meta].getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBlockTooltip(final ItemStack par1ItemStack, final List par3List) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropAsStack(World p0, BlockPos pos, ItemStack p4) {
|
||||
// this.dropBlockAsItem(world, x, y, z, drop);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(final Item itemIn, final CreativeTabs par2CreativeTabs, final List<ItemStack> itemList) {
|
||||
// if (this.field_150004_a) {
|
||||
// return;
|
||||
// }
|
||||
// for (int i = 0; i < PlankType.ExtraTreePlanks.values().length; ++i) {
|
||||
// itemList.add(TileEntityMetadata.getItemStack(this, i));
|
||||
// }
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public IIcon getIcon(final IBlockAccess world, final int x, final int y, final int z, final int side) {
|
||||
// final TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
|
||||
// if (tile != null) {
|
||||
// return this.getIcon(side, tile.getTileMetadata());
|
||||
// }
|
||||
// return super.getIcon(world, x, y, z, side);
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public IIcon getIcon(final int side, final int meta) {
|
||||
// return PlankType.ExtraTreePlanks.values()[meta].getIcon();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void breakBlock(final World par1World, final int par2, final int par3, final int par4, final Block par5, final int par6) {
|
||||
// super.breakBlock(par1World, par2, par3, par4, par5, par6);
|
||||
// par1World.removeTileEntity(par2, par3, par4);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isOpaqueCube() {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isWood(final IBlockAccess world, final int x, final int y, final int z) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getFlammability(final IBlockAccess world, final int x, final int y, final int z, final ForgeDirection face) {
|
||||
// return 20;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isFlammable(final IBlockAccess world, final int x, final int y, final int z, final ForgeDirection face) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getFireSpreadSpeed(final IBlockAccess world, final int x, final int y, final int z, final ForgeDirection face) {
|
||||
// return 5;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public ItemStack getPickBlock(final MovingObjectPosition target, final World world, final int x, final int y, final int z) {
|
||||
// return BlockMetadata.getPickBlock(world, x, y, z);
|
||||
// }
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
package binnie.extratrees.block;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.block.IBlockMetadata;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import forestry.api.core.Tabs;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlockETStairs extends BlockStairs implements IBlockMetadata {
|
||||
// @Override
|
||||
// public int getRenderType() {
|
||||
// return ExtraTrees.stairsID;
|
||||
// }
|
||||
|
||||
public BlockETStairs(final Block par2Block) {
|
||||
super(Blocks.OAK_STAIRS.getDefaultState());
|
||||
this.setCreativeTab(Tabs.tabArboriculture);
|
||||
this.setRegistryName("stairs");
|
||||
this.setResistance(5.0f);
|
||||
this.setHardness(2.0f);
|
||||
this.setSoundType(SoundType.WOOD);
|
||||
this.useNeighborBrightness = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(final Item itemIn, final CreativeTabs par2CreativeTabs, final List<ItemStack> itemList) {
|
||||
for (int i = 0; i < PlankType.ExtraTreePlanks.values().length; ++i) {
|
||||
itemList.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public IIcon getIcon(final IBlockAccess world, final int x, final int y, final int z, final int side) {
|
||||
// final TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
|
||||
// if (tile != null) {
|
||||
// return this.getIcon(side, tile.getTileMetadata());
|
||||
// }
|
||||
// return super.getIcon(world, x, y, z, side);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public IIcon getIcon(final int side, final int meta) {
|
||||
// return WoodManager.getPlankType(meta + 32).getIcon();
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public void dropAsStack(final World world, final int x, final int y, final int z, final ItemStack drop) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public ArrayList<ItemStack> getDrops(final World world, final int x, final int y, final int z, final int blockMeta, final int fortune) {
|
||||
// return BlockMetadata.getBlockDropped(this, world, x, y, z, blockMeta);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean removedByPlayer(final World world, final EntityPlayer player, final int x, final int y, final int z) {
|
||||
// return BlockMetadata.breakBlock(this, player, world, x, y, z);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(final World var1, final int i) {
|
||||
return new TileEntityMetadata();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean hasTileEntity(final int meta) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean onBlockEventReceived(final World par1World, final int par2, final int par3, final int par4, final int par5, final int par6) {
|
||||
// super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6);
|
||||
// final TileEntity tileentity = par1World.getTileEntity(par2, par3, par4);
|
||||
// return tileentity != null && tileentity.receiveClientEvent(par5, par6);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getPlacedMeta(final ItemStack stack, final World world, final int x, final int y, final int z, final ForgeDirection clickedBlock) {
|
||||
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public int getPlacedMeta(ItemStack p0, World p1, BlockPos pos, EnumFacing p5) {
|
||||
return TileEntityMetadata.getItemDamage(p0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDroppedMeta(final int blockMeta, final int tileMeta) {
|
||||
return tileMeta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockName(final ItemStack par1ItemStack) {
|
||||
final int meta = TileEntityMetadata.getItemDamage(par1ItemStack);
|
||||
return Binnie.Language.localise(ExtraTrees.instance, "block.woodstairs.name", WoodManager.getPlankType(meta + 32).getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBlockTooltip(final ItemStack par1ItemStack, final List par3List) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropAsStack(World p0, BlockPos pos, ItemStack p4) {
|
||||
//this.dropBlockAsItem(world, x, y, z, drop);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void breakBlock(final World par1World, final int par2, final int par3, final int par4, final Block par5, final int par6) {
|
||||
// super.breakBlock(par1World, par2, par3, par4, par5, par6);
|
||||
// par1World.removeTileEntity(par2, par3, par4);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isWood(final IBlockAccess world, final int x, final int y, final int z) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getFlammability(final IBlockAccess world, final int x, final int y, final int z, final ForgeDirection face) {
|
||||
// return 20;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isFlammable(final IBlockAccess world, final int x, final int y, final int z, final ForgeDirection face) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getFireSpreadSpeed(final IBlockAccess world, final int x, final int y, final int z, final ForgeDirection face) {
|
||||
// return 5;
|
||||
// }
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package binnie.extratrees.block;
|
||||
|
||||
import binnie.Constants;
|
||||
import binnie.extratrees.api.IDesignMaterial;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
|
||||
@@ -15,7 +16,7 @@ public enum EnumExtraTreeLog implements IWoodType {
|
||||
Alder("Alder", PlankType.ExtraTreePlanks.Alder),
|
||||
Beech("Beech", PlankType.ExtraTreePlanks.Beech),
|
||||
Hawthorn("Hawthorn", PlankType.ExtraTreePlanks.Hawthorn),
|
||||
Banana("Banana"),
|
||||
Banana("Banana", PlankType.ExtraTreePlanks.Banana),
|
||||
Yew("Yew", PlankType.ExtraTreePlanks.Yew),
|
||||
Cypress("Cypress", PlankType.ExtraTreePlanks.Cypress),
|
||||
Fir("Fir", PlankType.ExtraTreePlanks.Fir),
|
||||
@@ -44,18 +45,12 @@ public enum EnumExtraTreeLog implements IWoodType {
|
||||
Eucalyptus3("Eucalyptus", PlankType.ExtraTreePlanks.Eucalyptus),
|
||||
Cinnamon("Cinnamon", PlankType.VanillaPlanks.JUNGLE),
|
||||
PinkIvory("Pink Ivory", PlankType.ExtraTreePlanks.PinkIvory),
|
||||
EMPTY("EMPTY");//TODO change name/create wood for SHRUBS
|
||||
EMPTY("EMPTY", PlankType.VanillaPlanks.OAK);//TODO change name/create wood for SHRUBS
|
||||
|
||||
String name;
|
||||
IDesignMaterial plank;
|
||||
IPlankType plank;
|
||||
|
||||
|
||||
EnumExtraTreeLog(final String name) {
|
||||
this.plank = null;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
EnumExtraTreeLog(final String name, final IDesignMaterial plank) {
|
||||
EnumExtraTreeLog(final String name, final IPlankType plank) {
|
||||
this.name = name;
|
||||
this.plank = plank;
|
||||
}
|
||||
@@ -97,27 +92,27 @@ public enum EnumExtraTreeLog implements IWoodType {
|
||||
|
||||
@Override
|
||||
public String getHeartTexture() {
|
||||
return "blocks/logs/" + name().toLowerCase() + "Trunk";
|
||||
return Constants.EXTRA_TREES_MOD_ID + ":blocks/logs/" + name().toLowerCase() + "Trunk";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDoorLowerTexture() {
|
||||
return "blocks/door.standard.lower";
|
||||
return Constants.EXTRA_TREES_MOD_ID + ":blocks/door.standard.lower";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDoorUpperTexture() {
|
||||
return "blocks/door.standard.upper";
|
||||
return Constants.EXTRA_TREES_MOD_ID + ":blocks/door.standard.upper";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBarkTexture() {
|
||||
return "blocks/logs/" + name().toLowerCase() + "Bark";
|
||||
return Constants.EXTRA_TREES_MOD_ID + ":blocks/logs/" + name().toLowerCase() + "Bark";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlankTexture() {
|
||||
return "blocks/planks/" + name();
|
||||
return plank.getPlankTextureName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package binnie.extratrees.block;
|
||||
|
||||
import binnie.craftgui.resource.Texture;
|
||||
import binnie.extratrees.api.IDesignMaterial;
|
||||
|
||||
public interface IPlankType extends IDesignMaterial {
|
||||
// IIcon getIcon();
|
||||
|
||||
String getPlankTextureName();
|
||||
String getDescription();
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package binnie.extratrees.block;
|
||||
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
|
||||
public interface IWoodKind {
|
||||
PropertyEnum<EnumExtraTreeLog> getVariant();
|
||||
EnumExtraTreeLog getWoodType(int meta);
|
||||
WoodBlockKind getWoodKind();
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package binnie.extratrees.block;
|
||||
|
||||
import binnie.core.block.ItemMetadata;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemETSlab extends ItemMetadata {
|
||||
private final boolean isFullBlock;
|
||||
private final BlockETSlab theHalfSlab;
|
||||
private final BlockETSlab doubleSlab;
|
||||
|
||||
public ItemETSlab(final Block block) {
|
||||
super(block);
|
||||
this.theHalfSlab = (BlockETSlab) ExtraTrees.blockSlab;
|
||||
this.doubleSlab = (BlockETSlab) ExtraTrees.blockDoubleSlab;
|
||||
this.isFullBlock = (block != this.theHalfSlab);
|
||||
this.setMaxDamage(0);
|
||||
this.setHasSubtypes(true);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public boolean onItemUse(final ItemStack par1ItemStack, final EntityPlayer par2EntityPlayer, final World par3World, final int par4, final int par5, final int par6, final int par7, final float par8, final float par9, final float par10) {
|
||||
// if (this.isFullBlock) {
|
||||
// return super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
|
||||
// }
|
||||
// if (par1ItemStack.stackSize == 0) {
|
||||
// return false;
|
||||
// }
|
||||
// if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) {
|
||||
// return false;
|
||||
// }
|
||||
// final Block i1 = par3World.getBlock(par4, par5, par6);
|
||||
// final int j1 = par3World.getBlockMetadata(par4, par5, par6);
|
||||
// final int tileMeta = TileEntityMetadata.getTileMetadata(par3World, par4, par5, par6);
|
||||
// final int k1 = j1 & 0x7;
|
||||
// final boolean flag = (j1 & 0x8) != 0x0;
|
||||
// if (((par7 == 1 && !flag) || (par7 == 0 && flag)) && i1 == this.theHalfSlab && tileMeta == par1ItemStack.getItemDamage()) {
|
||||
// if (par3World.checkNoEntityCollision(this.doubleSlab.getCollisionBoundingBoxFromPool(par3World, par4, par5, par6)) && par3World.setBlock(par4, par5, par6, this.doubleSlab, k1, 3)) {
|
||||
// final TileEntityMetadata tile = TileEntityMetadata.getTile(par3World, par4, par5, par6);
|
||||
// if (tile != null) {
|
||||
// tile.setTileMetadata(tileMeta, true);
|
||||
// }
|
||||
// --par1ItemStack.stackSize;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// return this.func_77888_a(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7) || super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
|
||||
// }
|
||||
|
||||
private boolean func_77888_a(final ItemStack par1ItemStack, final EntityPlayer par2EntityPlayer, final World par3World, int par4, int par5, int par6, final int par7) {
|
||||
if (par7 == 0) {
|
||||
--par5;
|
||||
}
|
||||
if (par7 == 1) {
|
||||
++par5;
|
||||
}
|
||||
if (par7 == 2) {
|
||||
--par6;
|
||||
}
|
||||
if (par7 == 3) {
|
||||
++par6;
|
||||
}
|
||||
if (par7 == 4) {
|
||||
--par4;
|
||||
}
|
||||
if (par7 == 5) {
|
||||
++par4;
|
||||
}
|
||||
// final Block i1 = par3World.getBlock(par4, par5, par6);
|
||||
// final int j1 = par3World.getBlockMetadata(par4, par5, par6);
|
||||
// final int k1 = j1 & 0x7;
|
||||
// final int tileMeta = TileEntityMetadata.getTileMetadata(par3World, par4, par5, par6);
|
||||
// if (i1 == this.theHalfSlab && tileMeta == par1ItemStack.getItemDamage()) {
|
||||
// if (par3World.checkNoEntityCollision(this.doubleSlab.getCollisionBoundingBoxFromPool(par3World, par4, par5, par6)) && par3World.setBlock(par4, par5, par6, this.doubleSlab, k1, 3)) {
|
||||
// final TileEntityMetadata tile = TileEntityMetadata.getTile(par3World, par4, par5, par6);
|
||||
// if (tile != null) {
|
||||
// tile.setTileMetadata(tileMeta, false);
|
||||
// par3World.markBlockForUpdate(par4, par5, par6);
|
||||
// }
|
||||
// --par1ItemStack.stackSize;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package binnie.extratrees.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
||||
public class ItemETStairs extends ItemBlock {
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public IIcon getIconFromDamage(final int par1) {
|
||||
// return PlankType.ExtraTreePlanks.values()[par1].getIcon();
|
||||
// }
|
||||
|
||||
public ItemETStairs(final Block block) {
|
||||
super(block);
|
||||
this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
|
||||
this.setUnlocalizedName("stairs");
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean placeBlockAt(final ItemStack stack, final EntityPlayer player, final World world, final int x, final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ, final int metadata) {
|
||||
// final boolean done = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata);
|
||||
// final TileEntityMetadata tile = (TileEntityMetadata) world.getTileEntity(x, y, z);
|
||||
// if (tile != null) {
|
||||
// tile.setTileMetadata(stack.getItemDamage(), false);
|
||||
// }
|
||||
// return done;
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public String getItemStackDisplayName(final ItemStack par1ItemStack) {
|
||||
// return ((IBlockMetadata) this.field_150939_a).getBlockName(par1ItemStack);
|
||||
// }
|
||||
}
|
||||
@@ -1,19 +1,15 @@
|
||||
package binnie.extratrees.block;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.IInitializable;
|
||||
import binnie.core.Mods;
|
||||
import binnie.core.block.ItemMetadata;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
import binnie.core.liquid.ILiquidType;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.block.decor.BlockFence;
|
||||
import binnie.extratrees.block.decor.BlockGate;
|
||||
import binnie.extratrees.block.decor.BlockMultiFence;
|
||||
import binnie.extratrees.block.decor.FenceType;
|
||||
import binnie.extratrees.block.decor.MultiFenceRecipeEmbedded;
|
||||
import binnie.extratrees.block.decor.MultiFenceRecipeSize;
|
||||
import binnie.extratrees.block.decor.MultiFenceRecipeSolid;
|
||||
import binnie.extratrees.block.decor.*;
|
||||
import binnie.extratrees.block.log.BlockETLog;
|
||||
import binnie.extratrees.block.plank.BlockETPlank;
|
||||
import binnie.extratrees.block.slab.BlockETSlab;
|
||||
import binnie.extratrees.block.stairs.BlockETStairs;
|
||||
import binnie.extratrees.genetics.WoodAccess;
|
||||
import binnie.extratrees.item.ExtraTreeLiquid;
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
@@ -21,21 +17,12 @@ import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static binnie.extratrees.block.BlockETLog.woodTypes;
|
||||
import static binnie.extratrees.block.BlockETPlanks.plankTypes;
|
||||
|
||||
public class ModuleBlocks implements IInitializable {
|
||||
// public static int hedgeRenderID;
|
||||
@@ -43,82 +30,16 @@ public class ModuleBlocks implements IInitializable {
|
||||
@Override
|
||||
public void preInit() {
|
||||
PlankType.setup();
|
||||
//ExtraTrees.blockPlanks = new BlockETPlanks();
|
||||
|
||||
BlockETLog.init();
|
||||
BlockETPlank.init();
|
||||
BlockETSlab.init();
|
||||
BlockETStairs.init();
|
||||
|
||||
ExtraTrees.blockFence = new BlockFence("fence");
|
||||
|
||||
for (int i = 0; i < BlockETPlanks.GROUP_COUNT ; i++) {
|
||||
int finalI = i;
|
||||
BlockETPlanks blockETPlank = new BlockETPlanks(finalI, false) {
|
||||
@Override
|
||||
public PropertyEnum<EnumExtraTreeLog> getVariant() {return plankTypes[finalI];}
|
||||
};
|
||||
|
||||
GameRegistry.register(blockETPlank);
|
||||
Item plank = GameRegistry.register(new BlockETPlanks.PlankItemBlock<>(blockETPlank));
|
||||
WoodAccess.getInstance().registerWithVariants(blockETPlank, WoodBlockKind.PLANKS, plankTypes[finalI], false);
|
||||
ExtraTrees.proxy.setCustomStateMapper("plank", blockETPlank);
|
||||
|
||||
|
||||
//fireproof
|
||||
BlockETPlanks blockETPlankFireproof = new BlockETPlanks(finalI, true) {
|
||||
@Override
|
||||
public PropertyEnum<EnumExtraTreeLog> getVariant() {
|
||||
return plankTypes[finalI];
|
||||
}
|
||||
};
|
||||
GameRegistry.register(blockETPlankFireproof);
|
||||
ExtraTrees.proxy.setCustomStateMapper("plank", blockETPlankFireproof);
|
||||
Item plankFireproof = GameRegistry.register(new BlockETPlanks.PlankItemBlock<>(blockETPlankFireproof));
|
||||
WoodAccess.getInstance().registerWithVariants(blockETPlankFireproof, WoodBlockKind.PLANKS, plankTypes[finalI], true);
|
||||
|
||||
for (EnumExtraTreeLog l : plankTypes[finalI].getAllowedValues()) {
|
||||
BinnieCore.proxy.registermodel(plank, l.getMetadata() % BlockETPlanks.VARIANTS_PER_BLOCK, new ModelResourceLocation("extratrees:plank", "wood_type=" + l.getName()));
|
||||
BinnieCore.proxy.registermodel(plankFireproof, l.getMetadata() % BlockETPlanks.VARIANTS_PER_BLOCK, new ModelResourceLocation("extratrees:plank", "wood_type=" + l.getName()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < BlockETLog.GROUP_COUNT; i++) {
|
||||
int finalI = i;
|
||||
BlockETLog blockETLog = new BlockETLog(finalI, false) {
|
||||
@Override
|
||||
public PropertyEnum<EnumExtraTreeLog> getVariant() {
|
||||
return woodTypes[finalI];
|
||||
}
|
||||
};
|
||||
|
||||
GameRegistry.register(blockETLog);
|
||||
Item wood = GameRegistry.register(new BlockETLog.LogItemBlock<>(blockETLog));
|
||||
|
||||
WoodAccess.getInstance().registerWithVariants(blockETLog, WoodBlockKind.LOG, woodTypes[finalI], false);
|
||||
ExtraTrees.proxy.setCustomStateMapper("log", blockETLog);
|
||||
|
||||
//fireproof
|
||||
BlockETLog blockETLogFireproof = new BlockETLog(i, true) {
|
||||
@Override
|
||||
public PropertyEnum<EnumExtraTreeLog> getVariant() {
|
||||
return woodTypes[finalI];
|
||||
}
|
||||
};
|
||||
GameRegistry.register(blockETLogFireproof);
|
||||
ExtraTrees.proxy.setCustomStateMapper("log", blockETLogFireproof);
|
||||
Item woodFireproof = GameRegistry.register(new BlockETLog.LogItemBlock<>(blockETLogFireproof));
|
||||
for (EnumExtraTreeLog l : woodTypes[finalI].getAllowedValues()) {
|
||||
BinnieCore.proxy.registermodel(wood, l.getMetadata() % BlockETLog.VARIANTS_PER_BLOCK, new ModelResourceLocation("extratrees:log", "axis=y,wood_type=" + l.getName()));
|
||||
BinnieCore.proxy.registermodel(woodFireproof, l.getMetadata() % BlockETLog.VARIANTS_PER_BLOCK, new ModelResourceLocation("extratrees:log", "axis=y,wood_type=" + l.getName()));
|
||||
}
|
||||
WoodAccess.getInstance().registerWithVariants(blockETLogFireproof, WoodBlockKind.LOG, woodTypes[finalI], true);
|
||||
}
|
||||
|
||||
|
||||
ExtraTrees.blockGate = new BlockGate();
|
||||
ExtraTrees.blockDoor = new BlockETDoor();
|
||||
ExtraTrees.blockMultiFence = new BlockMultiFence();
|
||||
ExtraTrees.blockSlab = new BlockETSlab(false);
|
||||
ExtraTrees.blockDoubleSlab = new BlockETSlab(true);
|
||||
// ExtraTrees.blockStairs = new BlockETStairs(ExtraTrees.blockPlanks);
|
||||
// GameRegistry.register(ExtraTrees.blockPlanks);
|
||||
// GameRegistry.register(new ItemMetadata(ExtraTrees.blockPlanks).setRegistryName(ExtraTrees.blockPlanks.getRegistryName()));
|
||||
GameRegistry.register(ExtraTrees.blockFence);
|
||||
GameRegistry.register(new ItemMetadata(ExtraTrees.blockFence).setRegistryName(ExtraTrees.blockFence.getRegistryName()));
|
||||
GameRegistry.register(ExtraTrees.blockMultiFence);
|
||||
@@ -127,23 +48,17 @@ public class ModuleBlocks implements IInitializable {
|
||||
|
||||
GameRegistry.register(ExtraTrees.blockGate);
|
||||
GameRegistry.register(new ItemMetadata(ExtraTrees.blockGate).setRegistryName(ExtraTrees.blockGate.getRegistryName()));
|
||||
GameRegistry.register(ExtraTrees.blockSlab);
|
||||
GameRegistry.register(new ItemETSlab(ExtraTrees.blockSlab).setRegistryName(ExtraTrees.blockSlab.getRegistryName()));
|
||||
GameRegistry.register(ExtraTrees.blockDoubleSlab);
|
||||
GameRegistry.register(new ItemETSlab(ExtraTrees.blockDoubleSlab).setRegistryName(ExtraTrees.blockDoubleSlab.getRegistryName()));
|
||||
GameRegistry.register(ExtraTrees.blockDoor);
|
||||
GameRegistry.register(new ItemETDoor(ExtraTrees.blockDoor).setRegistryName(ExtraTrees.blockDoor.getRegistryName()));
|
||||
// GameRegistry.register(ExtraTrees.blockStairs);
|
||||
// GameRegistry.register(new ItemETStairs(ExtraTrees.blockStairs).setRegistryName(ExtraTrees.blockStairs.getRegistryName()));
|
||||
// GameRegistry.register(new ItemETStairs(ExtraTrees.blockStairs).setRegistryName(ExtraTrees.blockStairs.getRegistryName()));
|
||||
//BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(ExtraTrees.blockStairs), new StairItemRenderer());
|
||||
//BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(ExtraTrees.blockGate), new GateItemRenderer());
|
||||
for (final EnumExtraTreeLog plank : EnumExtraTreeLog.values()) {
|
||||
OreDictionary.registerOre("logWood", TreeManager.woodAccess.getStack(plank, WoodBlockKind.LOG, false));
|
||||
OreDictionary.registerOre("logWood", WoodAccess.getInstance().getStack(plank, WoodBlockKind.LOG, false));
|
||||
OreDictionary.registerOre("plankWood", WoodAccess.getInstance().getStack(plank, WoodBlockKind.PLANKS, false));
|
||||
}
|
||||
// GameRegistry.addSmelting(ExtraTrees.blockLog, new ItemStack(Items.COAL, 1, 1), 0.15f);
|
||||
for (final IPlankType plank2 : PlankType.ExtraTreePlanks.values()) {
|
||||
OreDictionary.registerOre("plankWood", plank2.getStack());
|
||||
}
|
||||
// FMLInterModComms.sendMessage("forestry", "add-fence-block", "ExtraTrees:fence");
|
||||
// FMLInterModComms.sendMessage("forestry", "add-fence-block", "ExtraTrees:gate");
|
||||
// FMLInterModComms.sendMessage("Forestry", "add-alveary-slab",
|
||||
@@ -170,7 +85,7 @@ public class ModuleBlocks implements IInitializable {
|
||||
public void postInit() {
|
||||
for (final PlankType.ExtraTreePlanks plank : PlankType.ExtraTreePlanks.values()) {
|
||||
final ItemStack planks = plank.getStack();
|
||||
final ItemStack slabs = TileEntityMetadata.getItemStack(ExtraTrees.blockSlab, plank.ordinal());
|
||||
//final ItemStack slabs = TileEntityMetadata.getItemStack(ExtraTrees.blockSlab, plank.ordinal());
|
||||
//final ItemStack stairs = TileEntityMetadata.getItemStack(ExtraTrees.blockStairs, plank.ordinal());
|
||||
//stairs.stackSize = 4;
|
||||
//GameRegistry.addRecipe(stairs.copy(), "# ", "## ", "###", '#', planks.copy());
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package binnie.extratrees.block;
|
||||
|
||||
import binnie.Constants;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.api.CarpentryManager;
|
||||
@@ -66,7 +67,8 @@ public class PlankType {
|
||||
Sweetgum(13997656),
|
||||
Rosewood(7738624),
|
||||
Gingko(16050106),
|
||||
PinkIvory(15502496);
|
||||
PinkIvory(15502496),
|
||||
Banana(0);
|
||||
|
||||
int color;
|
||||
//IIcon icon;
|
||||
@@ -80,6 +82,11 @@ public class PlankType {
|
||||
return ExtraTrees.proxy.localise("block.planks." + this.toString().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlankTextureName(){
|
||||
return Constants.EXTRA_TREES_MOD_ID + ":blocks/planks/" + name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return ExtraTrees.proxy.localise("block.planks." + this.toString().toLowerCase() + ".desc");
|
||||
@@ -116,7 +123,7 @@ public class PlankType {
|
||||
BIRCH(14139781),
|
||||
JUNGLE(11632732),
|
||||
ACACIA(12215095),
|
||||
DARKOAK(4599061);
|
||||
BIG_OAK(4599061);
|
||||
|
||||
int color;
|
||||
|
||||
@@ -134,6 +141,11 @@ public class PlankType {
|
||||
return ExtraTrees.proxy.localise("block.planks.vanilla." + this.toString().toLowerCase() + ".desc");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlankTextureName(){
|
||||
return "minecraft:blocks/planks_" + name().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColour() {
|
||||
return this.color;
|
||||
@@ -194,6 +206,11 @@ public class PlankType {
|
||||
this.woodType = woodType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlankTextureName(){
|
||||
return "forestry:blocks/wood/planks." + name().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return ExtraTrees.proxy.localise("block.planks.forestry." + this.toString().toLowerCase());
|
||||
@@ -246,6 +263,13 @@ public class PlankType {
|
||||
return ExtraTrees.proxy.localise("block.planks.ebxl." + this.toString().toLowerCase());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getPlankTextureName() {
|
||||
//TODO implement
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return ExtraTrees.proxy.localise("block.planks.ebxl." + this.toString().toLowerCase() + ".desc");
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package binnie.extratrees.block;
|
||||
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PropertyEnumWoodType extends PropertyEnum<EnumExtraTreeLog> {
|
||||
int group;
|
||||
|
||||
private PropertyEnumWoodType(Collection<EnumExtraTreeLog> allowedValues, int group) {
|
||||
super("wood_type", EnumExtraTreeLog.class, allowedValues);
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
public static PropertyEnumWoodType[] create(int variants_per_block){
|
||||
int groups = (int) Math.ceil(EnumExtraTreeLog.values().length / (float) variants_per_block);
|
||||
PropertyEnumWoodType[] result = new PropertyEnumWoodType[groups];
|
||||
for (int i = 0; i < groups; i++) {
|
||||
int finalI = i;
|
||||
List allowed = Arrays.stream(EnumExtraTreeLog.values()).filter(l -> l.getMetadata() >= finalI * variants_per_block && l.getMetadata() < finalI * variants_per_block + variants_per_block).collect(Collectors.toList());
|
||||
result[i] = new PropertyEnumWoodType(allowed, i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public EnumExtraTreeLog getFirstValue(){
|
||||
return getAllowedValues().iterator().next();
|
||||
}
|
||||
|
||||
public int getGroup() {
|
||||
return group;
|
||||
}
|
||||
}
|
||||
+62
-42
@@ -1,15 +1,26 @@
|
||||
package binnie.extratrees.block;
|
||||
package binnie.extratrees.block.log;
|
||||
|
||||
import binnie.Constants;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.block.EnumExtraTreeLog;
|
||||
import binnie.extratrees.block.IWoodKind;
|
||||
import binnie.extratrees.block.PropertyEnumWoodType;
|
||||
import binnie.extratrees.genetics.WoodAccess;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.api.core.Tabs;
|
||||
import net.minecraft.block.BlockLog;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -20,56 +31,24 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class BlockETLog extends BlockLog {
|
||||
public abstract class BlockETLog extends BlockLog implements IWoodKind, IStateMapperRegister, IItemModelRegister {
|
||||
protected static final int VARIANTS_PER_BLOCK = 4;
|
||||
protected static final int VARIANTS_META_MASK = VARIANTS_PER_BLOCK - 1;
|
||||
public static final int GROUP_COUNT = (int) Math.ceil(EnumExtraTreeLog.values().length / (float) VARIANTS_PER_BLOCK);
|
||||
public static final String BLOCK_NAME = "log";
|
||||
protected int offset = -1;
|
||||
protected boolean fireproof;
|
||||
protected static PropertyEnum<EnumExtraTreeLog>[] woodTypes;
|
||||
|
||||
static {
|
||||
|
||||
woodTypes = new PropertyEnum[GROUP_COUNT];
|
||||
for (int i = 0; i < GROUP_COUNT; i++) {
|
||||
int finalI = i;
|
||||
List allowed = Arrays.stream(EnumExtraTreeLog.values()).filter(l -> l.getMetadata() >= finalI * VARIANTS_PER_BLOCK && l.getMetadata() < finalI * VARIANTS_PER_BLOCK + VARIANTS_PER_BLOCK).collect(Collectors.toList());
|
||||
woodTypes[i] = PropertyEnum.create("wood_type", EnumExtraTreeLog.class, allowed);
|
||||
}
|
||||
}
|
||||
|
||||
public static class LogItemBlock<V extends BlockETLog> extends ItemBlock {
|
||||
EnumExtraTreeLog[] values;
|
||||
|
||||
public LogItemBlock(V block) {
|
||||
super(block);
|
||||
setHasSubtypes(true);
|
||||
setMaxDamage(0);
|
||||
setRegistryName(block.getRegistryName());
|
||||
values = block.getVariant().getAllowedValues().toArray(new EnumExtraTreeLog[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return "tile.log." + values[stack.getMetadata()].getName();
|
||||
}
|
||||
}
|
||||
protected static PropertyEnumWoodType[] types = PropertyEnumWoodType.create(VARIANTS_PER_BLOCK);
|
||||
|
||||
public BlockETLog(int offset, boolean fireproof) {
|
||||
this.setCreativeTab(Tabs.tabArboriculture);
|
||||
this.setRegistryName("log." + (fireproof ? "fireproof." : "") + offset);
|
||||
this.setRegistryName(BLOCK_NAME + "." + (fireproof ? "fireproof." : "") + offset);
|
||||
this.setResistance(5.0f);
|
||||
this.setHardness(2.0f);
|
||||
this.setSoundType(SoundType.WOOD);
|
||||
this.setUnlocalizedName("log." + (fireproof ? "fireproof." : "") + offset);
|
||||
this.setUnlocalizedName(BLOCK_NAME + "." + (fireproof ? "fireproof." : "") + offset);
|
||||
this.offset = offset;
|
||||
this.fireproof = fireproof;
|
||||
setDefaultState(this.blockState.getBaseState().withProperty(woodTypes[offset], EnumExtraTreeLog.values()[offset * VARIANTS_PER_BLOCK]).withProperty(LOG_AXIS, EnumAxis.Y));
|
||||
setDefaultState(this.blockState.getBaseState().withProperty(types[offset], types[offset].getFirstValue()).withProperty(LOG_AXIS, EnumAxis.Y));
|
||||
}
|
||||
|
||||
|
||||
@@ -131,7 +110,7 @@ public abstract class BlockETLog extends BlockLog {
|
||||
|
||||
@Override
|
||||
public final int damageDropped(IBlockState state) {
|
||||
return state.getValue(getVariant()).getMetadata() % 4;
|
||||
return state.getValue(getVariant()).getMetadata() % VARIANTS_PER_BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -150,7 +129,7 @@ public abstract class BlockETLog extends BlockLog {
|
||||
|
||||
@Override
|
||||
public final void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
|
||||
list.addAll(getVariant().getAllowedValues().stream().map(woodType -> new ItemStack(this, 1, woodType.getMetadata() % 4)).collect(Collectors.toList()));
|
||||
list.addAll(getVariant().getAllowedValues().stream().map(woodType -> new ItemStack(this, 1, woodType.getMetadata() % VARIANTS_PER_BLOCK)).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -181,4 +160,45 @@ public abstract class BlockETLog extends BlockLog {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WoodBlockKind getWoodKind() {
|
||||
return WoodBlockKind.LOG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
manager.registerItemModel(item, stack -> new ModelResourceLocation(Constants.EXTRA_TREES_MOD_ID + ":" + BLOCK_NAME, "axis=y,wood_type=" + getWoodType(stack.getMetadata()).getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerStateMapper() {
|
||||
ExtraTrees.proxy.setCustomStateMapper(BLOCK_NAME, this);
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
Arrays.stream(types).forEach(type -> {
|
||||
BlockETLog log = new BlockETLog(type.getGroup(), false) {
|
||||
@Override
|
||||
public PropertyEnum<EnumExtraTreeLog> getVariant() {
|
||||
return type;
|
||||
}
|
||||
};
|
||||
|
||||
BlockETLog log_fireproof = new BlockETLog(type.getGroup(), true) {
|
||||
@Override
|
||||
public PropertyEnum<EnumExtraTreeLog> getVariant() {
|
||||
return type;
|
||||
}
|
||||
};
|
||||
|
||||
ExtraTrees.proxy.registerItem(new ItemETLog<>(log));
|
||||
ExtraTrees.proxy.registerItem(new ItemETLog<>(log_fireproof));
|
||||
ExtraTrees.proxy.registerBlock(log);
|
||||
ExtraTrees.proxy.registerBlock(log_fireproof);
|
||||
|
||||
WoodAccess.getInstance().registerWithVariants(log, log.getWoodKind(), type, true);
|
||||
WoodAccess.getInstance().registerWithVariants(log_fireproof, log.getWoodKind(), type, false);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package binnie.extratrees.block.log;
|
||||
|
||||
import binnie.extratrees.block.EnumExtraTreeLog;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemETLog <V extends BlockETLog> extends ItemBlock {
|
||||
EnumExtraTreeLog[] values;
|
||||
|
||||
public ItemETLog(V block) {
|
||||
super(block);
|
||||
setHasSubtypes(true);
|
||||
setMaxDamage(0);
|
||||
setRegistryName(block.getRegistryName());
|
||||
values = block.getVariant().getAllowedValues().toArray(new EnumExtraTreeLog[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return "tile." + BlockETLog.BLOCK_NAME + "." + values[stack.getMetadata()].getName();
|
||||
}
|
||||
|
||||
}
|
||||
+54
-76
@@ -1,15 +1,25 @@
|
||||
package binnie.extratrees.block;
|
||||
package binnie.extratrees.block.plank;
|
||||
|
||||
import binnie.Constants;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.block.EnumExtraTreeLog;
|
||||
import binnie.extratrees.block.IWoodKind;
|
||||
import binnie.extratrees.block.PropertyEnumWoodType;
|
||||
import binnie.extratrees.block.log.BlockETLog;
|
||||
import binnie.extratrees.block.log.ItemETLog;
|
||||
import binnie.extratrees.genetics.WoodAccess;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.api.core.Tabs;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockPlanks;
|
||||
import net.minecraft.block.SoundType;
|
||||
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.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -26,30 +36,19 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.minecraft.block.BlockFence.*;
|
||||
|
||||
public class BlockETPlanks extends Block implements IItemModelRegister {
|
||||
public abstract class BlockETPlank extends Block implements IWoodKind, IItemModelRegister, IStateMapperRegister {
|
||||
protected static final int VARIANTS_PER_BLOCK = 16;
|
||||
protected static final int VARIANTS_META_MASK = VARIANTS_PER_BLOCK - 1;
|
||||
public static final String BLOCK_NAME = "plank";
|
||||
private final boolean fireproof;
|
||||
public static final int GROUP_COUNT = (int) Math.ceil(EnumExtraTreeLog.values().length / (float) VARIANTS_PER_BLOCK);
|
||||
protected int offset = -1;
|
||||
protected static PropertyEnum<EnumExtraTreeLog>[] plankTypes;
|
||||
protected static PropertyEnumWoodType[] types = PropertyEnumWoodType.create(VARIANTS_PER_BLOCK);
|
||||
|
||||
static {
|
||||
plankTypes = new PropertyEnum[GROUP_COUNT];
|
||||
for (int i = 0; i < GROUP_COUNT; i++) {
|
||||
int finalI = i;
|
||||
List allowed = Arrays.stream(EnumExtraTreeLog.values()).filter(l -> l.getMetadata() >= finalI * VARIANTS_PER_BLOCK && l.getMetadata() < finalI * VARIANTS_PER_BLOCK + VARIANTS_PER_BLOCK).collect(Collectors.toList());
|
||||
plankTypes[i] = PropertyEnum.create("wood_type", EnumExtraTreeLog.class, allowed);
|
||||
}
|
||||
}
|
||||
|
||||
public BlockETPlanks(int offset, boolean fireproof) {
|
||||
public BlockETPlank(int offset, boolean fireproof) {
|
||||
super(Material.WOOD);
|
||||
this.fireproof = fireproof;
|
||||
this.offset = offset;
|
||||
this.setRegistryName("plank." + (fireproof ? "fireproof." : "") + offset);
|
||||
this.setRegistryName(BLOCK_NAME + "." + (fireproof ? "fireproof." : "") + offset);
|
||||
this.setCreativeTab(Tabs.tabArboriculture);
|
||||
this.setResistance(5.0f);
|
||||
this.setHardness(2.0f);
|
||||
@@ -57,29 +56,6 @@ public class BlockETPlanks extends Block implements IItemModelRegister {
|
||||
this.setSoundType(SoundType.WOOD);
|
||||
}
|
||||
|
||||
public static class PlankItemBlock<V extends BlockETPlanks> extends ItemBlock {
|
||||
EnumExtraTreeLog[] values;
|
||||
|
||||
public PlankItemBlock(V block) {
|
||||
super(block);
|
||||
setHasSubtypes(true);
|
||||
setMaxDamage(0);
|
||||
setRegistryName(block.getRegistryName());
|
||||
values = block.getVariant().getAllowedValues().toArray(new EnumExtraTreeLog[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return "tile.plank." + values[stack.getMetadata()].getName();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public float getBlockHardness(IBlockState blockState, World worldIn, BlockPos pos) {
|
||||
int meta = getMetaFromState(blockState);
|
||||
@@ -114,7 +90,6 @@ public class BlockETPlanks extends Block implements IItemModelRegister {
|
||||
return getDefaultState().withProperty(getVariant(), woodType);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, getVariant());
|
||||
@@ -125,12 +100,6 @@ public class BlockETPlanks extends Block implements IItemModelRegister {
|
||||
list.addAll(getVariant().getAllowedValues().stream().map(woodType -> new ItemStack(this, 1, woodType.getMetadata() % VARIANTS_PER_BLOCK)).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
public PropertyEnum<EnumExtraTreeLog> getVariant(){
|
||||
return plankTypes[offset];
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int damageDropped(IBlockState state) {
|
||||
return state.getValue(getVariant()).getMetadata() % VARIANTS_PER_BLOCK;
|
||||
@@ -146,37 +115,46 @@ public class BlockETPlanks extends Block implements IItemModelRegister {
|
||||
return EnumExtraTreeLog.values()[offset * VARIANTS_PER_BLOCK + (meta & VARIANTS_META_MASK)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public WoodBlockKind getWoodKind() {
|
||||
return WoodBlockKind.PLANKS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerStateMapper() {
|
||||
ExtraTrees.proxy.setCustomStateMapper(BLOCK_NAME, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
manager.registerItemModel(item, stack -> new ModelResourceLocation(Constants.EXTRA_TREES_MOD_ID + ":" + BLOCK_NAME, "wood_type=" + getWoodType(stack.getMetadata()).getName()));
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
Arrays.stream(types).forEach(type -> {
|
||||
BlockETPlank plank = new BlockETPlank(type.getGroup(), false) {
|
||||
@Override
|
||||
public PropertyEnum<EnumExtraTreeLog> getVariant() {
|
||||
return type;
|
||||
}
|
||||
};
|
||||
|
||||
BlockETPlank plank_fireproof = new BlockETPlank(type.getGroup(), true) {
|
||||
@Override
|
||||
public PropertyEnum<EnumExtraTreeLog> getVariant() {
|
||||
return type;
|
||||
}
|
||||
};
|
||||
|
||||
ExtraTrees.proxy.registerItem(new ItemETPlank<>(plank));
|
||||
ExtraTrees.proxy.registerItem(new ItemETPlank<>(plank_fireproof));
|
||||
ExtraTrees.proxy.registerBlock(plank);
|
||||
ExtraTrees.proxy.registerBlock(plank_fireproof);
|
||||
|
||||
WoodAccess.getInstance().registerWithVariants(plank, plank.getWoodKind(), type, true);
|
||||
WoodAccess.getInstance().registerWithVariants(plank_fireproof, plank.getWoodKind(), type, false);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// public String getBlockName(final ItemStack par1ItemStack) {
|
||||
// final int meta = TileEntityMetadata.getItemDamage(par1ItemStack);
|
||||
// return Binnie.Language.localise(ExtraTrees.instance, "block.plank.name", PlankType.ExtraTreePlanks.values()[meta].getName());
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public IIcon getIcon(final IBlockAccess world, final int x, final int y, final int z, final int side) {
|
||||
// final TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
|
||||
// if (tile != null) {
|
||||
// return this.getIcon(side, tile.getTileMetadata());
|
||||
// }
|
||||
// return super.getIcon(world, x, y, z, side);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public IIcon getIcon(final int side, final int meta) {
|
||||
// return PlankType.ExtraTreePlanks.values()[meta].getIcon();
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public void registerBlockIcons(final IIconRegister register) {
|
||||
// for (final PlankType.ExtraTreePlanks plank : PlankType.ExtraTreePlanks.values()) {
|
||||
// plank.loadIcon(register);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package binnie.extratrees.block.plank;
|
||||
|
||||
import binnie.extratrees.block.EnumExtraTreeLog;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Created by Marcin on 03.11.2016.
|
||||
*/
|
||||
public class ItemETPlank<V extends BlockETPlank> extends ItemBlock {
|
||||
EnumExtraTreeLog[] values;
|
||||
|
||||
public ItemETPlank(V block) {
|
||||
super(block);
|
||||
setHasSubtypes(true);
|
||||
setMaxDamage(0);
|
||||
setRegistryName(block.getRegistryName());
|
||||
values = block.getVariant().getAllowedValues().toArray(new EnumExtraTreeLog[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return "tile." + BlockETPlank.BLOCK_NAME + "." + values[stack.getMetadata()].getName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
package binnie.extratrees.block.slab;
|
||||
|
||||
import binnie.Constants;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.block.EnumExtraTreeLog;
|
||||
import binnie.extratrees.block.IWoodKind;
|
||||
import binnie.extratrees.block.PropertyEnumWoodType;
|
||||
import binnie.extratrees.block.log.BlockETLog;
|
||||
import binnie.extratrees.block.log.ItemETLog;
|
||||
import binnie.extratrees.block.plank.BlockETPlank;
|
||||
import binnie.extratrees.genetics.WoodAccess;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.api.core.Tabs;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
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.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class BlockETSlab extends BlockSlab implements IWoodKind, IItemModelRegister, IStateMapperRegister{
|
||||
protected static final int VARIANTS_PER_BLOCK = 8;
|
||||
protected static final int VARIANTS_META_MASK = VARIANTS_PER_BLOCK - 1;
|
||||
public static final String BLOCK_NAME = "slab";
|
||||
private final boolean fireproof;
|
||||
private final int offset;
|
||||
protected static final PropertyEnumWoodType[] types = PropertyEnumWoodType.create(VARIANTS_PER_BLOCK);
|
||||
|
||||
public BlockETSlab(int offset, boolean fireproof) {
|
||||
super(Material.WOOD);
|
||||
this.fireproof = fireproof;
|
||||
this.offset = offset;
|
||||
setCreativeTab(Tabs.tabArboriculture);
|
||||
setHardness(2.0f);
|
||||
setResistance(5.0f);
|
||||
setSoundType(SoundType.WOOD);
|
||||
setLightOpacity(0);
|
||||
setRegistryName(BLOCK_NAME + "." + (fireproof ? "fireproof." : "") + (isDouble()?"double.":"") + offset);
|
||||
}
|
||||
|
||||
public EnumExtraTreeLog getWoodType(int meta) {
|
||||
return EnumExtraTreeLog.values()[offset * VARIANTS_PER_BLOCK + (meta & VARIANTS_META_MASK)];
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return this.isDouble() ? new BlockStateContainer(this, getVariant()) : new BlockStateContainer(this, HALF, getVariant());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
EnumExtraTreeLog woodType = getWoodType(meta);
|
||||
IBlockState iblockstate = this.getDefaultState().withProperty(getVariant(), woodType);
|
||||
|
||||
if (!this.isDouble()) {
|
||||
iblockstate = iblockstate.withProperty(HALF, (meta & 8) == 0 ? BlockSlab.EnumBlockHalf.BOTTOM : BlockSlab.EnumBlockHalf.TOP);
|
||||
}
|
||||
|
||||
return iblockstate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
int meta = damageDropped(state);
|
||||
|
||||
if (!this.isDouble() && state.getValue(HALF) == BlockSlab.EnumBlockHalf.TOP) {
|
||||
meta |= 8;
|
||||
}
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state) {
|
||||
EnumExtraTreeLog woodType = state.getValue(getVariant());
|
||||
return woodType.getMetadata() - offset * VARIANTS_PER_BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
|
||||
EnumExtraTreeLog woodType = state.getValue(getVariant());
|
||||
ItemStack slab = WoodAccess.getInstance().getStack(woodType, WoodBlockKind.SLAB, fireproof);
|
||||
return slab.getItem();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation") // this is the way the vanilla slabs work
|
||||
@Override
|
||||
public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) {
|
||||
EnumExtraTreeLog woodType = state.getValue(getVariant());
|
||||
ItemStack slab = WoodAccess.getInstance().getStack(woodType, WoodBlockKind.SLAB, fireproof);
|
||||
return new ItemStack(slab.getItem(), 1, getMetaFromState(state));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List<ItemStack> list) {
|
||||
if (!isDouble()) {
|
||||
list.addAll(getVariant().getAllowedValues().stream().map(woodType -> new ItemStack(this, 1, woodType.getMetadata() % VARIANTS_PER_BLOCK)).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockHardness(IBlockState blockState, World worldIn, BlockPos pos) {
|
||||
int meta = getMetaFromState(blockState);
|
||||
EnumExtraTreeLog woodType = getWoodType(meta);
|
||||
return woodType.getHardness();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(IBlockAccess world, BlockPos pos, EnumFacing face) {
|
||||
return fireproof ? 0 : 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(IBlockAccess world, BlockPos pos, EnumFacing face) {
|
||||
return fireproof ? 0 : 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(int meta) {
|
||||
EnumExtraTreeLog woodType = getWoodType(meta);
|
||||
return woodType.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDouble() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IProperty<?> getVariantProperty() {
|
||||
return getVariant();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Comparable<?> getTypeForItem(ItemStack stack) {
|
||||
return getWoodType(stack.getMetadata());
|
||||
}
|
||||
|
||||
@Override
|
||||
public WoodBlockKind getWoodKind() {
|
||||
return WoodBlockKind.SLAB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
if(!isDouble())
|
||||
manager.registerItemModel(item, stack -> new ModelResourceLocation(Constants.EXTRA_TREES_MOD_ID + ":" + BLOCK_NAME, "half=bottom,wood_type=" + getWoodType(stack.getMetadata()).getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerStateMapper() {
|
||||
if(isDouble())
|
||||
ExtraTrees.proxy.setCustomStateMapper(BlockETPlank.BLOCK_NAME, this);
|
||||
else
|
||||
ExtraTrees.proxy.setCustomStateMapper(BLOCK_NAME, this);
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
Arrays.stream(types).forEach(type -> {
|
||||
BlockETSlab slab = new BlockETSlab(type.getGroup(), false) {
|
||||
@Override
|
||||
public PropertyEnum<EnumExtraTreeLog> getVariant() {
|
||||
return type;
|
||||
}
|
||||
};
|
||||
|
||||
BlockETSlab slab_double = new BlockETSlab(type.getGroup(), false) {
|
||||
@Override
|
||||
public PropertyEnum<EnumExtraTreeLog> getVariant() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDouble() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
BlockETSlab slab_fireproof = new BlockETSlab(type.getGroup(), true) {
|
||||
@Override
|
||||
public PropertyEnum<EnumExtraTreeLog> getVariant() {
|
||||
return type;
|
||||
}
|
||||
};
|
||||
|
||||
BlockETSlab slab_double_fireproof = new BlockETSlab(type.getGroup(), true) {
|
||||
@Override
|
||||
public PropertyEnum<EnumExtraTreeLog> getVariant() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDouble() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
ExtraTrees.proxy.registerItem(new ItemETSlab<>(slab, slab_double));
|
||||
ExtraTrees.proxy.registerItem(new ItemETSlab<>(slab_fireproof, slab_double_fireproof));
|
||||
ExtraTrees.proxy.registerBlock(slab);
|
||||
ExtraTrees.proxy.registerBlock(slab_fireproof);
|
||||
ExtraTrees.proxy.registerBlock(slab_double);
|
||||
ExtraTrees.proxy.registerBlock(slab_double_fireproof);
|
||||
|
||||
WoodAccess.getInstance().registerWithVariants(slab, slab.getWoodKind(), type, true);
|
||||
WoodAccess.getInstance().registerWithVariants(slab_fireproof, slab.getWoodKind(), type, false);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package binnie.extratrees.block.slab;
|
||||
|
||||
import binnie.core.block.ItemMetadata;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.block.EnumExtraTreeLog;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemSlab;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemETSlab<V extends BlockETSlab> extends ItemSlab {
|
||||
EnumExtraTreeLog[] values;
|
||||
|
||||
public ItemETSlab(V block, V doubleBlock) {
|
||||
super(block, block, doubleBlock);
|
||||
setRegistryName(block.getRegistryName());
|
||||
values = block.getVariant().getAllowedValues().toArray(new EnumExtraTreeLog[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return "tile." + BlockETSlab.BLOCK_NAME + "." + values[stack.getMetadata()].getName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package binnie.extratrees.block.stairs;
|
||||
|
||||
import binnie.Constants;
|
||||
import binnie.core.models.ModelManager;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.block.*;
|
||||
import binnie.extratrees.genetics.WoodAccess;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.core.models.BlockModelEntry;
|
||||
import forestry.core.models.DefaultTextureGetter;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.ModelProcessingHelper;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class BlockETStairs extends BlockStairs implements IWoodKind, IItemModelRegister, IStateMapperRegister {
|
||||
private final boolean fireproof;
|
||||
protected static final int VARIANTS_PER_BLOCK = 1;
|
||||
protected static final PropertyEnumWoodType[] types = PropertyEnumWoodType.create(VARIANTS_PER_BLOCK);
|
||||
public static final String BLOCK_NAME = "stairs";
|
||||
private final int offset;
|
||||
|
||||
public BlockETStairs(int offset, boolean fireproof) {
|
||||
super(WoodAccess.getInstance().getBlock(types[offset].getFirstValue(), WoodBlockKind.PLANKS, fireproof));
|
||||
this.setCreativeTab(Tabs.tabArboriculture);
|
||||
this.setRegistryName(BLOCK_NAME + "." + (fireproof ? "fireproof." : "") + offset);
|
||||
this.offset = offset;
|
||||
this.fireproof = fireproof;
|
||||
this.setUnlocalizedName(types[offset].getFirstValue().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumExtraTreeLog getWoodType(int meta) {
|
||||
return types[offset].getFirstValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WoodBlockKind getWoodKind() {
|
||||
return WoodBlockKind.STAIRS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockHardness(IBlockState blockState, World worldIn, BlockPos pos) {
|
||||
int meta = getMetaFromState(blockState);
|
||||
EnumExtraTreeLog woodType = getWoodType(meta);
|
||||
return woodType.getHardness();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(IBlockAccess world, BlockPos pos, EnumFacing face) {
|
||||
if (fireproof) {
|
||||
return 0;
|
||||
}
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(IBlockAccess world, BlockPos pos, EnumFacing face) {
|
||||
if (fireproof) {
|
||||
return 0;
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
manager.registerItemModel(item, stack -> new ModelResourceLocation(Constants.EXTRA_TREES_MOD_ID + ":" + BLOCK_NAME + "." + getWoodType(0).getMetadata(), "facing=east,half=bottom,shape=straight"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerStateMapper() {
|
||||
ExtraTrees.proxy.setCustomStateMapper(BLOCK_NAME + "." + getWoodType(0).getMetadata(), this);
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
Arrays.stream(types).forEach(type -> {
|
||||
BlockETStairs stairs = new BlockETStairs(type.getGroup(), false) {
|
||||
@Override
|
||||
public PropertyEnum<EnumExtraTreeLog> getVariant() {
|
||||
return type;
|
||||
}
|
||||
};
|
||||
|
||||
BlockETStairs stairs_fireproof = new BlockETStairs(type.getGroup(), true) {
|
||||
@Override
|
||||
public PropertyEnum<EnumExtraTreeLog> getVariant() {
|
||||
return type;
|
||||
}
|
||||
};
|
||||
|
||||
ExtraTrees.proxy.registerItem(new ItemETStairs<>(stairs));
|
||||
ExtraTrees.proxy.registerItem(new ItemETStairs<>(stairs_fireproof));
|
||||
ExtraTrees.proxy.registerBlock(stairs);
|
||||
ExtraTrees.proxy.registerBlock(stairs_fireproof);
|
||||
|
||||
WoodAccess.getInstance().registerWithBlockState(stairs.getDefaultState(), stairs.getWoodKind(), type.getFirstValue(), true);
|
||||
WoodAccess.getInstance().registerWithBlockState(stairs_fireproof.getDefaultState(), stairs.getWoodKind(), type.getFirstValue(), false);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package binnie.extratrees.block.stairs;
|
||||
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
||||
public class ItemETStairs<V extends BlockETStairs> extends ItemBlock{
|
||||
|
||||
public ItemETStairs(final V block) {
|
||||
super(block);
|
||||
setRegistryName(block.getRegistryName());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package binnie.extratrees.genetics;
|
||||
|
||||
import binnie.extratrees.block.EnumExtraTreeLog;
|
||||
import forestry.api.arboriculture.IWoodAccess;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
@@ -28,16 +29,30 @@ public class WoodAccess implements IWoodAccess {
|
||||
for (V value : property.getAllowedValues()) {
|
||||
IBlockState blockState = woodTyped.getDefaultState().withProperty(property, value);
|
||||
if(fireproof) {
|
||||
wood.addWood(value, woodBlockKind, blockState);
|
||||
}else {
|
||||
woodFireproof.addWood(value, woodBlockKind, blockState);
|
||||
}else {
|
||||
wood.addWood(value, woodBlockKind, blockState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void registerWithBlockState(IBlockState blockState, WoodBlockKind woodBlockKind, EnumExtraTreeLog log, boolean fireproof) {
|
||||
if(fireproof) {
|
||||
woodFireproof.addWood(log, woodBlockKind, blockState);
|
||||
}else {
|
||||
wood.addWood(log, woodBlockKind, blockState);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack(IWoodType woodType, WoodBlockKind kind, boolean fireproof) {
|
||||
throw new NotImplementedException("");
|
||||
IBlockState state = fireproof?woodFireproof.getWood(woodType, kind) : wood.getWood(woodType, kind);
|
||||
if(state != null) {
|
||||
int metadata = state.getBlock().getMetaFromState(state);
|
||||
return new ItemStack(state.getBlock(), 1, metadata);
|
||||
} else {
|
||||
return TreeManager.woodAccess.getStack(woodType, kind, fireproof);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,8 +39,8 @@ public class WoodProvider implements IWoodProvider {
|
||||
@Override
|
||||
public void registerSprites(Item item, ITextureManager manager) {
|
||||
TextureMap textureMap = FMLClientHandler.instance().getClient().getTextureMapBlocks();
|
||||
trunk = textureMap.registerSprite(new ResourceLocation(modID, type.getHeartTexture()));
|
||||
bark = textureMap.registerSprite(new ResourceLocation(modID, type.getBarkTexture()));
|
||||
trunk = textureMap.registerSprite(new ResourceLocation(type.getHeartTexture()));
|
||||
bark = textureMap.registerSprite(new ResourceLocation(type.getBarkTexture()));
|
||||
|
||||
}
|
||||
|
||||
@@ -57,8 +57,7 @@ public class WoodProvider implements IWoodProvider {
|
||||
@Override
|
||||
public ItemStack getWoodStack() {
|
||||
if (type instanceof EnumExtraTreeLog) {
|
||||
int group = type.getMetadata() / EnumExtraTreeLog.values().length;
|
||||
return GameRegistry.makeItemStack(modID + ":log." + group, type.getMetadata() % 4, 1, null);
|
||||
return WoodAccess.getInstance().getStack(type, WoodBlockKind.LOG, false);
|
||||
} else {
|
||||
return TreeManager.woodAccess.getStack(type, WoodBlockKind.LOG, false);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user