Add recipes to fance gates and add fance gates to the wooditemaccess

This commit is contained in:
Nedelosk committed 2016-03-20 12:58:19 +01:00
1 parent 2442a2534a
commit b3a2d6cf84
4 files changed
+47 -151

No files matched your search

@@ -15,6 +15,8 @@ public interface IWoodItemAccess {
ItemStack getSlab(EnumWoodType woodType, boolean fireproof);
ItemStack getFence(EnumWoodType woodType, boolean fireproof);
ItemStack getFenceGate(EnumWoodType woodType, boolean fireproof);
ItemStack getStairs(EnumWoodType woodType, boolean fireproof);
}
@@ -125,12 +125,14 @@ public class PluginArboriculture extends BlankForestryPlugin {
WoodItemAccess.registerPlanks(blocks.planks);
WoodItemAccess.registerSlabs(blocks.slabs);
WoodItemAccess.registerFences(blocks.fences);
WoodItemAccess.registerFenceGates(blocks.fenceGates);
WoodItemAccess.registerStairs(blocks.stairs);
WoodItemAccess.registerLogs(blocks.logsFireproof);
WoodItemAccess.registerPlanks(blocks.planksFireproof);
WoodItemAccess.registerSlabs(blocks.slabsFireproof);
WoodItemAccess.registerFences(blocks.fencesFireproof);
WoodItemAccess.registerFenceGates(blocks.fenceGatesFireproof);
WoodItemAccess.registerStairs(blocks.stairsFireproof);
blocks.arboriculture.addDefinitions(BlockTypeArboricultureTesr.ARB_CHEST);
@@ -197,12 +199,14 @@ public class PluginArboriculture extends BlankForestryPlugin {
ItemStack logs = TreeManager.woodItemAccess.getLog(woodType, false);
ItemStack slabs = TreeManager.woodItemAccess.getSlab(woodType, false);
ItemStack fences = TreeManager.woodItemAccess.getFence(woodType, false);
ItemStack fenceGates = TreeManager.woodItemAccess.getFenceGate(woodType, false);
ItemStack stairs = TreeManager.woodItemAccess.getStairs(woodType, false);
ItemStack fireproofPlanks = TreeManager.woodItemAccess.getPlanks(woodType, true);
ItemStack fireproofLogs = TreeManager.woodItemAccess.getLog(woodType, true);
ItemStack fireproofSlabs = TreeManager.woodItemAccess.getSlab(woodType, true);
ItemStack fireproofFences = TreeManager.woodItemAccess.getFence(woodType, true);
ItemStack fireproofFenceGates = TreeManager.woodItemAccess.getFenceGate(woodType, true);
ItemStack fireproofStairs = TreeManager.woodItemAccess.getStairs(woodType, true);
planks.stackSize = 4;
@@ -238,6 +242,20 @@ public class PluginArboriculture extends BlankForestryPlugin {
"#X#",
"#X#",
'#', fireproofPlanks.copy(), 'X', "stickWood");
fenceGates.stackSize = 1;
planks.stackSize = 1;
RecipeUtil.addRecipe(fenceGates.copy(),
"X#X",
"X#X",
'#', planks.copy(), 'X', "stickWood");
fireproofFenceGates.stackSize = 1;
fireproofPlanks.stackSize = 1;
RecipeUtil.addRecipe(fireproofFenceGates.copy(),
"X#X",
"X#X",
'#', fireproofPlanks.copy(), 'X', "stickWood");
stairs.stackSize = 4;
planks.stackSize = 1;
@@ -21,6 +21,7 @@ import net.minecraft.item.ItemStack;
import forestry.api.arboriculture.EnumWoodType;
import forestry.api.arboriculture.IWoodItemAccess;
import forestry.arboriculture.blocks.BlockArbFence;
import forestry.arboriculture.blocks.BlockArbFenceGate;
import forestry.arboriculture.blocks.BlockArbLog;
import forestry.arboriculture.blocks.BlockArbPlanks;
import forestry.arboriculture.blocks.BlockArbSlab;
@@ -31,6 +32,7 @@ public class WoodItemAccess implements IWoodItemAccess {
private static final WoodMap planks = new WoodMap();
private static final WoodMap slabs = new WoodMap();
private static final WoodMap fences = new WoodMap();
private static final WoodMap fenceGates = new WoodMap();
private static final WoodMap stairs = new WoodMap();
private static class WoodMap {
@@ -66,6 +68,12 @@ public class WoodItemAccess implements IWoodItemAccess {
register(block, fences);
}
}
public static void registerFenceGates(List<BlockArbFenceGate> blocks) {
for (BlockArbFenceGate block : blocks) {
register(block, fenceGates);
}
}
public static void registerStairs(List<BlockArbStairs> blocks) {
for (BlockArbStairs block : blocks) {
@@ -103,6 +111,11 @@ public class WoodItemAccess implements IWoodItemAccess {
public ItemStack getFence(EnumWoodType woodType, boolean fireproof) {
return fences.get(fireproof).get(woodType).copy();
}
@Override
public ItemStack getFenceGate(EnumWoodType woodType, boolean fireproof) {
return fenceGates.get(fireproof).get(woodType).copy();
}
@Override
public ItemStack getStairs(EnumWoodType woodType, boolean fireproof) {
@@ -2,10 +2,12 @@ package forestry.arboriculture.blocks;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
import forestry.api.arboriculture.EnumWoodType;
import forestry.api.arboriculture.TreeManager;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.api.core.IStateMapperRegister;
@@ -14,26 +16,19 @@ import forestry.arboriculture.IWoodTyped;
import forestry.arboriculture.WoodHelper;
import forestry.arboriculture.WoodHelper.WoodMeshDefinition;
import forestry.core.proxy.Proxies;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDirectional;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.BlockFenceGate;
import net.minecraft.block.BlockPlanks.EnumType;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockArbFenceGate extends BlockDirectional implements IWoodTyped, IItemModelRegister, IStateMapperRegister {
public class BlockArbFenceGate extends BlockFenceGate implements IWoodTyped, IItemModelRegister, IStateMapperRegister {
public static final PropertyBool OPEN = PropertyBool.create("open");
public static final PropertyBool POWERED = PropertyBool.create("powered");
public static final PropertyBool IN_WALL = PropertyBool.create("in_wall");
@@ -42,15 +37,14 @@ public class BlockArbFenceGate extends BlockDirectional implements IWoodTyped, I
private final EnumWoodType woodType;
public BlockArbFenceGate(boolean fireproof, EnumWoodType woodType){
super(Material.wood);
super(EnumType.OAK);
this.fireproof = fireproof;
this.woodType = woodType;
setHardness(2.0F);
setResistance(5.0F);
setStepSound(soundTypeWood);
this.setDefaultState(this.blockState.getBaseState().withProperty(OPEN, Boolean.valueOf(false)).withProperty(POWERED, Boolean.valueOf(false)).withProperty(IN_WALL, Boolean.valueOf(false)));
this.setCreativeTab(Tabs.tabArboriculture);
setCreativeTab(Tabs.tabArboriculture);
}
@Override
@@ -58,142 +52,6 @@ public class BlockArbFenceGate extends BlockDirectional implements IWoodTyped, I
return fireproof;
}
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos){
EnumFacing.Axis enumfacing$axis = state.getValue(FACING).getAxis();
if (enumfacing$axis == EnumFacing.Axis.Z && (worldIn.getBlockState(pos.west()).getBlock() == Blocks.cobblestone_wall || worldIn.getBlockState(pos.east()).getBlock() == Blocks.cobblestone_wall) || enumfacing$axis == EnumFacing.Axis.X && (worldIn.getBlockState(pos.north()).getBlock() == Blocks.cobblestone_wall || worldIn.getBlockState(pos.south()).getBlock() == Blocks.cobblestone_wall)){
state = state.withProperty(IN_WALL, Boolean.valueOf(true));
}
return state;
}
@Override
public boolean canPlaceBlockAt(World worldIn, BlockPos pos){
return worldIn.getBlockState(pos.down()).getBlock().getMaterial().isSolid() ? super.canPlaceBlockAt(worldIn, pos) : false;
}
@Override
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state){
if (state.getValue(OPEN).booleanValue()){
return null;
}else{
EnumFacing.Axis enumfacing$axis = state.getValue(FACING).getAxis();
return enumfacing$axis == EnumFacing.Axis.Z ? new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ() + 0.375F, pos.getX() + 1, pos.getY() + 1.5F, pos.getZ() + 0.625F) : new AxisAlignedBB(pos.getX() + 0.375F, pos.getY(), pos.getZ(), pos.getX() + 0.625F, pos.getY() + 1.5F, pos.getZ() + 1);
}
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos){
EnumFacing.Axis enumfacing$axis = worldIn.getBlockState(pos).getValue(FACING).getAxis();
if (enumfacing$axis == EnumFacing.Axis.Z){
this.setBlockBounds(0.0F, 0.0F, 0.375F, 1.0F, 1.0F, 0.625F);
}else{
this.setBlockBounds(0.375F, 0.0F, 0.0F, 0.625F, 1.0F, 1.0F);
}
}
@Override
public boolean isOpaqueCube(){
return false;
}
@Override
public boolean isFullCube(){
return false;
}
@Override
public boolean isPassable(IBlockAccess worldIn, BlockPos pos){
return worldIn.getBlockState(pos).getValue(OPEN).booleanValue();
}
@Override
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer){
return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing()).withProperty(OPEN, Boolean.valueOf(false)).withProperty(POWERED, Boolean.valueOf(false)).withProperty(IN_WALL, Boolean.valueOf(false));
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ){
if (state.getValue(OPEN).booleanValue()){
state = state.withProperty(OPEN, Boolean.valueOf(false));
worldIn.setBlockState(pos, state, 2);
}else{
EnumFacing enumfacing = EnumFacing.fromAngle(playerIn.rotationYaw);
if (state.getValue(FACING) == enumfacing.getOpposite()){
state = state.withProperty(FACING, enumfacing);
}
state = state.withProperty(OPEN, Boolean.valueOf(true));
worldIn.setBlockState(pos, state, 2);
}
worldIn.playAuxSFXAtEntity(playerIn, state.getValue(OPEN).booleanValue() ? 1003 : 1006, pos, 0);
return true;
}
@Override
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock){
if (!worldIn.isRemote){
boolean flag = worldIn.isBlockPowered(pos);
if (flag || neighborBlock.canProvidePower()){
if (flag && !state.getValue(OPEN).booleanValue() && !state.getValue(POWERED).booleanValue()){
worldIn.setBlockState(pos, state.withProperty(OPEN, Boolean.valueOf(true)).withProperty(POWERED, Boolean.valueOf(true)), 2);
worldIn.playAuxSFXAtEntity((EntityPlayer)null, 1003, pos, 0);
}else if (!flag && state.getValue(OPEN).booleanValue() && state.getValue(POWERED).booleanValue()){
worldIn.setBlockState(pos, state.withProperty(OPEN, Boolean.valueOf(false)).withProperty(POWERED, Boolean.valueOf(false)), 2);
worldIn.playAuxSFXAtEntity((EntityPlayer)null, 1006, pos, 0);
}else if (flag != state.getValue(POWERED).booleanValue()){
worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(flag)), 2);
}
}
}
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side){
return true;
}
@Override
public IBlockState getStateFromMeta(int meta){
return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta)).withProperty(OPEN, Boolean.valueOf((meta & 4) != 0)).withProperty(POWERED, Boolean.valueOf((meta & 8) != 0));
}
@Override
public int getMetaFromState(IBlockState state){
int i = 0;
i = i | state.getValue(FACING).getHorizontalIndex();
if (state.getValue(POWERED).booleanValue()){
i |= 8;
}
if (state.getValue(OPEN).booleanValue()){
i |= 4;
}
return i;
}
@Override
protected BlockState createBlockState(){
return new BlockState(this, new IProperty[] {FACING, OPEN, POWERED, IN_WALL});
}
@Override
public float getBlockHardness(World world, BlockPos pos) {
IBlockState blockState = world.getBlockState(pos);
int meta = getMetaFromState(blockState);
EnumWoodType woodType = getWoodType(meta);
return woodType.getHardness();
}
@Override
public int getFlammability(IBlockAccess world, BlockPos pos, EnumFacing face) {
if (fireproof) {
@@ -234,6 +92,11 @@ public class BlockArbFenceGate extends BlockDirectional implements IWoodTyped, I
Proxies.render.registerStateMapper(this, new WoodTypeStateMapper(this, null).addPropertyToRemove(POWERED));
}
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
list.add(TreeManager.woodItemAccess.getFenceGate(woodType, fireproof));
}
@SideOnly(Side.CLIENT)
@Override
public void registerModel(Item item, IModelManager manager) {