mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-16 13:03:12 +01:00
130 lines
4.7 KiB
Java
130 lines
4.7 KiB
Java
/*
|
|
* This file ("BlockItemViewerHopping.java") is part of the Actually Additions mod for Minecraft.
|
|
* It is created and owned by Ellpeck and distributed
|
|
* under the Actually Additions License to be found at
|
|
* http://ellpeck.de/actaddlicense
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
*
|
|
* © 2015-2017 Ellpeck
|
|
*/
|
|
|
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
|
|
|
import com.google.common.base.Predicate;
|
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewerHopping;
|
|
import net.minecraft.block.properties.PropertyDirection;
|
|
import net.minecraft.block.state.BlockStateContainer;
|
|
import net.minecraft.block.state.IBlockState;
|
|
import net.minecraft.entity.Entity;
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.util.BlockRenderLayer;
|
|
import net.minecraft.util.EnumFacing;
|
|
import net.minecraft.util.Mirror;
|
|
import net.minecraft.util.Rotation;
|
|
import net.minecraft.util.math.AxisAlignedBB;
|
|
import net.minecraft.util.math.BlockPos;
|
|
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;
|
|
|
|
//Most of this is just copied from BlockHopper, no credit taken. Or clue what it is.
|
|
public class BlockItemViewerHopping extends BlockItemViewer{
|
|
|
|
public static final PropertyDirection FACING = PropertyDirection.create("facing", new Predicate<EnumFacing>(){
|
|
@Override
|
|
public boolean apply(EnumFacing facing){
|
|
return facing != EnumFacing.UP;
|
|
}
|
|
});
|
|
|
|
private static final AxisAlignedBB BASE_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.625D, 1.0D);
|
|
private static final AxisAlignedBB SOUTH_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.125D);
|
|
private static final AxisAlignedBB NORTH_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.875D, 1.0D, 1.0D, 1.0D);
|
|
private static final AxisAlignedBB WEST_AABB = new AxisAlignedBB(0.875D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
|
|
private static final AxisAlignedBB EAST_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.125D, 1.0D, 1.0D);
|
|
|
|
public BlockItemViewerHopping(String name){
|
|
super(name);
|
|
}
|
|
|
|
@Override
|
|
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
|
|
return FULL_BLOCK_AABB;
|
|
}
|
|
|
|
@Override
|
|
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, Entity entityIn, boolean someBool){
|
|
addCollisionBoxToList(pos, entityBox, collidingBoxes, BASE_AABB);
|
|
addCollisionBoxToList(pos, entityBox, collidingBoxes, EAST_AABB);
|
|
addCollisionBoxToList(pos, entityBox, collidingBoxes, WEST_AABB);
|
|
addCollisionBoxToList(pos, entityBox, collidingBoxes, SOUTH_AABB);
|
|
addCollisionBoxToList(pos, entityBox, collidingBoxes, NORTH_AABB);
|
|
}
|
|
|
|
@Override
|
|
public TileEntity createNewTileEntity(World worldIn, int meta){
|
|
return new TileEntityItemViewerHopping();
|
|
}
|
|
|
|
@Override
|
|
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer){
|
|
EnumFacing opp = facing.getOpposite();
|
|
return this.getDefaultState().withProperty(FACING, opp == EnumFacing.UP ? EnumFacing.DOWN : opp);
|
|
}
|
|
|
|
@Override
|
|
public boolean isFullyOpaque(IBlockState state){
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean isFullCube(IBlockState state){
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean isOpaqueCube(IBlockState state){
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
@SideOnly(Side.CLIENT)
|
|
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side){
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
@SideOnly(Side.CLIENT)
|
|
public BlockRenderLayer getBlockLayer(){
|
|
return BlockRenderLayer.CUTOUT_MIPPED;
|
|
}
|
|
|
|
@Override
|
|
public IBlockState getStateFromMeta(int meta){
|
|
return this.getDefaultState().withProperty(FACING, EnumFacing.getFront(meta));
|
|
}
|
|
|
|
@Override
|
|
public int getMetaFromState(IBlockState state){
|
|
return state.getValue(FACING).getIndex();
|
|
}
|
|
|
|
@Override
|
|
protected BlockStateContainer createBlockState(){
|
|
return new BlockStateContainer(this, FACING);
|
|
}
|
|
|
|
@Override
|
|
public IBlockState withRotation(IBlockState state, Rotation rot){
|
|
return state.withProperty(FACING, rot.rotate(state.getValue(FACING)));
|
|
}
|
|
|
|
@Override
|
|
public IBlockState withMirror(IBlockState state, Mirror mirror){
|
|
return this.withRotation(state, mirror.toRotation(state.getValue(FACING)));
|
|
}
|
|
}
|