2018-09-16 00:45:44 +02:00
|
|
|
package com.minelittlepony.unicopia.block;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
|
|
|
import com.minelittlepony.unicopia.CloudType;
|
2019-02-24 18:41:17 +01:00
|
|
|
import com.minelittlepony.unicopia.forgebullshit.FUF;
|
2018-09-16 00:45:44 +02:00
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.BlockSlab;
|
2018-09-19 14:39:37 +02:00
|
|
|
import net.minecraft.block.BlockSlab.EnumBlockHalf;
|
2018-09-16 00:45:44 +02:00
|
|
|
import net.minecraft.block.BlockStairs;
|
2018-09-19 14:39:37 +02:00
|
|
|
import net.minecraft.block.state.BlockFaceShape;
|
2018-09-16 00:45:44 +02:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.util.EnumFacing;
|
|
|
|
import net.minecraft.util.math.AxisAlignedBB;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
2019-01-10 10:34:58 +01:00
|
|
|
import net.minecraft.util.math.RayTraceResult;
|
|
|
|
import net.minecraft.util.math.Vec3d;
|
2018-09-16 00:45:44 +02:00
|
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
|
|
public class BlockCloudStairs extends BlockStairs implements ICloudBlock {
|
|
|
|
|
2019-02-08 22:39:02 +01:00
|
|
|
protected Block theBlock;
|
|
|
|
protected IBlockState theState;
|
|
|
|
|
|
|
|
public BlockCloudStairs(IBlockState inherited, String domain, String name) {
|
|
|
|
super(inherited);
|
|
|
|
setTranslationKey(name);
|
|
|
|
setRegistryName(domain, name);
|
|
|
|
theBlock = inherited.getBlock();
|
|
|
|
theState = inherited;
|
2019-02-23 14:23:24 +01:00
|
|
|
|
|
|
|
setTickRandomly(theBlock.getTickRandomly());
|
|
|
|
|
2019-02-08 22:39:02 +01:00
|
|
|
useNeighborBrightness = true;
|
|
|
|
|
|
|
|
fullBlock = isOpaqueCube(inherited);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Deprecated
|
|
|
|
public boolean isTranslucent(IBlockState state) {
|
2018-09-16 00:45:44 +02:00
|
|
|
return theBlock.isTranslucent(state);
|
|
|
|
}
|
|
|
|
|
2019-02-08 22:39:02 +01:00
|
|
|
@Override
|
|
|
|
@Deprecated
|
2018-09-16 00:45:44 +02:00
|
|
|
public boolean isOpaqueCube(IBlockState state) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-02-08 22:39:02 +01:00
|
|
|
@Override
|
|
|
|
@Deprecated
|
|
|
|
public boolean isNormalCube(IBlockState state) {
|
|
|
|
return theBlock.isNormalCube(state);
|
2018-09-16 00:45:44 +02:00
|
|
|
}
|
|
|
|
|
2019-02-08 22:39:02 +01:00
|
|
|
@Override
|
2018-09-16 00:45:44 +02:00
|
|
|
public boolean isPassable(IBlockAccess worldIn, BlockPos pos) {
|
|
|
|
return theBlock.isPassable(worldIn, pos);
|
|
|
|
}
|
|
|
|
|
2019-02-08 22:39:02 +01:00
|
|
|
@Override
|
2018-09-16 00:45:44 +02:00
|
|
|
public void onFallenUpon(World w, BlockPos pos, Entity entity, float fallDistance) {
|
2019-02-08 22:39:02 +01:00
|
|
|
theBlock.onFallenUpon(w, pos, entity, fallDistance);
|
2018-09-16 00:45:44 +02:00
|
|
|
}
|
|
|
|
|
2018-09-19 09:07:39 +02:00
|
|
|
@Override
|
|
|
|
public boolean isAir(IBlockState state, IBlockAccess world, BlockPos pos) {
|
|
|
|
return allowsFallingBlockToPass(state, world, pos);
|
|
|
|
}
|
|
|
|
|
2019-02-08 22:39:02 +01:00
|
|
|
@Override
|
2018-09-16 00:45:44 +02:00
|
|
|
public void onLanded(World w, Entity entity) {
|
2019-02-08 22:39:02 +01:00
|
|
|
theBlock.onLanded(w, entity);
|
2018-09-16 00:45:44 +02:00
|
|
|
}
|
|
|
|
|
2019-02-08 22:39:02 +01:00
|
|
|
@Override
|
2018-09-16 00:45:44 +02:00
|
|
|
public void onEntityCollision(World w, BlockPos pos, IBlockState state, Entity entity) {
|
2019-02-08 22:39:02 +01:00
|
|
|
theBlock.onEntityCollision(w, pos, theState, entity);
|
|
|
|
}
|
2018-09-16 00:45:44 +02:00
|
|
|
|
2019-02-08 22:39:02 +01:00
|
|
|
@Override
|
|
|
|
public void onEntityWalk(World w, BlockPos pos, Entity entity) {
|
|
|
|
theBlock.onEntityWalk(w, pos, entity);
|
|
|
|
}
|
2018-09-16 00:45:44 +02:00
|
|
|
|
2019-02-08 22:39:02 +01:00
|
|
|
@Override
|
|
|
|
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entity, boolean p_185477_7_) {
|
2018-09-16 00:45:44 +02:00
|
|
|
if (getCanInteract(theState, entity)) {
|
2019-02-08 22:39:02 +01:00
|
|
|
super.addCollisionBoxToList(state, worldIn, pos, entityBox, collidingBoxes, entity, p_185477_7_);
|
2018-09-16 00:45:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canEntityDestroy(IBlockState state, IBlockAccess world, BlockPos pos, Entity entity) {
|
|
|
|
return theBlock.canEntityDestroy(state, world, pos, entity);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Deprecated
|
|
|
|
@Override
|
|
|
|
public float getPlayerRelativeBlockHardness(IBlockState state, EntityPlayer player, World worldIn, BlockPos pos) {
|
|
|
|
return theBlock.getPlayerRelativeBlockHardness(state, player, worldIn, pos);
|
|
|
|
}
|
|
|
|
|
2019-01-10 10:34:58 +01:00
|
|
|
@Deprecated
|
|
|
|
@Override
|
|
|
|
public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
|
2019-01-13 21:06:27 +01:00
|
|
|
if (handleRayTraceSpecialCases(worldIn, pos, blockState)) {
|
|
|
|
return null;
|
2019-01-10 10:34:58 +01:00
|
|
|
}
|
|
|
|
return super.collisionRayTrace(blockState, worldIn, pos, start, end);
|
|
|
|
}
|
|
|
|
|
2019-02-24 18:41:17 +01:00
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
@Override
|
|
|
|
public boolean isTopSolid(IBlockState state) {
|
|
|
|
return getCloudMaterialType(state) == CloudType.ENCHANTED && super.isTopSolid(state);
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
@FUF(reason = "...Really?")
|
|
|
|
public boolean isSideSolid(IBlockState base_state, IBlockAccess world, BlockPos pos, EnumFacing side) {
|
|
|
|
return getCloudMaterialType(base_state) == CloudType.ENCHANTED && super.isSideSolid(base_state, world, pos, side);
|
|
|
|
}
|
|
|
|
|
2018-09-16 00:45:44 +02:00
|
|
|
@Override
|
|
|
|
public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) {
|
2018-09-19 14:39:37 +02:00
|
|
|
state = state.getActualState(world, pos);
|
2018-09-16 00:45:44 +02:00
|
|
|
|
2018-09-19 14:39:37 +02:00
|
|
|
IBlockState beside = world.getBlockState(pos.offset(face)).getActualState(world, pos);
|
2018-09-16 00:45:44 +02:00
|
|
|
|
|
|
|
if (beside.getBlock() instanceof ICloudBlock) {
|
|
|
|
ICloudBlock cloud = ((ICloudBlock)beside.getBlock());
|
|
|
|
|
|
|
|
if (cloud.getCloudMaterialType(beside) == getCloudMaterialType(state)) {
|
2018-09-19 14:39:37 +02:00
|
|
|
EnumFacing front = state.getValue(FACING);
|
|
|
|
EnumHalf half = state.getValue(HALF);
|
|
|
|
|
|
|
|
boolean sideIsBack = state.getBlockFaceShape(world, pos, face) == BlockFaceShape.SOLID;
|
|
|
|
boolean sideIsFront = state.getBlockFaceShape(world, pos, face.getOpposite()) == BlockFaceShape.SOLID;
|
|
|
|
boolean sideIsSide = !(sideIsBack || sideIsFront);
|
|
|
|
|
2018-09-16 00:45:44 +02:00
|
|
|
if (beside.getBlock() == this) {
|
|
|
|
EnumFacing bfront = beside.getValue(FACING);
|
|
|
|
EnumHalf bhalf = beside.getValue(HALF);
|
|
|
|
|
2018-09-19 14:39:37 +02:00
|
|
|
if (face == EnumFacing.UP || face == EnumFacing.DOWN) {
|
|
|
|
return half != bhalf
|
|
|
|
&& ( (face == EnumFacing.UP && half == EnumHalf.TOP)
|
|
|
|
|| (face == EnumFacing.DOWN && half == EnumHalf.BOTTOM)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean bsideIsBack = beside.getBlockFaceShape(world, pos, face) == BlockFaceShape.SOLID;
|
|
|
|
boolean bsideIsFront = beside.getBlockFaceShape(world, pos, face.getOpposite()) == BlockFaceShape.SOLID;
|
|
|
|
boolean bsideIsSide = !(bsideIsBack || bsideIsFront);
|
|
|
|
|
|
|
|
return sideIsBack
|
|
|
|
|| (sideIsSide && bsideIsSide && front == bfront && half == bhalf);
|
2018-09-19 10:19:46 +02:00
|
|
|
} else if (beside.getBlock() instanceof BlockCloudSlab) {
|
2018-09-19 14:39:37 +02:00
|
|
|
EnumBlockHalf bhalf = beside.getValue(BlockSlab.HALF);
|
|
|
|
|
|
|
|
if (face == EnumFacing.UP || face == EnumFacing.DOWN) {
|
|
|
|
return bhalf == EnumBlockHalf.TOP && half == EnumHalf.BOTTOM;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bhalf == EnumBlockHalf.TOP && half == EnumHalf.BOTTOM;
|
|
|
|
} else {
|
|
|
|
if (face == EnumFacing.UP || face == EnumFacing.DOWN) {
|
|
|
|
return half == EnumHalf.BOTTOM && face == EnumFacing.DOWN;
|
|
|
|
}
|
2018-09-16 00:45:44 +02:00
|
|
|
}
|
|
|
|
|
2018-09-19 10:19:46 +02:00
|
|
|
return front == face;
|
2018-09-16 00:45:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public CloudType getCloudMaterialType(IBlockState blockState) {
|
|
|
|
return CloudType.NORMAL;
|
|
|
|
}
|
|
|
|
}
|