mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 23:27:59 +01:00
Fixed clouds blocks causing suffocation damage, fixed sides being culled incorrectly
This commit is contained in:
parent
da824ffe7d
commit
c731d515c4
6 changed files with 34 additions and 108 deletions
|
@ -28,11 +28,11 @@ public interface UBlocks {
|
||||||
CloudBlock ENCHANTED_CLOUD_BLOCK = register(new CloudBlock(CloudType.ENCHANTED), "enchanted_cloud_block");
|
CloudBlock ENCHANTED_CLOUD_BLOCK = register(new CloudBlock(CloudType.ENCHANTED), "enchanted_cloud_block");
|
||||||
CloudBlock DENSE_CLOUD_BLOCK = register(new CloudBlock(CloudType.DENSE), "dense_cloud_block");
|
CloudBlock DENSE_CLOUD_BLOCK = register(new CloudBlock(CloudType.DENSE), "dense_cloud_block");
|
||||||
|
|
||||||
CloudStairsBlock<CloudBlock> CLOUD_STAIRS = register(new CloudStairsBlock<>(CLOUD_BLOCK.getDefaultState(), FabricBlockSettings.of(UMaterials.CLOUD).build()), "cloud_stairs");
|
CloudStairsBlock<CloudBlock> CLOUD_STAIRS = register(new CloudStairsBlock<>(CLOUD_BLOCK.getDefaultState(), CloudType.NORMAL.configure().build()), "cloud_stairs");
|
||||||
|
|
||||||
CloudSlabBlock<CloudBlock> CLOUD_SLAB = register(new CloudSlabBlock<>(CLOUD_BLOCK.getDefaultState(), UMaterials.CLOUD), "cloud_slab");
|
CloudSlabBlock<CloudBlock> CLOUD_SLAB = register(new CloudSlabBlock<>(CLOUD_BLOCK.getDefaultState(), CloudType.NORMAL.configure().build()), "cloud_slab");
|
||||||
CloudSlabBlock<CloudBlock> ENCHANTED_CLOUD_SLAB = register(new CloudSlabBlock<>(ENCHANTED_CLOUD_BLOCK.getDefaultState(), UMaterials.CLOUD), "enchanted_cloud_slab");
|
CloudSlabBlock<CloudBlock> ENCHANTED_CLOUD_SLAB = register(new CloudSlabBlock<>(ENCHANTED_CLOUD_BLOCK.getDefaultState(), CloudType.ENCHANTED.configure().build()), "enchanted_cloud_slab");
|
||||||
CloudSlabBlock<CloudBlock> DENSE_CLOUD_SLAB = register(new CloudSlabBlock<>(ENCHANTED_CLOUD_BLOCK.getDefaultState(), UMaterials.CLOUD), "dense_cloud_slab");
|
CloudSlabBlock<CloudBlock> DENSE_CLOUD_SLAB = register(new CloudSlabBlock<>(ENCHANTED_CLOUD_BLOCK.getDefaultState(), CloudType.DENSE.configure().build()), "dense_cloud_slab");
|
||||||
|
|
||||||
CloudDoorBlock MISTED_GLASS_DOOR = register(new CloudDoorBlock(), "misted_glass_door");
|
CloudDoorBlock MISTED_GLASS_DOOR = register(new CloudDoorBlock(), "misted_glass_door");
|
||||||
DutchDoorBlock LIBRARY_DOOR = register(new DutchDoorBlock(FabricBlockSettings.of(Material.WOOD).sounds(BlockSoundGroup.WOOD).hardness(3).build()), "library_door");
|
DutchDoorBlock LIBRARY_DOOR = register(new DutchDoorBlock(FabricBlockSettings.of(Material.WOOD).sounds(BlockSoundGroup.WOOD).hardness(3).build()), "library_door");
|
||||||
|
|
|
@ -4,6 +4,6 @@ import net.minecraft.block.Material;
|
||||||
import net.minecraft.block.MaterialColor;
|
import net.minecraft.block.MaterialColor;
|
||||||
|
|
||||||
public interface UMaterials {
|
public interface UMaterials {
|
||||||
Material CLOUD = new Material.Builder(MaterialColor.WHITE).build();
|
Material CLOUD = new Material.Builder(MaterialColor.WHITE).allowsMovement().build();
|
||||||
Material HIVE = new Material.Builder(MaterialColor.NETHER).build();
|
Material HIVE = new Material.Builder(MaterialColor.NETHER).build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ import com.minelittlepony.unicopia.blockstate.StateMaps;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
import com.minelittlepony.unicopia.util.HoeUtil;
|
import com.minelittlepony.unicopia.util.HoeUtil;
|
||||||
|
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
@ -19,6 +21,7 @@ import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.util.shape.VoxelShapes;
|
import net.minecraft.util.shape.VoxelShapes;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.BlockView;
|
||||||
|
import net.minecraft.world.EmptyBlockView;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class CloudBlock extends Block implements Gas, HoeUtil.Tillable {
|
public class CloudBlock extends Block implements Gas, HoeUtil.Tillable {
|
||||||
|
@ -76,13 +79,13 @@ public class CloudBlock extends Block implements Gas, HoeUtil.Tillable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) {
|
public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) {
|
||||||
if (beside.getBlock() instanceof Gas) {
|
if (beside.getBlock() instanceof Gas) {
|
||||||
Gas cloud = ((Gas)beside.getBlock());
|
VoxelShape myShape = state.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN);
|
||||||
|
VoxelShape otherShape = beside.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN);
|
||||||
|
|
||||||
if (cloud.getGasType(beside) == getGasType(state)) {
|
return VoxelShapes.isSideCovered(myShape, otherShape, face);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.isSideInvisible(state, beside, face);
|
return super.isSideInvisible(state, beside, face);
|
||||||
|
|
|
@ -2,24 +2,22 @@ package com.minelittlepony.unicopia.gas;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.block.AbstractSlabBlock;
|
import com.minelittlepony.unicopia.block.AbstractSlabBlock;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Material;
|
|
||||||
import net.minecraft.block.StairsBlock;
|
|
||||||
import net.minecraft.block.enums.SlabType;
|
|
||||||
import net.minecraft.entity.EntityContext;
|
import net.minecraft.entity.EntityContext;
|
||||||
import net.minecraft.state.property.Properties;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.util.shape.VoxelShapes;
|
import net.minecraft.util.shape.VoxelShapes;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.BlockView;
|
||||||
|
import net.minecraft.world.EmptyBlockView;
|
||||||
|
|
||||||
public class CloudSlabBlock<T extends Block & Gas> extends AbstractSlabBlock<T> implements Gas {
|
public class CloudSlabBlock<T extends Block & Gas> extends AbstractSlabBlock<T> implements Gas {
|
||||||
|
|
||||||
public CloudSlabBlock(BlockState inherited, Material material) {
|
public CloudSlabBlock(BlockState inherited, Settings settings) {
|
||||||
super(inherited, FabricBlockSettings.of(material).build());
|
super(inherited, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -50,46 +48,16 @@ public class CloudSlabBlock<T extends Block & Gas> extends AbstractSlabBlock<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) {
|
public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) {
|
||||||
if (state.get(TYPE) == SlabType.DOUBLE) {
|
|
||||||
if (beside.getBlock() instanceof Gas) {
|
if (beside.getBlock() instanceof Gas) {
|
||||||
Gas cloud = ((Gas)beside.getBlock());
|
VoxelShape myShape = state.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN);
|
||||||
|
VoxelShape otherShape = beside.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN);
|
||||||
|
|
||||||
if (cloud.getGasType(beside) == getGasType(state)) {
|
return VoxelShapes.isSideCovered(myShape, otherShape, face);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return super.isSideInvisible(state, beside, face);
|
||||||
} else {
|
|
||||||
if (beside.getBlock() instanceof Gas) {
|
|
||||||
Gas cloud = ((Gas)beside.getBlock());
|
|
||||||
|
|
||||||
if (cloud.getGasType(beside) == getGasType(state)) {
|
|
||||||
|
|
||||||
SlabType half = state.get(TYPE);
|
|
||||||
|
|
||||||
if (beside.getBlock() instanceof CloudStairsBlock) {
|
|
||||||
return beside.get(StairsBlock.HALF).ordinal() == state.get(TYPE).ordinal()
|
|
||||||
&& beside.get(Properties.FACING) == face;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (face == Direction.DOWN) {
|
|
||||||
return half == SlabType.BOTTOM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (face == Direction.UP) {
|
|
||||||
return half == SlabType.TOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (beside.getBlock() == this) {
|
|
||||||
return beside.get(TYPE) == state.get(TYPE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,17 +2,17 @@ package com.minelittlepony.unicopia.gas;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.block.AbstractStairsBlock;
|
import com.minelittlepony.unicopia.block.AbstractStairsBlock;
|
||||||
|
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.SlabBlock;
|
|
||||||
import net.minecraft.block.enums.BlockHalf;
|
|
||||||
import net.minecraft.block.enums.SlabType;
|
|
||||||
import net.minecraft.entity.EntityContext;
|
import net.minecraft.entity.EntityContext;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.util.shape.VoxelShapes;
|
import net.minecraft.util.shape.VoxelShapes;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.BlockView;
|
||||||
|
import net.minecraft.world.EmptyBlockView;
|
||||||
|
|
||||||
public class CloudStairsBlock<T extends Block & Gas> extends AbstractStairsBlock<T> implements Gas {
|
public class CloudStairsBlock<T extends Block & Gas> extends AbstractStairsBlock<T> implements Gas {
|
||||||
|
|
||||||
|
@ -48,57 +48,15 @@ public class CloudStairsBlock<T extends Block & Gas> extends AbstractStairsBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) {
|
public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) {
|
||||||
if (beside.getBlock() instanceof Gas) {
|
if (beside.getBlock() instanceof Gas) {
|
||||||
Gas cloud = ((Gas)beside.getBlock());
|
VoxelShape myShape = state.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN);
|
||||||
|
VoxelShape otherShape = beside.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN);
|
||||||
|
|
||||||
if (cloud.getGasType(beside) == getGasType(state)) {
|
return VoxelShapes.isSideCovered(myShape, otherShape, face);
|
||||||
Direction front = state.get(FACING);
|
|
||||||
BlockHalf half = state.get(HALF);
|
|
||||||
|
|
||||||
VoxelShape shape = getOutlineShape(state, null, null, EntityContext.absent());
|
|
||||||
|
|
||||||
boolean sideIsBack = Block.isFaceFullSquare(shape, face);
|
|
||||||
boolean sideIsFront = Block.isFaceFullSquare(shape, face.getOpposite());
|
|
||||||
boolean sideIsSide = !(sideIsBack || sideIsFront);
|
|
||||||
|
|
||||||
if (beside.getBlock() == this) {
|
|
||||||
Direction bfront = beside.get(FACING);
|
|
||||||
BlockHalf bhalf = beside.get(HALF);
|
|
||||||
|
|
||||||
if (face == Direction.UP || face == Direction.DOWN) {
|
|
||||||
return half != bhalf
|
|
||||||
&& ( (face == Direction.UP && half == BlockHalf.TOP)
|
|
||||||
|| (face == Direction.DOWN && half == BlockHalf.BOTTOM)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VoxelShape shapeBeside = getOutlineShape(beside, null, null, EntityContext.absent());
|
return super.isSideInvisible(state, beside, face);
|
||||||
|
|
||||||
boolean bsideIsBack = Block.isFaceFullSquare(shapeBeside, face);
|
|
||||||
boolean bsideIsFront = Block.isFaceFullSquare(shapeBeside, face.getOpposite());
|
|
||||||
boolean bsideIsSide = !(bsideIsBack || bsideIsFront);
|
|
||||||
|
|
||||||
return sideIsBack
|
|
||||||
|| (sideIsSide && bsideIsSide && front == bfront && half == bhalf);
|
|
||||||
} else if (beside.getBlock() instanceof CloudSlabBlock) {
|
|
||||||
SlabType bhalf = beside.get(SlabBlock.TYPE);
|
|
||||||
|
|
||||||
if (face == Direction.UP || face == Direction.DOWN) {
|
|
||||||
return bhalf == SlabType.TOP && half == BlockHalf.BOTTOM;
|
|
||||||
}
|
|
||||||
|
|
||||||
return bhalf == SlabType.TOP && half == BlockHalf.BOTTOM;
|
|
||||||
} else {
|
|
||||||
if (face == Direction.UP || face == Direction.DOWN) {
|
|
||||||
return half == BlockHalf.BOTTOM && face == Direction.DOWN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return front == face;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,13 +11,10 @@ public enum CloudType {
|
||||||
ENCHANTED;
|
ENCHANTED;
|
||||||
|
|
||||||
public FabricBlockSettings configure() {
|
public FabricBlockSettings configure() {
|
||||||
FabricBlockSettings settings = FabricBlockSettings.of(UMaterials.CLOUD)
|
return FabricBlockSettings.of(UMaterials.CLOUD)
|
||||||
.strength(0.5F, 1)
|
.strength(0.5F, 1)
|
||||||
.sounds(BlockSoundGroup.WOOL);
|
.sounds(BlockSoundGroup.WOOL)
|
||||||
if (this != NORMAL ) {
|
.nonOpaque();
|
||||||
settings.nonOpaque();
|
|
||||||
}
|
|
||||||
return settings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTranslucent() {
|
public boolean isTranslucent() {
|
||||||
|
|
Loading…
Reference in a new issue