2016-12-18 13:27:14 +01:00
|
|
|
/*
|
2017-01-01 16:23:26 +01:00
|
|
|
* This file ("BlockItemViewerHopping.java") is part of the Actually Additions mod for Minecraft.
|
2016-12-18 13:27:14 +01:00
|
|
|
* 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
|
|
|
|
*
|
2017-01-01 16:23:26 +01:00
|
|
|
* © 2015-2017 Ellpeck
|
2016-12-18 13:27:14 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
|
|
|
|
|
|
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewerHopping;
|
|
|
|
import net.minecraft.block.properties.PropertyDirection;
|
2021-02-27 13:24:45 +01:00
|
|
|
import net.minecraft.block.state.BlockStateContainer;
|
2016-12-18 13:27:14 +01:00
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.BlockRenderLayer;
|
2021-02-27 13:24:45 +01:00
|
|
|
import net.minecraft.util.Direction;
|
2016-12-18 13:27:14 +01:00
|
|
|
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;
|
2021-02-27 13:24:45 +01:00
|
|
|
import net.minecraftforge.api.distmarker.Dist;
|
2021-02-26 22:15:48 +01:00
|
|
|
import net.minecraftforge.fml.relauncher.OnlyIn;
|
2016-12-18 13:27:14 +01:00
|
|
|
|
2021-02-27 13:24:45 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
2016-12-18 13:27:14 +01:00
|
|
|
//Most of this is just copied from BlockHopper, no credit taken. Or clue what it is.
|
2019-05-02 09:10:29 +02:00
|
|
|
public class BlockItemViewerHopping extends BlockItemViewer {
|
2016-12-18 13:27:14 +01:00
|
|
|
|
2021-02-27 13:24:45 +01:00
|
|
|
public static final PropertyDirection FACING = PropertyDirection.create("facing", facing -> facing != Direction.UP);
|
2016-12-18 13:27:14 +01:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2021-02-27 13:24:45 +01:00
|
|
|
public BlockItemViewerHopping() {
|
|
|
|
super(this.name);
|
2016-12-18 13:27:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-02-26 22:15:48 +01:00
|
|
|
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
2016-12-18 13:27:14 +01:00
|
|
|
return FULL_BLOCK_AABB;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-08-04 04:22:20 +02:00
|
|
|
@Deprecated
|
2021-02-26 22:15:48 +01:00
|
|
|
public void addCollisionBoxToList(BlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, Entity entityIn, boolean someBool) {
|
2021-02-27 13:24:45 +01:00
|
|
|
this.addCollisionBoxToList(pos, entityBox, collidingBoxes, BASE_AABB);
|
|
|
|
this.addCollisionBoxToList(pos, entityBox, collidingBoxes, EAST_AABB);
|
|
|
|
this.addCollisionBoxToList(pos, entityBox, collidingBoxes, WEST_AABB);
|
|
|
|
this.addCollisionBoxToList(pos, entityBox, collidingBoxes, SOUTH_AABB);
|
|
|
|
this.addCollisionBoxToList(pos, entityBox, collidingBoxes, NORTH_AABB);
|
2016-12-18 13:27:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
2016-12-18 13:27:14 +01:00
|
|
|
return new TileEntityItemViewerHopping();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-02-27 13:24:45 +01:00
|
|
|
public BlockState getStateForPlacement(World worldIn, BlockPos pos, Direction facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
|
|
|
|
Direction opp = facing.getOpposite();
|
|
|
|
return this.getDefaultState().withProperty(FACING, opp == Direction.UP
|
|
|
|
? Direction.DOWN
|
|
|
|
: opp);
|
2016-12-18 13:27:14 +01:00
|
|
|
}
|
|
|
|
|
2017-06-29 18:30:02 +02:00
|
|
|
@Override //was isFullyOpaque, not sure if correct change.
|
2021-02-26 22:15:48 +01:00
|
|
|
public boolean isNormalCube(BlockState state) {
|
2016-12-18 13:27:14 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-02-26 22:15:48 +01:00
|
|
|
public boolean isFullCube(BlockState state) {
|
2016-12-18 13:27:14 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-02-26 22:15:48 +01:00
|
|
|
public boolean isOpaqueCube(BlockState state) {
|
2016-12-18 13:27:14 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-02-26 22:15:48 +01:00
|
|
|
@OnlyIn(Dist.CLIENT)
|
2021-02-27 13:24:45 +01:00
|
|
|
public boolean shouldSideBeRendered(BlockState blockState, IBlockAccess blockAccess, BlockPos pos, Direction side) {
|
2016-12-18 13:27:14 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public BlockRenderLayer getRenderLayer() {
|
2016-12-18 13:27:14 +01:00
|
|
|
return BlockRenderLayer.CUTOUT_MIPPED;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-02-26 22:15:48 +01:00
|
|
|
public BlockState getStateFromMeta(int meta) {
|
2021-02-27 13:24:45 +01:00
|
|
|
return this.getDefaultState().withProperty(FACING, Direction.byIndex(meta));
|
2016-12-18 13:27:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-02-26 22:15:48 +01:00
|
|
|
public int getMetaFromState(BlockState state) {
|
2016-12-18 13:27:14 +01:00
|
|
|
return state.getValue(FACING).getIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
protected BlockStateContainer createBlockState() {
|
2016-12-18 13:27:14 +01:00
|
|
|
return new BlockStateContainer(this, FACING);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-02-26 22:15:48 +01:00
|
|
|
public BlockState withRotation(BlockState state, Rotation rot) {
|
2016-12-18 13:27:14 +01:00
|
|
|
return state.withProperty(FACING, rot.rotate(state.getValue(FACING)));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-02-26 22:15:48 +01:00
|
|
|
public BlockState withMirror(BlockState state, Mirror mirror) {
|
2016-12-18 13:27:14 +01:00
|
|
|
return this.withRotation(state, mirror.toRotation(state.getValue(FACING)));
|
|
|
|
}
|
|
|
|
}
|