2015-11-08 18:29:05 +01:00
|
|
|
/*
|
2016-05-16 22:52:27 +02:00
|
|
|
* This file ("BlockWallAA.java") is part of the Actually Additions mod for Minecraft.
|
2015-11-08 18:29:05 +01:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-05-16 22:52:27 +02:00
|
|
|
* http://ellpeck.de/actaddlicense
|
2015-11-08 18:29:05 +01:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2017-01-01 16:23:26 +01:00
|
|
|
* © 2015-2017 Ellpeck
|
2015-11-08 18:29:05 +01:00
|
|
|
*/
|
|
|
|
|
2016-03-18 18:38:39 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
2015-11-08 18:29:05 +01:00
|
|
|
|
2016-03-18 18:38:39 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
|
2015-11-08 18:29:05 +01:00
|
|
|
import net.minecraft.block.Block;
|
2016-01-09 14:35:04 +01:00
|
|
|
import net.minecraft.block.BlockFenceGate;
|
2015-11-08 18:29:05 +01:00
|
|
|
import net.minecraft.block.BlockWall;
|
2016-01-09 14:35:04 +01:00
|
|
|
import net.minecraft.block.material.Material;
|
2016-03-18 23:47:22 +01:00
|
|
|
import net.minecraft.block.state.BlockStateContainer;
|
2016-01-07 23:42:42 +01:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
2015-11-08 18:29:05 +01:00
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
2016-01-09 14:35:04 +01:00
|
|
|
import net.minecraft.init.Blocks;
|
2015-11-08 18:29:05 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2016-01-09 14:35:04 +01:00
|
|
|
import net.minecraft.util.EnumFacing;
|
2016-11-19 21:11:17 +01:00
|
|
|
import net.minecraft.util.NonNullList;
|
2016-03-18 23:47:22 +01:00
|
|
|
import net.minecraft.util.math.AxisAlignedBB;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
2016-01-09 14:35:04 +01:00
|
|
|
import net.minecraft.world.IBlockAccess;
|
2016-01-07 18:20:59 +01:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2015-11-08 18:29:05 +01:00
|
|
|
|
2016-01-09 14:35:04 +01:00
|
|
|
public class BlockWallAA extends BlockBase{
|
2015-11-08 18:29:05 +01:00
|
|
|
|
2016-05-07 02:49:03 +02:00
|
|
|
protected static final AxisAlignedBB[] AABB_BY_INDEX = new AxisAlignedBB[]{new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 0.75D, 1.0D, 1.0D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.3125D, 0.0D, 0.0D, 0.6875D, 0.875D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.75D, 1.0D, 1.0D), new AxisAlignedBB(0.25D, 0.0D, 0.25D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.25D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.3125D, 1.0D, 0.875D, 0.6875D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D)};
|
|
|
|
protected static final AxisAlignedBB[] CLIP_AABB_BY_INDEX = new AxisAlignedBB[]{AABB_BY_INDEX[0].setMaxY(1.5D), AABB_BY_INDEX[1].setMaxY(1.5D), AABB_BY_INDEX[2].setMaxY(1.5D), AABB_BY_INDEX[3].setMaxY(1.5D), AABB_BY_INDEX[4].setMaxY(1.5D), AABB_BY_INDEX[5].setMaxY(1.5D), AABB_BY_INDEX[6].setMaxY(1.5D), AABB_BY_INDEX[7].setMaxY(1.5D), AABB_BY_INDEX[8].setMaxY(1.5D), AABB_BY_INDEX[9].setMaxY(1.5D), AABB_BY_INDEX[10].setMaxY(1.5D), AABB_BY_INDEX[11].setMaxY(1.5D), AABB_BY_INDEX[12].setMaxY(1.5D), AABB_BY_INDEX[13].setMaxY(1.5D), AABB_BY_INDEX[14].setMaxY(1.5D), AABB_BY_INDEX[15].setMaxY(1.5D)};
|
2016-05-03 21:26:02 +02:00
|
|
|
|
2016-05-19 20:05:12 +02:00
|
|
|
private final int meta;
|
2016-05-07 02:49:03 +02:00
|
|
|
|
2015-12-19 10:30:39 +01:00
|
|
|
public BlockWallAA(String name, Block base){
|
|
|
|
this(name, base, 0);
|
|
|
|
}
|
|
|
|
|
2016-03-18 23:47:22 +01:00
|
|
|
|
2017-09-17 08:47:04 +02:00
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public BlockWallAA(String name, Block base, int meta){
|
2017-07-28 03:17:50 +02:00
|
|
|
super(base.getDefaultState().getMaterial(), name);
|
2015-12-17 20:18:22 +01:00
|
|
|
this.meta = meta;
|
2015-12-03 20:15:07 +01:00
|
|
|
|
2016-01-09 14:35:04 +01:00
|
|
|
this.setHardness(1.5F);
|
|
|
|
this.setResistance(10F);
|
2016-04-20 21:39:03 +02:00
|
|
|
this.setSoundType(base.getSoundType());
|
2016-01-09 14:35:04 +01:00
|
|
|
|
|
|
|
this.setDefaultState(this.blockState.getBaseState().withProperty(BlockWall.UP, false).withProperty(BlockWall.NORTH, false).withProperty(BlockWall.EAST, false).withProperty(BlockWall.SOUTH, false).withProperty(BlockWall.WEST, false));
|
|
|
|
}
|
|
|
|
|
2016-05-03 21:26:02 +02:00
|
|
|
private static int yesThisIsCopyPastedFromBlockWallAndIHaveNoIdeaWhatThisMethodDoes(IBlockState state){
|
2016-05-02 17:12:31 +02:00
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
if(state.getValue(BlockWall.NORTH)){
|
|
|
|
i |= 1 << EnumFacing.NORTH.getHorizontalIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(state.getValue(BlockWall.EAST)){
|
|
|
|
i |= 1 << EnumFacing.EAST.getHorizontalIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(state.getValue(BlockWall.SOUTH)){
|
|
|
|
i |= 1 << EnumFacing.SOUTH.getHorizontalIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(state.getValue(BlockWall.WEST)){
|
|
|
|
i |= 1 << EnumFacing.WEST.getHorizontalIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2016-01-09 14:35:04 +01:00
|
|
|
@Override
|
2016-05-29 23:49:35 +02:00
|
|
|
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos){
|
2016-05-03 21:26:02 +02:00
|
|
|
boolean flag = this.canConnectTo(worldIn, pos.north());
|
|
|
|
boolean flag1 = this.canConnectTo(worldIn, pos.east());
|
|
|
|
boolean flag2 = this.canConnectTo(worldIn, pos.south());
|
|
|
|
boolean flag3 = this.canConnectTo(worldIn, pos.west());
|
|
|
|
boolean flag4 = flag && !flag1 && flag2 && !flag3 || !flag && flag1 && !flag2 && flag3;
|
|
|
|
return state.withProperty(BlockWall.UP, !flag4 || !worldIn.isAirBlock(pos.up())).withProperty(BlockWall.NORTH, flag).withProperty(BlockWall.EAST, flag1).withProperty(BlockWall.SOUTH, flag2).withProperty(BlockWall.WEST, flag3);
|
2016-01-09 14:35:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-03-18 23:47:22 +01:00
|
|
|
public boolean isFullCube(IBlockState state){
|
2016-01-09 14:35:04 +01:00
|
|
|
return false;
|
2015-12-03 20:15:07 +01:00
|
|
|
}
|
|
|
|
|
2016-01-09 14:35:04 +01:00
|
|
|
@Override
|
|
|
|
public boolean isPassable(IBlockAccess worldIn, BlockPos pos){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-02-01 17:49:55 +01:00
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
2017-09-17 08:47:04 +02:00
|
|
|
@Deprecated
|
2016-05-29 23:49:35 +02:00
|
|
|
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side){
|
2016-03-18 23:47:22 +01:00
|
|
|
return side != EnumFacing.DOWN || super.shouldSideBeRendered(blockState, blockAccess, pos, side);
|
2016-02-01 17:49:55 +01:00
|
|
|
}
|
|
|
|
|
2016-05-02 17:09:23 +02:00
|
|
|
@Override
|
2016-03-18 23:47:22 +01:00
|
|
|
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
|
|
|
|
state = this.getActualState(state, source, pos);
|
2016-05-03 21:26:02 +02:00
|
|
|
return AABB_BY_INDEX[yesThisIsCopyPastedFromBlockWallAndIHaveNoIdeaWhatThisMethodDoes(state)];
|
2016-02-01 17:49:55 +01:00
|
|
|
}
|
|
|
|
|
2016-05-02 17:09:23 +02:00
|
|
|
@Override
|
2016-11-19 21:11:17 +01:00
|
|
|
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos){
|
2016-03-18 23:47:22 +01:00
|
|
|
blockState = this.getActualState(blockState, worldIn, pos);
|
2016-05-03 21:26:02 +02:00
|
|
|
return CLIP_AABB_BY_INDEX[yesThisIsCopyPastedFromBlockWallAndIHaveNoIdeaWhatThisMethodDoes(blockState)];
|
2016-01-09 14:35:04 +01:00
|
|
|
}
|
|
|
|
|
2016-03-18 23:47:22 +01:00
|
|
|
@Override
|
|
|
|
public boolean isOpaqueCube(IBlockState state){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int damageDropped(IBlockState state){
|
2016-05-02 17:46:53 +02:00
|
|
|
return this.meta;
|
2016-01-08 20:51:03 +01:00
|
|
|
}
|
|
|
|
|
2016-01-09 14:35:04 +01:00
|
|
|
@Override
|
2016-02-01 17:49:55 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2017-07-28 03:17:50 +02:00
|
|
|
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list){
|
2017-06-17 00:48:49 +02:00
|
|
|
list.add(new ItemStack(this, 1, 0));
|
2015-12-03 20:15:07 +01:00
|
|
|
}
|
|
|
|
|
2016-01-09 14:35:04 +01:00
|
|
|
public boolean canConnectTo(IBlockAccess worldIn, BlockPos pos){
|
2016-03-18 23:47:22 +01:00
|
|
|
IBlockState state = worldIn.getBlockState(pos);
|
2016-07-04 20:15:41 +02:00
|
|
|
Block block = state.getBlock();
|
2017-08-09 18:20:55 +02:00
|
|
|
return block != Blocks.BARRIER && (!(block != this && !(block instanceof BlockFenceGate)) || ((state.getMaterial().isOpaque() && state.isFullCube()) && state.getMaterial() != Material.GOURD));
|
2015-12-03 20:15:07 +01:00
|
|
|
}
|
|
|
|
|
2016-05-29 23:49:35 +02:00
|
|
|
|
2016-01-09 14:35:04 +01:00
|
|
|
@Override
|
2016-02-01 17:49:55 +01:00
|
|
|
public IBlockState getStateFromMeta(int meta){
|
|
|
|
return this.getDefaultState();
|
2015-12-03 20:15:07 +01:00
|
|
|
}
|
|
|
|
|
2016-01-09 14:35:04 +01:00
|
|
|
@Override
|
2016-02-01 17:49:55 +01:00
|
|
|
public int getMetaFromState(IBlockState state){
|
|
|
|
return 0;
|
2015-12-19 10:30:39 +01:00
|
|
|
}
|
|
|
|
|
2016-05-29 23:49:35 +02:00
|
|
|
|
2016-01-09 14:35:04 +01:00
|
|
|
@Override
|
2016-03-18 23:47:22 +01:00
|
|
|
protected BlockStateContainer createBlockState(){
|
|
|
|
return new BlockStateContainer(this, BlockWall.UP, BlockWall.NORTH, BlockWall.EAST, BlockWall.WEST, BlockWall.SOUTH);
|
2015-11-08 18:29:05 +01:00
|
|
|
}
|
|
|
|
}
|