pick 97420a31d The big reformat of 2020

This commit is contained in:
yueh
2020-06-16 21:41:28 +02:00
parent 5304b3febe
commit 5225ea426b
2252 changed files with 95466 additions and 118582 deletions
+168 -211
View File
@@ -18,11 +18,8 @@
package appeng.block;
import javax.annotation.Nullable;
import appeng.helpers.AEGlassMaterial;
import appeng.util.Platform;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
@@ -40,68 +37,60 @@ import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import net.minecraftforge.common.ToolType;
import appeng.helpers.AEGlassMaterial;
import appeng.util.Platform;
public abstract class AEBaseBlock extends Block {
public abstract class AEBaseBlock extends Block
{
private boolean isOpaque = true;
private boolean isFullSize = true;
private boolean isInventory = false;
private boolean isOpaque = true;
private boolean isFullSize = true;
private boolean isInventory = false;
protected VoxelShape boundingBox = VoxelShapes.fullCube();
protected VoxelShape boundingBox = VoxelShapes.fullCube();
protected AEBaseBlock(final Block.Properties props) {
super(props);
}
protected AEBaseBlock( final Block.Properties props )
{
super( props );
}
/**
* Utility function to create block properties with some sensible defaults for
* AE blocks.
*/
public static Block.Properties defaultProps(Material material) {
return defaultProps(material, material.getColor());
}
/**
* Utility function to create block properties with some sensible defaults for AE blocks.
*/
public static Block.Properties defaultProps(Material material) {
return defaultProps(material, material.getColor());
}
/**
* Utility function to create block properties with some sensible defaults for
* AE blocks.
*/
public static Block.Properties defaultProps(Material material, MaterialColor color) {
return Block.Properties.create(material, color)
// These values previousls were encoded in AEBaseBlock
.hardnessAndResistance(2.2f, 11.f).harvestTool(ToolType.PICKAXE).harvestLevel(0)
.sound(getDefaultSoundByMaterial(material));
}
/**
* Utility function to create block properties with some sensible defaults for AE blocks.
*/
public static Block.Properties defaultProps(Material material, MaterialColor color) {
return Block.Properties.create(material, color)
// These values previousls were encoded in AEBaseBlock
.hardnessAndResistance(2.2f, 11.f)
.harvestTool(ToolType.PICKAXE)
.harvestLevel(0)
.sound(getDefaultSoundByMaterial(material));
}
private static SoundType getDefaultSoundByMaterial(Material mat) {
if (mat == AEGlassMaterial.INSTANCE || mat == Material.GLASS) {
return SoundType.GLASS;
} else if (mat == Material.ROCK) {
return SoundType.STONE;
} else if (mat == Material.WOOD) {
return SoundType.WOOD;
} else {
return SoundType.METAL;
}
}
private static SoundType getDefaultSoundByMaterial(Material mat) {
if( mat == AEGlassMaterial.INSTANCE || mat == Material.GLASS )
{
return SoundType.GLASS;
}
else if( mat == Material.ROCK )
{
return SoundType.STONE;
}
else if( mat == Material.WOOD )
{
return SoundType.WOOD;
}
else
{
return SoundType.METAL;
}
}
@Override
public boolean isNormalCube(BlockState state, IBlockReader worldIn, BlockPos pos) {
return this.isFullSize() && this.isOpaque();
}
@Override
public boolean isNormalCube(BlockState state, IBlockReader worldIn, BlockPos pos) {
return this.isFullSize() && this.isOpaque();
}
// FIXME @SuppressWarnings( "deprecation" )
// FIXME @Override
@@ -129,7 +118,6 @@ public abstract class AEBaseBlock extends Block
// FIXME }
// FIXME
// @Override
// public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
// final ICustomCollision collisionHandler = this.getCustomCollision( w, pos );
@@ -192,7 +180,7 @@ public abstract class AEBaseBlock extends Block
// return super.getShape( state, w, pos, context );
// }
// FIXME: Move to state
// FIXME: Move to state
// FIXME @Override
// FIXME public final boolean isOpaqueCube( BlockState state )
// {
@@ -243,190 +231,159 @@ public abstract class AEBaseBlock extends Block
//FIXME return super.collisionRayTrace( state, w, pos, a, b );
//FIXME }
//FIXME
@Override
public boolean hasComparatorInputOverride( BlockState state )
{
return this.isInventory();
}
@Override
public boolean hasComparatorInputOverride(BlockState state) {
return this.isInventory();
}
@Override
public int getComparatorInputOverride(BlockState state, final World worldIn, final BlockPos pos )
{
return 0;
}
@Override
public int getComparatorInputOverride(BlockState state, final World worldIn, final BlockPos pos) {
return 0;
}
/**
* Rotates around the given Axis (usually the current up axis).
*/
public boolean rotateAroundFaceAxis(IWorld w, BlockPos pos, Direction face) {
final IOrientable rotatable = this.getOrientable( w, pos );
/**
* Rotates around the given Axis (usually the current up axis).
*/
public boolean rotateAroundFaceAxis(IWorld w, BlockPos pos, Direction face) {
final IOrientable rotatable = this.getOrientable(w, pos);
if( rotatable != null && rotatable.canBeRotated() )
{
if( this.hasCustomRotation() )
{
this.customRotateBlock( rotatable, face );
return true;
}
else
{
Direction forward = rotatable.getForward();
Direction up = rotatable.getUp();
if (rotatable != null && rotatable.canBeRotated()) {
if (this.hasCustomRotation()) {
this.customRotateBlock(rotatable, face);
return true;
} else {
Direction forward = rotatable.getForward();
Direction up = rotatable.getUp();
for( int rs = 0; rs < 4; rs++ )
{
forward = Platform.rotateAround( forward, face );
up = Platform.rotateAround( up, face );
for (int rs = 0; rs < 4; rs++) {
forward = Platform.rotateAround(forward, face);
up = Platform.rotateAround(up, face);
if( this.isValidOrientation( w, pos, forward, up ) )
{
rotatable.setOrientation( forward, up );
return true;
}
}
}
}
if (this.isValidOrientation(w, pos, forward, up)) {
rotatable.setOrientation(forward, up);
return true;
}
}
}
}
return false;
}
return false;
}
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
{
return ActionResultType.PASS;
}
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
return ActionResultType.PASS;
}
public final Direction mapRotation(final IOrientable ori, final Direction dir )
{
// case DOWN: return bottomIcon;
// case UP: return blockIcon;
// case NORTH: return northIcon;
// case SOUTH: return southIcon;
// case WEST: return sideIcon;
// case EAST: return sideIcon;
public final Direction mapRotation(final IOrientable ori, final Direction dir) {
// case DOWN: return bottomIcon;
// case UP: return blockIcon;
// case NORTH: return northIcon;
// case SOUTH: return southIcon;
// case WEST: return sideIcon;
// case EAST: return sideIcon;
final Direction forward = ori.getForward();
final Direction up = ori.getUp();
final Direction forward = ori.getForward();
final Direction up = ori.getUp();
if( forward == null || up == null )
{
return dir;
}
if (forward == null || up == null) {
return dir;
}
final int west_x = forward.getYOffset() * up.getZOffset() - forward.getZOffset() * up.getYOffset();
final int west_y = forward.getZOffset() * up.getXOffset() - forward.getXOffset() * up.getZOffset();
final int west_z = forward.getXOffset() * up.getYOffset() - forward.getYOffset() * up.getXOffset();
final int west_x = forward.getYOffset() * up.getZOffset() - forward.getZOffset() * up.getYOffset();
final int west_y = forward.getZOffset() * up.getXOffset() - forward.getXOffset() * up.getZOffset();
final int west_z = forward.getXOffset() * up.getYOffset() - forward.getYOffset() * up.getXOffset();
Direction west = null;
for( final Direction dx : Direction.values() )
{
if( dx.getXOffset() == west_x && dx.getYOffset() == west_y && dx.getZOffset() == west_z )
{
west = dx;
}
}
Direction west = null;
for (final Direction dx : Direction.values()) {
if (dx.getXOffset() == west_x && dx.getYOffset() == west_y && dx.getZOffset() == west_z) {
west = dx;
}
}
if( west == null )
{
return dir;
}
if (west == null) {
return dir;
}
if( dir == forward )
{
return Direction.SOUTH;
}
if( dir == forward.getOpposite() )
{
return Direction.NORTH;
}
if (dir == forward) {
return Direction.SOUTH;
}
if (dir == forward.getOpposite()) {
return Direction.NORTH;
}
if( dir == up )
{
return Direction.UP;
}
if( dir == up.getOpposite() )
{
return Direction.DOWN;
}
if (dir == up) {
return Direction.UP;
}
if (dir == up.getOpposite()) {
return Direction.DOWN;
}
if( dir == west )
{
return Direction.WEST;
}
if( dir == west.getOpposite() )
{
return Direction.EAST;
}
if (dir == west) {
return Direction.WEST;
}
if (dir == west.getOpposite()) {
return Direction.EAST;
}
return null;
}
return null;
}
@Override
public String toString()
{
String regName = this.getRegistryName() != null ? this.getRegistryName().getPath() : "unregistered";
return this.getClass().getSimpleName() + "[" + regName + "]";
}
@Override
public String toString() {
String regName = this.getRegistryName() != null ? this.getRegistryName().getPath() : "unregistered";
return this.getClass().getSimpleName() + "[" + regName + "]";
}
protected String getUnlocalizedName( final ItemStack is )
{
return this.getTranslationKey();
}
protected String getUnlocalizedName(final ItemStack is) {
return this.getTranslationKey();
}
protected boolean hasCustomRotation()
{
return false;
}
protected boolean hasCustomRotation() {
return false;
}
protected void customRotateBlock( final IOrientable rotatable, final Direction axis )
{
protected void customRotateBlock(final IOrientable rotatable, final Direction axis) {
}
}
protected IOrientable getOrientable( final IBlockReader w, final BlockPos pos )
{
if( this instanceof IOrientableBlock )
{
IOrientableBlock orientable = (IOrientableBlock) this;
return orientable.getOrientable( w, pos );
}
return null;
}
protected IOrientable getOrientable(final IBlockReader w, final BlockPos pos) {
if (this instanceof IOrientableBlock) {
IOrientableBlock orientable = (IOrientableBlock) this;
return orientable.getOrientable(w, pos);
}
return null;
}
protected boolean isValidOrientation(final IWorld w, final BlockPos pos, final Direction forward, final Direction up )
{
return true;
}
protected boolean isValidOrientation(final IWorld w, final BlockPos pos, final Direction forward,
final Direction up) {
return true;
}
protected boolean isOpaque()
{
return this.isOpaque;
}
protected boolean isOpaque() {
return this.isOpaque;
}
protected boolean setOpaque( final boolean isOpaque )
{
this.isOpaque = isOpaque;
return isOpaque;
}
protected boolean setOpaque(final boolean isOpaque) {
this.isOpaque = isOpaque;
return isOpaque;
}
protected boolean isFullSize()
{
return this.isFullSize;
}
protected boolean isFullSize() {
return this.isFullSize;
}
protected boolean setFullSize( final boolean isFullSize )
{
this.isFullSize = isFullSize;
return isFullSize;
}
protected boolean setFullSize(final boolean isFullSize) {
this.isFullSize = isFullSize;
return isFullSize;
}
protected boolean isInventory()
{
return this.isInventory;
}
protected boolean isInventory() {
return this.isInventory;
}
protected void setInventory( final boolean isInventory )
{
this.isInventory = isInventory;
}
protected void setInventory(final boolean isInventory) {
this.isInventory = isInventory;
}
}