mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 14:52:58 +00:00
Overwrite getBlockFaceShape for various blocks (#5539)
* Return block face shape data for various blocks. Fixes #5530 * Allow for bounding block tile owners to control the face shape
This commit is contained in:
1 parent
de705af546
commit
c3be258c46
9 files changed
+134
-10
No files matched your search
@@ -1,5 +1,10 @@
|
||||
package mekanism.common.base;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
|
||||
/**
|
||||
* Internal interface. A bounding block is not actually a 'bounding' block, it is really just a fake block that is used to mimic actual block bounds.
|
||||
*
|
||||
@@ -16,4 +21,17 @@ public interface IBoundingBlock {
|
||||
* Called when any part of the structure is broken.
|
||||
*/
|
||||
void onBreak();
|
||||
|
||||
/**
|
||||
* Used for getting the proper BlockFaceShape for the bounding block.
|
||||
*
|
||||
* @param face The face of the block at the offset that the shape is needed for.
|
||||
* @param offset Offset from the implementation of IBoundingBlock
|
||||
*
|
||||
* @return A BlockFaceShape
|
||||
*/
|
||||
@Nonnull
|
||||
default BlockFaceShape getOffsetBlockFaceShape(@Nonnull EnumFacing face, @Nonnull Vec3i offset) {
|
||||
return BlockFaceShape.UNDEFINED;
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,14 @@ package mekanism.common.block;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import mekanism.common.base.IBoundingBlock;
|
||||
import mekanism.common.block.states.BlockStateBounding;
|
||||
import mekanism.common.tile.TileEntityAdvancedBoundingBlock;
|
||||
import mekanism.common.tile.TileEntityBoundingBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFlowerPot;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -201,6 +203,20 @@ public class BlockBounding extends Block {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face) {
|
||||
BlockPos mainPos = getMainBlockPos(world, pos);
|
||||
if (mainPos != null) {
|
||||
TileEntity tile = world.getTileEntity(mainPos);
|
||||
if (tile instanceof IBoundingBlock) {
|
||||
return ((IBoundingBlock) tile).getOffsetBlockFaceShape(face, pos.subtract(mainPos));
|
||||
}
|
||||
}
|
||||
return BlockFaceShape.UNDEFINED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state) {
|
||||
return true;
|
||||
|
||||
@@ -20,6 +20,7 @@ import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.SecurityUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -275,4 +276,11 @@ public class BlockGasTank extends BlockMekanismContainer {
|
||||
public boolean isFullCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face) {
|
||||
return face == EnumFacing.UP || face == EnumFacing.DOWN ? BlockFaceShape.CENTER_BIG : BlockFaceShape.UNDEFINED;
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import mekanism.common.util.MultipartUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -190,4 +191,11 @@ public class BlockGlowPanel extends BlockTileDrops implements ITileEntityProvide
|
||||
public boolean isFullBlock(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face) {
|
||||
return BlockFaceShape.UNDEFINED;
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,7 @@ import mekanism.common.util.StackUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.particle.ParticleManager;
|
||||
@@ -708,15 +709,39 @@ public abstract class BlockMachine extends BlockMekanismContainer {
|
||||
@Deprecated
|
||||
public boolean isSideSolid(IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, EnumFacing side) {
|
||||
MachineType type = MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state));
|
||||
switch (type) {
|
||||
case CHARGEPAD:
|
||||
case PERSONAL_CHEST:
|
||||
return false;
|
||||
case FLUID_TANK:
|
||||
return side == EnumFacing.UP || side == EnumFacing.DOWN;
|
||||
default:
|
||||
return true;
|
||||
if (type != null) {
|
||||
switch (type) {
|
||||
case CHARGEPAD:
|
||||
case PERSONAL_CHEST:
|
||||
return false;
|
||||
case FLUID_TANK:
|
||||
return side == EnumFacing.UP || side == EnumFacing.DOWN;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face) {
|
||||
MachineType type = MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state));
|
||||
if (type != null) {
|
||||
switch (type) {
|
||||
case PERSONAL_CHEST:
|
||||
case LOGISTICAL_SORTER:
|
||||
case LASER:
|
||||
return BlockFaceShape.UNDEFINED;
|
||||
case ELECTRIC_PUMP:
|
||||
case FLUIDIC_PLENISHER:
|
||||
return face == EnumFacing.UP || face == EnumFacing.DOWN ? BlockFaceShape.CENTER_BIG : BlockFaceShape.UNDEFINED;
|
||||
case CHARGEPAD:
|
||||
return face == EnumFacing.DOWN ? BlockFaceShape.SOLID : BlockFaceShape.UNDEFINED;
|
||||
case FLUID_TANK:
|
||||
return face != EnumFacing.UP && face != EnumFacing.DOWN ? BlockFaceShape.UNDEFINED : BlockFaceShape.SOLID;
|
||||
}
|
||||
}
|
||||
return super.getBlockFaceShape(world, state, pos, face);
|
||||
}
|
||||
|
||||
public PropertyEnum<MachineType> getTypeProperty() {
|
||||
|
||||
@@ -31,6 +31,7 @@ import mekanism.common.util.MultipartUtils.AdvancedRayTraceResult;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.particle.ParticleManager;
|
||||
@@ -347,6 +348,13 @@ public class BlockTransmitter extends BlockTileDrops implements ITileEntityProvi
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face) {
|
||||
return BlockFaceShape.UNDEFINED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(@Nonnull World worldIn, int meta) {
|
||||
TransmitterType type = TransmitterType.get(meta);
|
||||
|
||||
@@ -53,6 +53,7 @@ import mekanism.common.util.StackUtils;
|
||||
import mekanism.common.util.TransporterUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockBush;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -1178,8 +1179,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOffsetCapabilityDisabled(@Nonnull Capability<?> capability, EnumFacing side,
|
||||
@Nonnull Vec3i offset) {
|
||||
public boolean isOffsetCapabilityDisabled(@Nonnull Capability<?> capability, EnumFacing side, @Nonnull Vec3i offset) {
|
||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
//Input
|
||||
if (offset.equals(new Vec3i(0, 1, 0))) {
|
||||
@@ -1236,4 +1236,17 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
||||
}
|
||||
return chunkSet;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public BlockFaceShape getOffsetBlockFaceShape(@Nonnull EnumFacing face, @Nonnull Vec3i offset) {
|
||||
if (offset.equals(new Vec3i(0, 1, 0))) {
|
||||
return BlockFaceShape.SOLID;
|
||||
}
|
||||
EnumFacing back = facing.getOpposite();
|
||||
if (offset.equals(new Vec3i(back.getXOffset(), 1, back.getZOffset()))) {
|
||||
return BlockFaceShape.SOLID;
|
||||
}
|
||||
return BlockFaceShape.UNDEFINED;
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,13 @@ import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.tile.prefab.TileEntityElectricBlock;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -212,4 +214,10 @@ public class TileEntitySeismicVibrator extends TileEntityElectricBlock implement
|
||||
public boolean isItemValidForSlot(int slot, @Nonnull ItemStack stack) {
|
||||
return ChargeUtils.canBeDischarged(stack);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public BlockFaceShape getOffsetBlockFaceShape(@Nonnull EnumFacing face, @Nonnull Vec3i offset) {
|
||||
return BlockFaceShape.SOLID;
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ import mekanism.generators.common.tile.turbine.TileEntityTurbineRotor;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
@@ -411,6 +412,25 @@ public abstract class BlockGenerator extends BlockMekanismContainer {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face) {
|
||||
GeneratorType type = GeneratorType.get(state);
|
||||
if (type != null) {
|
||||
switch (type) {
|
||||
case SOLAR_GENERATOR:
|
||||
return BlockFaceShape.UNDEFINED;
|
||||
case ADVANCED_SOLAR_GENERATOR:
|
||||
case WIND_GENERATOR:
|
||||
return face == EnumFacing.DOWN ? BlockFaceShape.SOLID : BlockFaceShape.UNDEFINED;
|
||||
case TURBINE_ROTOR:
|
||||
return face != EnumFacing.UP && face != EnumFacing.DOWN ? BlockFaceShape.MIDDLE_POLE : BlockFaceShape.CENTER;
|
||||
}
|
||||
}
|
||||
return super.getBlockFaceShape(world, state, pos, face);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Nonnull
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user