mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-18 11:29:23 +00:00
Start to work on ceramic blocks
This commit is contained in:
1 parent
4b6e3e5424
commit
9e68539431
28 files changed
+1009
-661
No files matched your search
@@ -6,9 +6,9 @@ import binnie.botany.api.EnumSoilType;
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.botany.api.gardening.IBlockSoil;
|
||||
import binnie.botany.ceramic.BlockCeramic;
|
||||
import binnie.botany.ceramic.BlockCeramicBrick;
|
||||
import binnie.botany.ceramic.BlockCeramicPatterned;
|
||||
import binnie.botany.ceramic.BlockStained;
|
||||
import binnie.botany.ceramic.brick.BlockCeramicBrick;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.botany.core.BotanyGUI;
|
||||
import binnie.botany.core.ModuleCore;
|
||||
|
||||
@@ -2,23 +2,20 @@ package binnie.botany.ceramic;
|
||||
|
||||
import binnie.botany.CreativeTabBotany;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.core.block.BlockMetadata;
|
||||
import binnie.core.block.IBlockMetadata;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.util.TileUtil;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.core.blocks.IColoredBlock;
|
||||
import forestry.core.items.IColoredItem;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
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.util.math.RayTraceResult;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
@@ -26,11 +23,11 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockCeramic extends Block implements IBlockMetadata, IColoredBlock, IColoredItem, IItemModelRegister {
|
||||
public static final PropertyEnum<EnumFlowerColor> COLOUR = PropertyEnum.create("color", EnumFlowerColor.class);
|
||||
|
||||
public class BlockCeramic extends Block implements IColoredBlock, IItemModelRegister {
|
||||
public BlockCeramic() {
|
||||
super(Material.ROCK);
|
||||
this.setHardness(1.0f);
|
||||
@@ -47,96 +44,69 @@ public class BlockCeramic extends Block implements IBlockMetadata, IColoredBlock
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Adding Meta
|
||||
/*@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, COLOUR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return state.getValue(COLOUR).ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState().withProperty(COLOUR, EnumFlowerColor.values()[meta]);
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
return BlockMetadata.getBlockDropped(this, world, pos);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
|
||||
return BlockMetadata.breakBlock(this, player, world, pos);
|
||||
List<ItemStack> drops = new ArrayList<>();
|
||||
TileCeramic ceramic = TileUtil.getTile(world, pos, TileCeramic.class);
|
||||
if (ceramic != null) {
|
||||
drops = Collections.singletonList(ceramic.getStack());
|
||||
}
|
||||
boolean hasBeenBroken = world.setBlockToAir(pos);
|
||||
if (hasBeenBroken && BinnieCore.proxy.isSimulating(world) && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) {
|
||||
for (ItemStack drop : drops) {
|
||||
spawnAsEntity(world, pos, drop);
|
||||
}
|
||||
}
|
||||
return hasBeenBroken;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(final World var1, final int i) {
|
||||
return new TileEntityMetadata();
|
||||
public TileEntity createTileEntity(World world, IBlockState state) {
|
||||
return new TileCeramic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean eventReceived(IBlockState state, World worldIn, BlockPos pos, int id, int param) {
|
||||
super.eventReceived(state, worldIn, pos, id, param);
|
||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
return tileentity == null ? false : tileentity.receiveClientEvent(id, param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlacedMeta(final ItemStack stack, final World world, BlockPos pos, final EnumFacing clickedBlock) {
|
||||
return TileEntityMetadata.getItemDamage(stack);
|
||||
}
|
||||
|
||||
@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 EnumFlowerColor.get(meta).getColourName() + " Ceramic Block";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBlockTooltip(final ItemStack par1ItemStack, final List par3List) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropAsStack(final World world, final BlockPos pos, final ItemStack itemStack) {
|
||||
spawnAsEntity(world, pos, itemStack);
|
||||
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
|
||||
TileCeramic ceramic = TileUtil.getTile(worldIn, pos, TileCeramic.class);
|
||||
if(ceramic != null){
|
||||
ceramic.setColor(EnumFlowerColor.VALUES[stack.getItemDamage()]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(final Item itemIn, final CreativeTabs par2CreativeTabs, final List<ItemStack> itemList) {
|
||||
for (final EnumFlowerColor c : EnumFlowerColor.values()) {
|
||||
itemList.add(TileEntityMetadata.getItemStack(this, c.ordinal()));
|
||||
public void getSubBlocks(final Item item, final CreativeTabs tab, final List<ItemStack> itemList) {
|
||||
for (EnumFlowerColor c : EnumFlowerColor.values()) {
|
||||
itemList.add(new ItemStack(item, 1, c.getID()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
|
||||
return BlockMetadata.getPickBlock(world, pos);
|
||||
TileCeramic ceramic = TileUtil.getTile(world, pos, TileCeramic.class);
|
||||
if(ceramic != null){
|
||||
return ceramic.getStack();
|
||||
}
|
||||
return super.getPickBlock(state, target, world, pos, player);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
|
||||
return EnumFlowerColor.get(stack.getMetadata()).getColor(false);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int colorMultiplier(IBlockState state, IBlockAccess worldIn, BlockPos pos, int tintIndex) {
|
||||
return EnumFlowerColor.get(getMetaFromState(state)).getColor(false);
|
||||
public int colorMultiplier(IBlockState state, IBlockAccess world, BlockPos pos, int tintIndex) {
|
||||
TileCeramic ceramic = TileUtil.getTile(world, pos, TileCeramic.class);
|
||||
if(ceramic != null){
|
||||
return ceramic.getColor().getColor(false);
|
||||
}
|
||||
return EnumFlowerColor.get(0).getColor(false);
|
||||
}
|
||||
}
|
||||
@@ -1,528 +0,0 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import binnie.Constants;
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.CreativeTabBotany;
|
||||
import binnie.botany.ceramic.BlockCeramicBrick.BlockType;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.botany.items.BotanyItems;
|
||||
import binnie.core.block.BlockMetadata;
|
||||
import binnie.core.block.IBlockMetadata;
|
||||
import binnie.core.block.IMultipassBlock;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
import forestry.api.core.ISpriteRegister;
|
||||
import forestry.api.core.ITextureManager;
|
||||
import forestry.core.blocks.IColoredBlock;
|
||||
import forestry.core.render.TextureManager;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class BlockCeramicBrick extends Block implements IBlockMetadata, IMultipassBlock<BlockType>, IColoredBlock, ISpriteRegister {
|
||||
|
||||
public static final PropertyEnum<TileType> TYPE = PropertyEnum.create("type", TileType.class);
|
||||
|
||||
public BlockCeramicBrick() {
|
||||
super(Material.ROCK);
|
||||
this.setHardness(1.0f);
|
||||
this.setResistance(5.0f);
|
||||
this.setRegistryName("ceramicBrick");
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
}
|
||||
|
||||
private static BlockType getType(final int meta) {
|
||||
return new BlockType(meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
return BlockMetadata.getBlockDropped(this, world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
|
||||
return BlockMetadata.breakBlock(this, player, world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(final World var1, final int i) {
|
||||
return new TileEntityMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventReceived(IBlockState state, World worldIn, BlockPos pos, int id, int param) {
|
||||
super.eventReceived(state, worldIn, pos, id, param);
|
||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
return tileentity == null ? false : tileentity.receiveClientEvent(id, param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlacedMeta(final ItemStack stack, final World world, final BlockPos pos, final EnumFacing clickedBlock) {
|
||||
return TileEntityMetadata.getItemDamage(stack);
|
||||
}
|
||||
|
||||
@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 getType(meta).getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBlockTooltip(final ItemStack par1ItemStack, final List par3List) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropAsStack(World world, BlockPos pos, ItemStack itemStack) {
|
||||
spawnAsEntity(world, pos, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(final Item itemIn, final CreativeTabs par2CreativeTabs, final List<ItemStack> itemList) {
|
||||
for (final EnumFlowerColor c : EnumFlowerColor.values()) {
|
||||
final BlockType type = new BlockType(c, c, TileType.Tile);
|
||||
itemList.add(TileEntityMetadata.getItemStack(this, type.ordinal()));
|
||||
}
|
||||
for (final TileType type2 : TileType.values()) {
|
||||
if (type2.canDouble()) {
|
||||
itemList.add(new BlockType(EnumFlowerColor.Brown, EnumFlowerColor.Gold, type2).getStack(1));
|
||||
}
|
||||
}
|
||||
itemList.add(new BlockType(EnumFlowerColor.Gold, EnumFlowerColor.Gold, TileType.Split).getStack(1));
|
||||
itemList.add(new BlockType(EnumFlowerColor.Brown, EnumFlowerColor.Brown, TileType.Chequered).getStack(1));
|
||||
itemList.add(new BlockType(EnumFlowerColor.Gold, EnumFlowerColor.Brown, TileType.LargeBrick).getStack(1));
|
||||
}
|
||||
|
||||
// @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 getType(meta).getIcon(MultipassBlockRenderer.getLayer());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public void registerBlockIcons(final IIconRegister register) {
|
||||
// for (final TileType type : TileType.values()) {
|
||||
// for (int i = 0; i < 3; ++i) {
|
||||
// type.icons[i] = Botany.proxy.getIcon(register, "ceramic." + type.id + "." + i);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
|
||||
return BlockMetadata.getPickBlock(world, pos);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int colorMultiplier(IBlockState state, IBlockAccess world, BlockPos pos, int tintIndex) {
|
||||
BlockType type = getType(getMetaFromState(state));
|
||||
if (tintIndex == 0) {
|
||||
return 16777215;
|
||||
}
|
||||
if (tintIndex == 1) {
|
||||
return type.color1.getColor(false);
|
||||
}
|
||||
return type.color2.getColor(false);
|
||||
}
|
||||
|
||||
public enum TileType implements IStringSerializable {
|
||||
Tile("tile", "Ceramic Tile"),
|
||||
Brick("brick", "Ceramic Bricks"),
|
||||
StripeBrick("brickstripe", "Striped Ceramic Bricks"),
|
||||
LargeBrick("bricklarge", "Large Ceramic Bricks"),
|
||||
Split("split", "Split Ceramic Tile"),
|
||||
Chequered("cheque", "Chequered Ceramic Tile"),
|
||||
Mixed("mixed", "Mixed Ceramic Tile"),
|
||||
VerticalBrick("verticalbrick", "Vertical Ceramic Bricks"),
|
||||
VerticalStripeBrick("verticalbrickstripe", "Vertical Striped Ceramic Bricks"),
|
||||
VerticalLargeBrick("verticalbricklarge", "Large Vertical Ceramic Bricks");
|
||||
|
||||
String id;
|
||||
String name;
|
||||
TextureAtlasSprite[] sprites;
|
||||
|
||||
TileType(final String id, final String name) {
|
||||
this.sprites = new TextureAtlasSprite[3];
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static TileType get(final int id) {
|
||||
return values()[id % values().length];
|
||||
}
|
||||
|
||||
public boolean canDouble() {
|
||||
return this != TileType.Tile;
|
||||
}
|
||||
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
switch (this) {
|
||||
case Tile: {
|
||||
if (stacks.size() != 4) {
|
||||
return null;
|
||||
}
|
||||
int mortars = 0;
|
||||
int blocks = 0;
|
||||
int blockColor = -1;
|
||||
for (final ItemStack stack : stacks) {
|
||||
if (this.isMortar(stack)) {
|
||||
++mortars;
|
||||
} else {
|
||||
if (stack.getItem() != Item.getItemFromBlock(Botany.ceramic)) {
|
||||
return null;
|
||||
}
|
||||
++blocks;
|
||||
final int color = TileEntityMetadata.getItemDamage(stack);
|
||||
if (blockColor == -1) {
|
||||
blockColor = color;
|
||||
} else {
|
||||
if (blockColor != color) {
|
||||
return null;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mortars != 1) {
|
||||
return null;
|
||||
}
|
||||
final EnumFlowerColor c = EnumFlowerColor.get(blockColor);
|
||||
return new BlockType(c, c, TileType.Tile).getStack(3);
|
||||
}
|
||||
case Split: {
|
||||
if (stacks.size() != 4) {
|
||||
return null;
|
||||
}
|
||||
final int[] colors = {-1, -1};
|
||||
int altCounter = 0;
|
||||
for (final ItemStack stack2 : stacks) {
|
||||
final int alt = (altCounter != 0 && altCounter != 3) ? 1 : 0;
|
||||
if (stack2.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return null;
|
||||
}
|
||||
final BlockType type = new BlockType(stack2);
|
||||
if (type.type != TileType.Tile) {
|
||||
return null;
|
||||
}
|
||||
final int color2 = type.color1.ordinal();
|
||||
if (colors[alt] == -1) {
|
||||
colors[alt] = color2;
|
||||
} else if (colors[alt] != color2) {
|
||||
return null;
|
||||
}
|
||||
++altCounter;
|
||||
}
|
||||
return new BlockType(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), TileType.Split).getStack(4);
|
||||
}
|
||||
case Chequered: {
|
||||
if (stacks.size() != 4) {
|
||||
return null;
|
||||
}
|
||||
final int[] colors = {-1, -1};
|
||||
for (final ItemStack stack2 : stacks) {
|
||||
if (stack2.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return null;
|
||||
}
|
||||
final BlockType type2 = new BlockType(stack2);
|
||||
if (type2.type != TileType.Split) {
|
||||
return null;
|
||||
}
|
||||
final int color3 = type2.color1.ordinal();
|
||||
final int color4 = type2.color2.ordinal();
|
||||
if (colors[0] == -1) {
|
||||
colors[0] = color3;
|
||||
colors[1] = color4;
|
||||
} else {
|
||||
if (colors[0] != color3 || colors[1] != color4) {
|
||||
return null;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return new BlockType(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), TileType.Chequered).getStack(4);
|
||||
}
|
||||
case Mixed: {
|
||||
if (stacks.size() != 4) {
|
||||
return null;
|
||||
}
|
||||
final int[] colors = {-1, -1};
|
||||
for (final ItemStack stack2 : stacks) {
|
||||
if (stack2.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return null;
|
||||
}
|
||||
final BlockType type2 = new BlockType(stack2);
|
||||
if (type2.isTwoColors()) {
|
||||
return null;
|
||||
}
|
||||
final int color3 = type2.color1.ordinal();
|
||||
if (type2.type == TileType.Split) {
|
||||
if (colors[1] != -1) {
|
||||
return null;
|
||||
}
|
||||
colors[1] = color3;
|
||||
} else {
|
||||
if (type2.type != TileType.Chequered) {
|
||||
return null;
|
||||
}
|
||||
if (colors[0] == -1) {
|
||||
colors[0] = color3;
|
||||
} else if (colors[0] != color3) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
final int color4 = type2.color2.ordinal();
|
||||
}
|
||||
if (colors[0] == -1 || colors[1] == -1) {
|
||||
return null;
|
||||
}
|
||||
return new BlockType(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), TileType.Mixed).getStack(4);
|
||||
}
|
||||
case LargeBrick: {
|
||||
if (stacks.size() == 1) {
|
||||
final ItemStack stack3 = stacks.get(0);
|
||||
final BlockType type3 = new BlockType(stack3);
|
||||
if (type3.type == TileType.VerticalLargeBrick) {
|
||||
type3.type = this;
|
||||
return type3.getStack(1);
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
if (stacks.size() != 3) {
|
||||
return null;
|
||||
}
|
||||
final int[] colors = {-1, -1};
|
||||
int a = 0;
|
||||
int b = 0;
|
||||
for (final ItemStack stack4 : stacks) {
|
||||
if (stack4.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return null;
|
||||
}
|
||||
final BlockType type4 = new BlockType(stack4);
|
||||
if (type4.type != TileType.Tile) {
|
||||
return null;
|
||||
}
|
||||
final int color5 = type4.color1.ordinal();
|
||||
if (colors[0] == -1) {
|
||||
colors[0] = color5;
|
||||
++a;
|
||||
} else if (colors[0] == color5) {
|
||||
++a;
|
||||
} else if (colors[1] == -1) {
|
||||
colors[1] = color5;
|
||||
++b;
|
||||
} else {
|
||||
if (colors[1] != color5) {
|
||||
return null;
|
||||
}
|
||||
++b;
|
||||
}
|
||||
}
|
||||
if (colors[1] == -1) {
|
||||
colors[1] = colors[0];
|
||||
}
|
||||
return new BlockType(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), TileType.LargeBrick).getStack(3);
|
||||
}
|
||||
}
|
||||
case Brick:
|
||||
case StripeBrick: {
|
||||
if (stacks.size() == 1) {
|
||||
final ItemStack stack5 = stacks.get(0);
|
||||
final BlockType type = new BlockType(stack5);
|
||||
if (type.type == TileType.VerticalBrick) {
|
||||
type.type = this;
|
||||
return type.getStack(1);
|
||||
}
|
||||
if (type.type == TileType.StripeBrick) {
|
||||
type.type = this;
|
||||
return type.getStack(1);
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
if (stacks.size() != 4) {
|
||||
return null;
|
||||
}
|
||||
final int[] colors = {-1, -1};
|
||||
for (int index2 = 0; index2 < stacks.size(); ++index2) {
|
||||
final ItemStack stack4 = stacks.get(index2);
|
||||
if (stack4.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return null;
|
||||
}
|
||||
final BlockType type4 = new BlockType(stack4);
|
||||
if (type4.type != TileType.LargeBrick) {
|
||||
return null;
|
||||
}
|
||||
final int color5 = type4.color1.ordinal();
|
||||
final int color6 = type4.color2.ordinal();
|
||||
int alt2 = (index2 != 0 && index2 != 3) ? 1 : 0;
|
||||
if (this == TileType.StripeBrick) {
|
||||
alt2 = 0;
|
||||
}
|
||||
if (colors[alt2] == -1) {
|
||||
colors[alt2] = color5;
|
||||
colors[1 - alt2] = color6;
|
||||
} else if (colors[alt2] != color5 || colors[1 - alt2] != color6) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return new BlockType(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), this).getStack(4);
|
||||
}
|
||||
}
|
||||
case VerticalLargeBrick:
|
||||
case VerticalBrick:
|
||||
case VerticalStripeBrick: {
|
||||
if (stacks.size() != 1) {
|
||||
return null;
|
||||
}
|
||||
final ItemStack stack5 = stacks.get(0);
|
||||
final BlockType type = new BlockType(stack5);
|
||||
if (type.type == TileType.LargeBrick) {
|
||||
type.type = TileType.VerticalLargeBrick;
|
||||
return type.getStack(1);
|
||||
}
|
||||
if (type.type == TileType.Brick) {
|
||||
type.type = TileType.VerticalBrick;
|
||||
return type.getStack(1);
|
||||
}
|
||||
if (type.type == TileType.StripeBrick) {
|
||||
type.type = TileType.VerticalStripeBrick;
|
||||
return type.getStack(1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
default: {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isMortar(final ItemStack stack) {
|
||||
return stack.getItem() == Botany.misc && stack.getItemDamage() == BotanyItems.Mortar.ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
}
|
||||
|
||||
public static class BlockType {
|
||||
EnumFlowerColor color1;
|
||||
EnumFlowerColor color2;
|
||||
TileType type;
|
||||
|
||||
private BlockType(final EnumFlowerColor color1, final EnumFlowerColor color2, final TileType type) {
|
||||
this.color1 = color1;
|
||||
this.color2 = color2;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public boolean isTwoColors() {
|
||||
return this.type.canDouble() && this.color2 != this.color1;
|
||||
}
|
||||
|
||||
public BlockType(final ItemStack stack) {
|
||||
this(TileEntityMetadata.getItemDamage(stack));
|
||||
}
|
||||
|
||||
public ItemStack getStack(final int i) {
|
||||
final ItemStack s = TileEntityMetadata.getItemStack(Botany.ceramicBrick, this.ordinal());
|
||||
s.stackSize = i;
|
||||
return s;
|
||||
}
|
||||
|
||||
public BlockType(final int id) {
|
||||
this.color1 = EnumFlowerColor.get(id & 0xFF);
|
||||
this.color2 = EnumFlowerColor.get(id >> 8 & 0xFF);
|
||||
this.type = TileType.get(id >> 16 & 0xFF);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
String name = this.color1.getColourName();
|
||||
if (this.type.canDouble() && this.color2 != this.color1) {
|
||||
name = name + " & " + this.color2.getColourName();
|
||||
}
|
||||
return name + " " + this.type.name;
|
||||
}
|
||||
|
||||
public int ordinal() {
|
||||
return this.color1.ordinal() + this.color2.ordinal() * 256 + this.type.ordinal() * 256 * 256;
|
||||
}
|
||||
|
||||
public TextureAtlasSprite getSprite(int pass) {
|
||||
return this.type.sprites[pass];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderPasses() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BlockType getInventoryKey(ItemStack stack) {
|
||||
return getType(stack.getItemDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BlockType getWorldKey(IBlockState state) {
|
||||
return getType(getMetaFromState(state));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getSprite(BlockType type, int pass) {
|
||||
return type.getSprite(pass);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerSprites(ITextureManager manager) {
|
||||
for (final TileType type : TileType.values()) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
type.sprites[i] = TextureManager.registerSprite(new ResourceLocation(Constants.BOTANY_MOD_ID + ":blocks/ceramic." + type.id + "." + i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.ceramic.brick.CeramicBrickType;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -47,10 +48,10 @@ public class CeramicTileRecipe implements IRecipe {
|
||||
stacks.add(stack);
|
||||
}
|
||||
}
|
||||
for (final BlockCeramicBrick.TileType type : BlockCeramicBrick.TileType.values()) {
|
||||
final ItemStack stack2 = type.getRecipe(stacks);
|
||||
if (stack2 != null) {
|
||||
return stack2;
|
||||
for (CeramicBrickType type : CeramicBrickType.VALUES) {
|
||||
ItemStack result = type.getRecipe(stacks);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,16 +1,32 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import binnie.core.block.ItemMetadata;
|
||||
import net.minecraft.block.Block;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import forestry.core.items.IColoredItem;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemCeramic extends ItemMetadata {
|
||||
public ItemCeramic(final Block block) {
|
||||
public class ItemCeramic extends ItemBlock implements IColoredItem {
|
||||
public ItemCeramic(BlockCeramic block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(final int metadata) {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public int getColorFromItemStack(final ItemStack stack, final int p_82790_2_) {
|
||||
// return 16711935;
|
||||
// }
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
|
||||
return EnumFlowerColor.get(stack.getMetadata()).getColor(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getItemStackDisplayName(ItemStack itemStack) {
|
||||
return EnumFlowerColor.get(itemStack.getItemDamage()).getColourName() + " " + I18n.translateToLocal("tile.botany.ceramic.name").trim();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,46 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TileCeramic extends TileEntity {
|
||||
|
||||
protected EnumFlowerColor color;
|
||||
|
||||
public void setColor(EnumFlowerColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public EnumFlowerColor getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
compound.setInteger("Color", color.getID());
|
||||
return super.writeToNBT(compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
super.readFromNBT(compound);
|
||||
color = EnumFlowerColor.VALUES[compound.getInteger("Color")];
|
||||
}
|
||||
|
||||
public ItemStack getStack(){
|
||||
return getStack(1);
|
||||
}
|
||||
|
||||
public ItemStack getStack(int amount){
|
||||
int ID = 0;
|
||||
if(color != null){
|
||||
ID = color.getID();
|
||||
}
|
||||
return new ItemStack(Botany.ceramic, amount, ID);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
package binnie.botany.ceramic.brick;
|
||||
|
||||
import binnie.Constants;
|
||||
import binnie.botany.CreativeTabBotany;
|
||||
import binnie.botany.ceramic.TileCeramic;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.block.IMultipassBlock;
|
||||
import binnie.core.models.ModelManager;
|
||||
import binnie.core.models.ModelMutlipass;
|
||||
import binnie.core.util.TileUtil;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.ISpriteRegister;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.api.core.ITextureManager;
|
||||
import forestry.core.blocks.IColoredBlock;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockAccess;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockPos;
|
||||
import forestry.core.models.BlockModelEntry;
|
||||
import forestry.core.render.TextureManager;
|
||||
import net.minecraft.block.Block;
|
||||
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.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.common.property.ExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockCeramicBrick extends Block implements IMultipassBlock<CeramicBrickPair>, IColoredBlock, ISpriteRegister, IStateMapperRegister, IItemModelRegister {
|
||||
|
||||
public static final PropertyEnum<CeramicBrickType> TYPE = PropertyEnum.create("type", CeramicBrickType.class);
|
||||
|
||||
public BlockCeramicBrick() {
|
||||
super(Material.ROCK);
|
||||
this.setHardness(1.0f);
|
||||
this.setResistance(5.0f);
|
||||
this.setRegistryName("ceramicBrick");
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
|
||||
List<ItemStack> drops = new ArrayList<>();
|
||||
TileCeramic ceramic = TileUtil.getTile(world, pos, TileCeramic.class);
|
||||
if (ceramic != null) {
|
||||
drops = Collections.singletonList(ceramic.getStack());
|
||||
}
|
||||
boolean hasBeenBroken = world.setBlockToAir(pos);
|
||||
if (hasBeenBroken && BinnieCore.proxy.isSimulating(world) && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) {
|
||||
for (ItemStack drop : drops) {
|
||||
spawnAsEntity(world, pos, drop);
|
||||
}
|
||||
}
|
||||
return hasBeenBroken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, IBlockState state) {
|
||||
return new TileCeramicBrick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubBlocks(Item item, final CreativeTabs par2CreativeTabs, final List<ItemStack> itemList) {
|
||||
for (final EnumFlowerColor color : EnumFlowerColor.values()) {
|
||||
itemList.add(new CeramicBrickPair(color, color, CeramicBrickType.Tile).getStack(1));
|
||||
}
|
||||
for (CeramicBrickType type : CeramicBrickType.VALUES) {
|
||||
if (type.canDouble()) {
|
||||
itemList.add(new CeramicBrickPair(EnumFlowerColor.Brown, EnumFlowerColor.Gold, type).getStack(1));
|
||||
}
|
||||
}
|
||||
itemList.add(new CeramicBrickPair(EnumFlowerColor.Gold, EnumFlowerColor.Gold, CeramicBrickType.Split).getStack(1));
|
||||
itemList.add(new CeramicBrickPair(EnumFlowerColor.Brown, EnumFlowerColor.Brown, CeramicBrickType.Chequered).getStack(1));
|
||||
itemList.add(new CeramicBrickPair(EnumFlowerColor.Gold, EnumFlowerColor.Brown, CeramicBrickType.LargeBrick).getStack(1));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerStateMapper() {
|
||||
ModelLoader.setCustomStateMapper(this, new binnie.core.models.DefaultStateMapper());
|
||||
ModelManager.registerCustomBlockModel(new BlockModelEntry(
|
||||
new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":ceramicBrick", "normal"),
|
||||
new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":ceramicBrick", "inventory"),
|
||||
new ModelMutlipass(BlockCeramicBrick.class), this));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
manager.registerItemModel(item, new CeramicBrickMeshDefinition());
|
||||
}
|
||||
|
||||
private class CeramicBrickMeshDefinition implements ItemMeshDefinition{
|
||||
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack) {
|
||||
return new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":ceramicBrick", "inventory");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new ExtendedBlockState(this, new IProperty[]{TYPE}, new IUnlistedProperty[]{UnlistedBlockPos.POS, UnlistedBlockAccess.BLOCKACCESS});
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState().withProperty(TYPE, CeramicBrickType.VALUES[meta]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return state.getValue(TYPE).ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return ((IExtendedBlockState)super.getExtendedState(state, world, pos)).withProperty(UnlistedBlockPos.POS, pos).withProperty(UnlistedBlockAccess.BLOCKACCESS, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, ItemStack stack) {
|
||||
return getDefaultState().withProperty(TYPE, CeramicBrickType.get(meta >> 16 & 0xFF));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
|
||||
TileCeramicBrick ceramic = TileUtil.getTile(worldIn, pos, TileCeramicBrick.class);
|
||||
if(ceramic != null){
|
||||
int damage = stack.getItemDamage();
|
||||
ceramic.setColors(EnumFlowerColor.get(damage & 0xFF), EnumFlowerColor.get(damage >> 8 & 0xFF));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
|
||||
TileCeramicBrick ceramic = TileUtil.getTile(world, pos, TileCeramicBrick.class);
|
||||
if(ceramic != null){
|
||||
return ceramic.pair().getStack(0);
|
||||
}
|
||||
return super.getPickBlock(state, target, world, pos, player);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int colorMultiplier(IBlockState state, IBlockAccess world, BlockPos pos, int tintIndex) {
|
||||
TileCeramicBrick ceramic = TileUtil.getTile(world, pos, TileCeramicBrick.class);
|
||||
if(ceramic != null){
|
||||
if (tintIndex == 1) {
|
||||
return ceramic.getColorFirst().getColor(false);
|
||||
}else if(tintIndex == 2){
|
||||
return ceramic.getColorSecond().getColor(false);
|
||||
}
|
||||
}
|
||||
return 16777215;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public BlockRenderLayer getBlockLayer() {
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderPasses() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CeramicBrickPair getInventoryKey(ItemStack stack) {
|
||||
return new CeramicBrickPair(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CeramicBrickPair getWorldKey(IBlockState state) {
|
||||
IExtendedBlockState extendedState = (IExtendedBlockState) state;
|
||||
IBlockAccess world = extendedState.getValue(UnlistedBlockAccess.BLOCKACCESS);
|
||||
BlockPos pos = extendedState.getValue(UnlistedBlockPos.POS);
|
||||
TileCeramicBrick ceramic = TileUtil.getTile(world, pos, TileCeramicBrick.class);
|
||||
if(ceramic != null){
|
||||
return ceramic.pair();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getSprite(CeramicBrickPair type, int pass) {
|
||||
return type.getSprite(pass);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerSprites(ITextureManager manager) {
|
||||
for (CeramicBrickType type : CeramicBrickType.VALUES) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
type.sprites[i] = TextureManager.registerSprite(new ResourceLocation(Constants.BOTANY_MOD_ID + ":blocks/ceramic." + type.id + "." + i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package binnie.botany.ceramic.brick;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class CeramicBrickPair {
|
||||
EnumFlowerColor colorFirst;
|
||||
EnumFlowerColor colorSecond;
|
||||
CeramicBrickType type;
|
||||
int ordinal;
|
||||
|
||||
CeramicBrickPair(final EnumFlowerColor colorFirst, final EnumFlowerColor colorSecond, CeramicBrickType type) {
|
||||
this.colorFirst = colorFirst;
|
||||
this.colorSecond = colorSecond;
|
||||
this.type = type;
|
||||
this.ordinal = colorFirst.ordinal() + colorSecond.ordinal() * 256 + type.ordinal() * 256 * 256;
|
||||
}
|
||||
|
||||
public boolean isTwoColors() {
|
||||
return this.type.canDouble() && this.colorSecond != this.colorFirst;
|
||||
}
|
||||
|
||||
public CeramicBrickPair(ItemStack stack) {
|
||||
this(TileEntityMetadata.getItemDamage(stack));
|
||||
}
|
||||
|
||||
public ItemStack getStack(int i) {
|
||||
ItemStack s = new ItemStack(Botany.ceramicBrick, i, this.ordinal());
|
||||
return s;
|
||||
}
|
||||
|
||||
public CeramicBrickPair(int id) {
|
||||
this.colorFirst = EnumFlowerColor.get(id & 0xFF);
|
||||
this.colorSecond = EnumFlowerColor.get(id >> 8 & 0xFF);
|
||||
this.type = CeramicBrickType.get(id >> 16 & 0xFF);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
String name = this.colorFirst.getColourName();
|
||||
if (this.type.canDouble() && this.colorSecond != this.colorFirst) {
|
||||
name = name + " & " + this.colorSecond.getColourName();
|
||||
}
|
||||
return name + " " + this.type.name;
|
||||
}
|
||||
|
||||
public int ordinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public TextureAtlasSprite getSprite(int pass) {
|
||||
return this.type.sprites[pass];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof CeramicBrickPair)){
|
||||
return false;
|
||||
}
|
||||
return ((CeramicBrickPair)obj).ordinal() == ordinal();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,323 @@
|
||||
package binnie.botany.ceramic.brick;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.botany.items.BotanyItems;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public enum CeramicBrickType implements IStringSerializable {
|
||||
Tile("tile", "Ceramic Tile"){
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() != 4) {
|
||||
return null;
|
||||
}
|
||||
int mortars = 0;
|
||||
int blocks = 0;
|
||||
int blockColor = -1;
|
||||
for (final ItemStack stack : stacks) {
|
||||
if (this.isMortar(stack)) {
|
||||
++mortars;
|
||||
} else {
|
||||
if (stack.getItem() != Item.getItemFromBlock(Botany.ceramic)) {
|
||||
return null;
|
||||
}
|
||||
++blocks;
|
||||
final int color = TileEntityMetadata.getItemDamage(stack);
|
||||
if (blockColor == -1) {
|
||||
blockColor = color;
|
||||
} else {
|
||||
if (blockColor != color) {
|
||||
return null;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mortars != 1) {
|
||||
return null;
|
||||
}
|
||||
final EnumFlowerColor c = EnumFlowerColor.get(blockColor);
|
||||
return new CeramicBrickPair(c, c, CeramicBrickType.Tile).getStack(3);
|
||||
}
|
||||
},
|
||||
Brick("brick", "Ceramic Bricks"){
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
return getBrickRecipe(this, stacks);
|
||||
}
|
||||
},
|
||||
StripeBrick("brickstripe", "Striped Ceramic Bricks"){
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
return getBrickRecipe(this, stacks);
|
||||
}
|
||||
},
|
||||
LargeBrick("bricklarge", "Large Ceramic Bricks"){
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() == 1) {
|
||||
final ItemStack stack3 = stacks.get(0);
|
||||
final CeramicBrickPair type3 = new CeramicBrickPair(stack3);
|
||||
if (type3.type == CeramicBrickType.VerticalLargeBrick) {
|
||||
type3.type = this;
|
||||
return type3.getStack(1);
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
if (stacks.size() != 3) {
|
||||
return null;
|
||||
}
|
||||
final int[] colors = {-1, -1};
|
||||
int a = 0;
|
||||
int b = 0;
|
||||
for (final ItemStack stack4 : stacks) {
|
||||
if (stack4.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return null;
|
||||
}
|
||||
final CeramicBrickPair type4 = new CeramicBrickPair(stack4);
|
||||
if (type4.type != CeramicBrickType.Tile) {
|
||||
return null;
|
||||
}
|
||||
final int color5 = type4.colorFirst.ordinal();
|
||||
if (colors[0] == -1) {
|
||||
colors[0] = color5;
|
||||
++a;
|
||||
} else if (colors[0] == color5) {
|
||||
++a;
|
||||
} else if (colors[1] == -1) {
|
||||
colors[1] = color5;
|
||||
++b;
|
||||
} else {
|
||||
if (colors[1] != color5) {
|
||||
return null;
|
||||
}
|
||||
++b;
|
||||
}
|
||||
}
|
||||
if (colors[1] == -1) {
|
||||
colors[1] = colors[0];
|
||||
}
|
||||
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.LargeBrick).getStack(3);
|
||||
}
|
||||
}
|
||||
},
|
||||
Split("split", "Split Ceramic Tile"){
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() != 4) {
|
||||
return null;
|
||||
}
|
||||
final int[] colors = {-1, -1};
|
||||
int altCounter = 0;
|
||||
for (final ItemStack stack2 : stacks) {
|
||||
final int alt = (altCounter != 0 && altCounter != 3) ? 1 : 0;
|
||||
if (stack2.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return null;
|
||||
}
|
||||
final CeramicBrickPair type = new CeramicBrickPair(stack2);
|
||||
if (type.type != CeramicBrickType.Tile) {
|
||||
return null;
|
||||
}
|
||||
final int color2 = type.colorFirst.ordinal();
|
||||
if (colors[alt] == -1) {
|
||||
colors[alt] = color2;
|
||||
} else if (colors[alt] != color2) {
|
||||
return null;
|
||||
}
|
||||
++altCounter;
|
||||
}
|
||||
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.Split).getStack(4);
|
||||
}
|
||||
},
|
||||
Chequered("cheque", "Chequered Ceramic Tile"){
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() != 4) {
|
||||
return null;
|
||||
}
|
||||
final int[] colors = {-1, -1};
|
||||
for (final ItemStack stack2 : stacks) {
|
||||
if (stack2.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return null;
|
||||
}
|
||||
final CeramicBrickPair type2 = new CeramicBrickPair(stack2);
|
||||
if (type2.type != CeramicBrickType.Split) {
|
||||
return null;
|
||||
}
|
||||
final int color3 = type2.colorFirst.ordinal();
|
||||
final int color4 = type2.colorSecond.ordinal();
|
||||
if (colors[0] == -1) {
|
||||
colors[0] = color3;
|
||||
colors[1] = color4;
|
||||
} else {
|
||||
if (colors[0] != color3 || colors[1] != color4) {
|
||||
return null;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.Chequered).getStack(4);
|
||||
}
|
||||
},
|
||||
Mixed("mixed", "Mixed Ceramic Tile"){
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() != 4) {
|
||||
return null;
|
||||
}
|
||||
final int[] colors = {-1, -1};
|
||||
for (final ItemStack stack2 : stacks) {
|
||||
if (stack2.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return null;
|
||||
}
|
||||
final CeramicBrickPair type2 = new CeramicBrickPair(stack2);
|
||||
if (type2.isTwoColors()) {
|
||||
return null;
|
||||
}
|
||||
final int color3 = type2.colorFirst.ordinal();
|
||||
if (type2.type == CeramicBrickType.Split) {
|
||||
if (colors[1] != -1) {
|
||||
return null;
|
||||
}
|
||||
colors[1] = color3;
|
||||
} else {
|
||||
if (type2.type != CeramicBrickType.Chequered) {
|
||||
return null;
|
||||
}
|
||||
if (colors[0] == -1) {
|
||||
colors[0] = color3;
|
||||
} else if (colors[0] != color3) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
final int color4 = type2.colorSecond.ordinal();
|
||||
}
|
||||
if (colors[0] == -1 || colors[1] == -1) {
|
||||
return null;
|
||||
}
|
||||
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.Mixed).getStack(4);
|
||||
}
|
||||
},
|
||||
VerticalBrick("verticalbrick", "Vertical Ceramic Bricks"){
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
return getVerticalBrickRecipe(stacks);
|
||||
}
|
||||
},
|
||||
VerticalStripeBrick("verticalbrickstripe", "Vertical Striped Ceramic Bricks"){
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
return getVerticalBrickRecipe(stacks);
|
||||
}
|
||||
},
|
||||
VerticalLargeBrick("verticalbricklarge", "Large Vertical Ceramic Bricks"){
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
return getVerticalBrickRecipe(stacks);
|
||||
}
|
||||
};
|
||||
|
||||
public static final CeramicBrickType[] VALUES = values();
|
||||
|
||||
String id;
|
||||
String name;
|
||||
TextureAtlasSprite[] sprites;
|
||||
|
||||
CeramicBrickType(final String id, final String name) {
|
||||
this.sprites = new TextureAtlasSprite[3];
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static CeramicBrickType get(final int id) {
|
||||
return VALUES[id % VALUES.length];
|
||||
}
|
||||
|
||||
public boolean canDouble() {
|
||||
return this != CeramicBrickType.Tile;
|
||||
}
|
||||
|
||||
public abstract ItemStack getRecipe(List<ItemStack> stacks);
|
||||
|
||||
protected ItemStack getVerticalBrickRecipe(List<ItemStack> stacks){
|
||||
if (stacks.size() != 1) {
|
||||
return null;
|
||||
}
|
||||
final ItemStack stack5 = stacks.get(0);
|
||||
final CeramicBrickPair type = new CeramicBrickPair(stack5);
|
||||
if (type.type == CeramicBrickType.LargeBrick) {
|
||||
type.type = CeramicBrickType.VerticalLargeBrick;
|
||||
return type.getStack(1);
|
||||
}
|
||||
if (type.type == CeramicBrickType.Brick) {
|
||||
type.type = CeramicBrickType.VerticalBrick;
|
||||
return type.getStack(1);
|
||||
}
|
||||
if (type.type == CeramicBrickType.StripeBrick) {
|
||||
type.type = CeramicBrickType.VerticalStripeBrick;
|
||||
return type.getStack(1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected ItemStack getBrickRecipe(CeramicBrickType ceramicType, List<ItemStack> stacks){
|
||||
if (stacks.size() == 1) {
|
||||
final ItemStack stack5 = stacks.get(0);
|
||||
final CeramicBrickPair type = new CeramicBrickPair(stack5);
|
||||
if (type.type == CeramicBrickType.VerticalBrick) {
|
||||
type.type = ceramicType;
|
||||
return type.getStack(1);
|
||||
}
|
||||
if (type.type == CeramicBrickType.StripeBrick) {
|
||||
type.type = ceramicType;
|
||||
return type.getStack(1);
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
if (stacks.size() != 4) {
|
||||
return null;
|
||||
}
|
||||
final int[] colors = {-1, -1};
|
||||
for (int index2 = 0; index2 < stacks.size(); ++index2) {
|
||||
final ItemStack stack4 = stacks.get(index2);
|
||||
if (stack4.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return null;
|
||||
}
|
||||
final CeramicBrickPair type4 = new CeramicBrickPair(stack4);
|
||||
if (type4.type != CeramicBrickType.LargeBrick) {
|
||||
return null;
|
||||
}
|
||||
final int color5 = type4.colorFirst.ordinal();
|
||||
final int color6 = type4.colorSecond.ordinal();
|
||||
int alt2 = (index2 != 0 && index2 != 3) ? 1 : 0;
|
||||
if (ceramicType == CeramicBrickType.StripeBrick) {
|
||||
alt2 = 0;
|
||||
}
|
||||
if (colors[alt2] == -1) {
|
||||
colors[alt2] = color5;
|
||||
colors[1 - alt2] = color6;
|
||||
} else if (colors[alt2] != color5 || colors[1 - alt2] != color6) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), ceramicType).getStack(4);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isMortar(final ItemStack stack) {
|
||||
return stack.getItem() == Botany.misc && stack.getItemDamage() == BotanyItems.Mortar.ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package binnie.botany.ceramic.brick;
|
||||
|
||||
import forestry.core.items.IColoredItem;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemCeramicBrick extends ItemBlock implements IColoredItem {
|
||||
public ItemCeramicBrick(BlockCeramicBrick block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(final int metadata) {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
|
||||
CeramicBrickPair ceramic = new CeramicBrickPair(stack.getItemDamage());
|
||||
if(ceramic != null){
|
||||
if (tintIndex == 1) {
|
||||
return ceramic.colorFirst.getColor(false);
|
||||
}else if (tintIndex == 2) {
|
||||
return ceramic.colorSecond.getColor(false);
|
||||
}
|
||||
}
|
||||
return 16777215;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getItemStackDisplayName(ItemStack itemStack) {
|
||||
return new CeramicBrickPair(itemStack.getItemDamage()).getName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package binnie.botany.ceramic.brick;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TileCeramicBrick extends TileEntity{
|
||||
|
||||
private EnumFlowerColor colorFirst;
|
||||
private EnumFlowerColor colorSecond;
|
||||
|
||||
public void setColors(EnumFlowerColor colorFirst, EnumFlowerColor colorSecond) {
|
||||
this.colorFirst = colorFirst;
|
||||
this.colorSecond = colorSecond;
|
||||
}
|
||||
|
||||
public boolean hasTwoColors() {
|
||||
return CeramicBrickType.VALUES[getBlockMetadata()].canDouble() && this.colorSecond != this.colorFirst;
|
||||
}
|
||||
|
||||
public ItemStack getStack(final int i) {
|
||||
final ItemStack s = TileEntityMetadata.getItemStack(Botany.ceramicBrick, this.ordinal());
|
||||
s.stackSize = i;
|
||||
return s;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
CeramicBrickType type = CeramicBrickType.VALUES[getBlockMetadata()];
|
||||
String name = this.colorFirst.getColourName();
|
||||
if (type.canDouble() && this.colorSecond != this.colorFirst) {
|
||||
name = name + " & " + this.colorSecond.getColourName();
|
||||
}
|
||||
return name + " " + type.name;
|
||||
}
|
||||
|
||||
public int ordinal() {
|
||||
return this.colorFirst.ordinal() + this.colorSecond.ordinal() * 256 + getBlockMetadata() * 256 * 256;
|
||||
}
|
||||
|
||||
public CeramicBrickPair pair(){
|
||||
return new CeramicBrickPair(colorFirst, colorSecond, CeramicBrickType.VALUES[getBlockMetadata()]);
|
||||
}
|
||||
|
||||
public EnumFlowerColor getColorFirst() {
|
||||
if(colorFirst == null){
|
||||
colorFirst = EnumFlowerColor.Aquamarine;
|
||||
}
|
||||
return colorFirst;
|
||||
}
|
||||
|
||||
public EnumFlowerColor getColorSecond() {
|
||||
if(colorSecond == null){
|
||||
colorSecond = EnumFlowerColor.Aquamarine;
|
||||
}
|
||||
return colorSecond;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
compound.setInteger("First", colorFirst.ordinal());
|
||||
compound.setInteger("Second", colorSecond.ordinal());
|
||||
return super.writeToNBT(compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getUpdateTag() {
|
||||
return writeToNBT(new NBTTagCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
super.readFromNBT(compound);
|
||||
if(compound.hasKey("First")){
|
||||
colorFirst = EnumFlowerColor.VALUES[compound.getInteger("First")];
|
||||
}
|
||||
if(compound.hasKey("Second")){
|
||||
colorSecond = EnumFlowerColor.VALUES[compound.getInteger("Second")];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,7 +24,6 @@ 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.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
||||
@@ -7,17 +7,22 @@ import binnie.botany.api.EnumAcidity;
|
||||
import binnie.botany.api.EnumMoisture;
|
||||
import binnie.botany.api.EnumSoilType;
|
||||
import binnie.botany.ceramic.BlockCeramic;
|
||||
import binnie.botany.ceramic.BlockCeramicBrick;
|
||||
import binnie.botany.ceramic.BlockCeramicPatterned;
|
||||
import binnie.botany.ceramic.BlockStained;
|
||||
import binnie.botany.ceramic.CeramicTileRecipe;
|
||||
import binnie.botany.ceramic.ItemCeramic;
|
||||
import binnie.botany.ceramic.PigmentRecipe;
|
||||
import binnie.botany.ceramic.TileCeramic;
|
||||
import binnie.botany.ceramic.brick.BlockCeramicBrick;
|
||||
import binnie.botany.ceramic.brick.ItemCeramicBrick;
|
||||
import binnie.botany.ceramic.brick.TileCeramicBrick;
|
||||
import binnie.botany.farm.CircuitGarden;
|
||||
import binnie.botany.flower.ItemInsulatedTube;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.botany.items.BotanyItems;
|
||||
import binnie.botany.items.ItemClay;
|
||||
import binnie.botany.items.ItemPigment;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.IInitializable;
|
||||
import binnie.core.Mods;
|
||||
import binnie.core.block.ItemMetadata;
|
||||
@@ -84,7 +89,8 @@ public class ModuleGardening implements IInitializable {
|
||||
Botany.proxy.registerItem(Botany.clay);
|
||||
Botany.ceramic = new BlockCeramic();
|
||||
Botany.proxy.registerBlock(Botany.ceramic);
|
||||
Botany.proxy.registerItem(new ItemMetadata(Botany.ceramic).setRegistryName(Botany.ceramic.getRegistryName()));
|
||||
Botany.proxy.registerItem(new ItemCeramic(Botany.ceramic).setRegistryName(Botany.ceramic.getRegistryName()));
|
||||
BinnieCore.proxy.registerTileEntity(TileCeramic.class, "botany.tile.ceramic");
|
||||
// BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramic), new ItemMetadataRenderer());
|
||||
Botany.stained = new BlockStained();
|
||||
Botany.proxy.registerBlock(Botany.stained);
|
||||
@@ -95,7 +101,9 @@ public class ModuleGardening implements IInitializable {
|
||||
Botany.proxy.registerItem(new ItemMetadata(Botany.ceramicTile).setRegistryName(Botany.ceramicTile.getRegistryName()));
|
||||
Botany.ceramicBrick = new BlockCeramicBrick();
|
||||
Botany.proxy.registerBlock(Botany.ceramicBrick);
|
||||
Botany.proxy.registerItem(new ItemMetadata(Botany.ceramicBrick).setRegistryName(Botany.ceramicBrick.getRegistryName()));
|
||||
Botany.proxy.registerItem(new ItemCeramicBrick(Botany.ceramicBrick).setRegistryName(Botany.ceramicBrick.getRegistryName()));
|
||||
GameRegistry.registerTileEntity(TileCeramicBrick.class, "");
|
||||
BinnieCore.proxy.registerTileEntity(TileCeramicBrick.class, "botany.tile.ceramicBrick");
|
||||
// BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramicTile), new MultipassItemRenderer());
|
||||
// BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramicBrick), new MultipassItemRenderer());
|
||||
}
|
||||
|
||||
@@ -89,6 +89,8 @@ public enum EnumFlowerColor implements IFlowerColour, IAlleleInteger, IStringSer
|
||||
Yellow("yellow", 16776960),
|
||||
YellowGreen("yellowGreen", 10145074);
|
||||
|
||||
public static final EnumFlowerColor[] VALUES = values();
|
||||
|
||||
int color;
|
||||
int colorDis;
|
||||
String uid;
|
||||
|
||||
@@ -17,6 +17,7 @@ import binnie.core.mod.config.ConfigurationMain;
|
||||
import binnie.core.mod.config.ConfigurationMods;
|
||||
import binnie.core.mod.parser.FieldParser;
|
||||
import binnie.core.mod.parser.ItemParser;
|
||||
import binnie.core.models.ModelManager;
|
||||
import binnie.core.network.BinnieCorePacketID;
|
||||
import binnie.core.network.BinniePacketHandler;
|
||||
import binnie.core.network.IPacketID;
|
||||
@@ -29,6 +30,7 @@ import forestry.plugins.PluginManager;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
@@ -172,6 +174,12 @@ public final class BinnieCore extends AbstractMod {
|
||||
// }
|
||||
Binnie.Resource.registerIcons();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void handleModelBake(ModelBakeEvent event) {
|
||||
ModelManager.registerCustomModels(event);
|
||||
}
|
||||
|
||||
public static class PacketHandler extends BinniePacketHandler {
|
||||
public PacketHandler() {
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package binnie.core.block;
|
||||
|
||||
import forestry.api.core.IModelBaker;
|
||||
import forestry.core.models.ModelBlockCached;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ModelMutlipass<B extends Block & IMultipassBlock<K>, K> extends ModelBlockCached<B, K> {
|
||||
|
||||
public ModelMutlipass(Class<B> blockClass) {
|
||||
super(blockClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected K getInventoryKey(ItemStack stack) {
|
||||
return ((B) Block.getBlockFromItem(stack.getItem())).getInventoryKey(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected K getWorldKey(IBlockState state) {
|
||||
return ((B) state.getBlock()).getWorldKey(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bakeBlock(B block, K key, IModelBaker baker, boolean inventory) {
|
||||
for (int pass = 0; pass < block.getRenderPasses(); pass++) {
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, block.getSprite(key, pass), 0);
|
||||
}
|
||||
|
||||
// Set the particle sprite
|
||||
baker.setParticleSprite(block.getSprite(key, -1));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -50,8 +50,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package binnie.core.models;
|
||||
|
||||
import binnie.Constants;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
|
||||
public class DefaultStateMapper extends StateMapperBase {
|
||||
|
||||
@Override
|
||||
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
|
||||
return new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":ceramicBrick", "normal");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
package binnie.core.models;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.ISpriteRegister;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.core.blocks.IColoredBlock;
|
||||
import forestry.core.items.IColoredItem;
|
||||
@@ -42,13 +45,14 @@ public class ModelManager implements IModelManager {
|
||||
|
||||
private final String modID;
|
||||
|
||||
private final List<BlockModelEntry> customBlockModels = new ArrayList<>();
|
||||
private final List<ModelEntry> customModels = new ArrayList<>();
|
||||
private final static List<BlockModelEntry> customBlockModels = new ArrayList<>();
|
||||
private final static List<ModelEntry> customModels = new ArrayList<>();
|
||||
|
||||
private final List<IItemModelRegister> itemModelRegisters = new ArrayList<>();
|
||||
private final List<IStateMapperRegister> stateMapperRegisters = new ArrayList<>();
|
||||
private final List<IColoredBlock> blockColorList = new ArrayList<>();
|
||||
private final List<IColoredItem> itemColorList = new ArrayList<>();
|
||||
private final static List<ISpriteRegister> spriteRegister = new ArrayList<>();
|
||||
|
||||
private TRSRTransformation flipX = new TRSRTransformation(null, null, new Vector3f(-1, 1, 1), null);
|
||||
public final IModelState DEFAULT_BLOCK;
|
||||
@@ -149,6 +153,9 @@ public class ModelManager implements IModelManager {
|
||||
if (block instanceof IColoredBlock) {
|
||||
blockColorList.add((IColoredBlock) block);
|
||||
}
|
||||
if (block instanceof ISpriteRegister) {
|
||||
spriteRegister.add((ISpriteRegister) block);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -159,6 +166,9 @@ public class ModelManager implements IModelManager {
|
||||
if (item instanceof IColoredItem) {
|
||||
itemColorList.add((IColoredItem) item);
|
||||
}
|
||||
if (item instanceof ISpriteRegister) {
|
||||
spriteRegister.add((ISpriteRegister) item);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -180,6 +190,15 @@ public class ModelManager implements IModelManager {
|
||||
stateMapperRegister.registerStateMapper();
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void reloadSprites() {
|
||||
for (ISpriteRegister spriteRegister : spriteRegister) {
|
||||
if(spriteRegister != null){
|
||||
spriteRegister.registerSprites(ForestryAPI.textureManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerItemAndBlockColors() {
|
||||
@@ -236,7 +255,7 @@ public class ModelManager implements IModelManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void registerCustomModels(ModelBakeEvent event) {
|
||||
public static void registerCustomModels(ModelBakeEvent event) {
|
||||
IRegistry<ModelResourceLocation, IBakedModel> registry = event.getModelRegistry();
|
||||
for (final BlockModelEntry entry : customBlockModels) {
|
||||
registry.putObject(entry.blockModelLocation, entry.model);
|
||||
@@ -250,11 +269,11 @@ public class ModelManager implements IModelManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void registerCustomBlockModel(@Nonnull BlockModelEntry index) {
|
||||
public static void registerCustomBlockModel(@Nonnull BlockModelEntry index) {
|
||||
customBlockModels.add(index);
|
||||
}
|
||||
|
||||
public void registerCustomModel(@Nonnull ModelEntry index) {
|
||||
public static void registerCustomModel(@Nonnull ModelEntry index) {
|
||||
customModels.add(index);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package binnie.core.models;
|
||||
|
||||
import binnie.core.block.IMultipassBlock;
|
||||
import forestry.api.core.IModelBaker;
|
||||
import forestry.core.models.ModelBlockCached;
|
||||
import forestry.core.models.baker.ModelBaker;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelMutlipass<B extends Block & IMultipassBlock<K>, K> extends ModelBlockCached<B, K> {
|
||||
|
||||
public ModelMutlipass(Class<B> blockClass) {
|
||||
super(blockClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected K getInventoryKey(ItemStack stack) {
|
||||
return ((B) Block.getBlockFromItem(stack.getItem())).getInventoryKey(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected K getWorldKey(IBlockState state) {
|
||||
return ((B) state.getBlock()).getWorldKey(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bakeBlock(B block, K key, IModelBaker baker, boolean inventory) {
|
||||
for (int pass = 0; pass < block.getRenderPasses(); pass++) {
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, block.getSprite(key, pass), pass);
|
||||
}
|
||||
|
||||
// Set the particle sprite
|
||||
//TODO: Adding a preaking sprite
|
||||
baker.setParticleSprite(block.getSprite(key, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IBakedModel bakeModel(ItemStack stack, World world, K key) {
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IModelBaker baker = new ModelBaker();
|
||||
Block block = Block.getBlockFromItem(stack.getItem());
|
||||
if (!blockClass.isInstance(block)) {
|
||||
return null;
|
||||
}
|
||||
B bBlock = blockClass.cast(block);
|
||||
|
||||
baker.setRenderBounds(Block.FULL_BLOCK_AABB);
|
||||
bakeBlock(bBlock, key, baker, true);
|
||||
|
||||
return itemModel = baker.bakeModel(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -106,6 +106,11 @@ public class BinnieProxy extends BinnieModProxy implements IBinnieProxy {
|
||||
|
||||
@Override
|
||||
public void registerTileEntity(final Class<? extends TileEntity> tile, final String id, @Nullable final Object renderer) {
|
||||
registerTileEntity(tile, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTileEntity(final Class<? extends TileEntity> tile, final String id) {
|
||||
GameRegistry.registerTileEntity(tile, id);
|
||||
}
|
||||
|
||||
@@ -156,6 +161,9 @@ public class BinnieProxy extends BinnieModProxy implements IBinnieProxy {
|
||||
@Override
|
||||
public void bindTexture(final ResourceLocation location) {
|
||||
}
|
||||
|
||||
public void reloadSprites(){
|
||||
}
|
||||
|
||||
public boolean isShiftDown() {
|
||||
return false;
|
||||
|
||||
@@ -51,6 +51,11 @@ public final class BinnieProxyClient extends BinnieProxy implements IBinnieProxy
|
||||
public void registerModels() {
|
||||
getModelManager().registerModels();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadSprites() {
|
||||
ModelManager.reloadSprites();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerItemAndBlockColors() {
|
||||
|
||||
@@ -42,6 +42,8 @@ public interface IBinnieProxy extends IProxyCore {
|
||||
Object createObject(final String p0);
|
||||
|
||||
void registerTileEntity(final Class<? extends TileEntity> tile, final String id, @Nullable final Object renderer);
|
||||
|
||||
void registerTileEntity(final Class<? extends TileEntity> tile, final String id);
|
||||
|
||||
void createPipe(final Item p0);
|
||||
|
||||
|
||||
@@ -17,4 +17,5 @@ public interface IProxyCore extends IInitializable {
|
||||
|
||||
public void registerItemAndBlockColors();
|
||||
|
||||
|
||||
}
|
||||
@@ -37,6 +37,7 @@ public class ManagerResource {
|
||||
for (final BinnieIcon icon : this.icons) {
|
||||
BinnieCore.proxy.registerIcon(icon.getResourceLocation());
|
||||
}
|
||||
BinnieCore.proxy.reloadSprites();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ public class ContainerCraftGUI extends Container {
|
||||
@Override
|
||||
public boolean canInteractWith(final EntityPlayer var1) {
|
||||
if (var1 instanceof EntityPlayerMP) {
|
||||
crafters.add((EntityPlayerMP) var1);
|
||||
crafters.add(var1);
|
||||
this.sentNBT.clear();
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"variants": {
|
||||
"normal": { "model": "botany:ceramic" }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,6 +43,8 @@ botany.flower.destroy=This item is bugged. Destroy it!
|
||||
botany.grammar.flower=%PRIMARY, %STEM Stem
|
||||
botany.grammar.flower.secondary=%PRIMARY and %SECONDARY, %STEM Stem
|
||||
|
||||
tile.botany.ceramic.name=Ceramic Block
|
||||
|
||||
botany.colour.aquamarine=Aquamarine
|
||||
botany.colour.black=Black
|
||||
botany.colour.blue=Deep Blue
|
||||
|
||||
Reference in new issue
Block a user