mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
You can no longer place solid blocks on non-solid cloud blocks
This commit is contained in:
parent
337b652cc0
commit
16d39c781e
6 changed files with 59 additions and 20 deletions
|
@ -15,7 +15,6 @@ import net.minecraft.block.properties.IProperty;
|
|||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -194,10 +193,8 @@ public class BlockCloud extends Block implements ICloudBlock, ITillable {
|
|||
@Deprecated
|
||||
@Override
|
||||
public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
|
||||
if (worldIn.isRemote) {
|
||||
if (!getCanInteract(blockState, Minecraft.getMinecraft().player)) {
|
||||
return null;
|
||||
}
|
||||
if (handleRayTraceSpecialCases(worldIn, pos, blockState)) {
|
||||
return null;
|
||||
}
|
||||
return super.collisionRayTrace(blockState, worldIn, pos, start, end);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ import net.minecraft.util.EnumHand;
|
|||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@ -146,6 +148,15 @@ public class BlockCloudAnvil extends BlockAnvil implements ICloudBlock {
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
|
||||
if (handleRayTraceSpecialCases(worldIn, pos, blockState)) {
|
||||
return null;
|
||||
}
|
||||
return super.collisionRayTrace(blockState, worldIn, pos, start, end);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public float getPlayerRelativeBlockHardness(IBlockState state, EntityPlayer player, World worldIn, BlockPos pos) {
|
||||
|
|
|
@ -9,7 +9,6 @@ import com.minelittlepony.unicopia.UBlocks;
|
|||
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
|
@ -105,10 +104,8 @@ public class BlockCloudFarm extends UFarmland implements ICloudBlock {
|
|||
@Deprecated
|
||||
@Override
|
||||
public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
|
||||
if (worldIn.isRemote) {
|
||||
if (!getCanInteract(blockState, Minecraft.getMinecraft().player)) {
|
||||
return null;
|
||||
}
|
||||
if (handleRayTraceSpecialCases(worldIn, pos, blockState)) {
|
||||
return null;
|
||||
}
|
||||
return super.collisionRayTrace(blockState, worldIn, pos, start, end);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import net.minecraft.block.properties.IProperty;
|
|||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -113,10 +112,8 @@ public class BlockCloudSlab extends BlockSlab implements ICloudBlock {
|
|||
@Deprecated
|
||||
@Override
|
||||
public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
|
||||
if (worldIn.isRemote) {
|
||||
if (!getCanInteract(blockState, Minecraft.getMinecraft().player)) {
|
||||
return null;
|
||||
}
|
||||
if (handleRayTraceSpecialCases(worldIn, pos, blockState)) {
|
||||
return null;
|
||||
}
|
||||
return super.collisionRayTrace(blockState, worldIn, pos, start, end);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import net.minecraft.block.BlockSlab.EnumBlockHalf;
|
|||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -108,10 +107,8 @@ public class BlockCloudStairs extends BlockStairs implements ICloudBlock {
|
|||
@Deprecated
|
||||
@Override
|
||||
public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
|
||||
if (worldIn.isRemote) {
|
||||
if (!getCanInteract(blockState, Minecraft.getMinecraft().player)) {
|
||||
return null;
|
||||
}
|
||||
if (handleRayTraceSpecialCases(worldIn, pos, blockState)) {
|
||||
return null;
|
||||
}
|
||||
return super.collisionRayTrace(blockState, worldIn, pos, start, end);
|
||||
}
|
||||
|
|
|
@ -4,15 +4,55 @@ import com.minelittlepony.unicopia.CloudType;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFalling;
|
||||
import net.minecraft.block.BlockTorch;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface ICloudBlock {
|
||||
|
||||
CloudType getCloudMaterialType(IBlockState blockState);
|
||||
|
||||
default boolean handleRayTraceSpecialCases(World world, BlockPos pos, IBlockState state) {
|
||||
if (world.isRemote) {
|
||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
||||
|
||||
if (!getCanInteract(state, player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ItemStack main = player.getHeldItemMainhand();
|
||||
if (main.isEmpty()) {
|
||||
main = player.getHeldItemOffhand();
|
||||
}
|
||||
|
||||
if (!main.isEmpty() && main.getItem() instanceof ItemBlock) {
|
||||
Block block = ((ItemBlock)main.getItem()).getBlock();
|
||||
|
||||
if (block == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (block instanceof BlockTorch && getCloudMaterialType(state) != CloudType.NORMAL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (block != Blocks.AIR && !(block instanceof ICloudBlock)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean getCanInteract(IBlockState state, Entity e) {
|
||||
return getCloudMaterialType(state).canInteract(e);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue