pick 97420a31d The big reformat of 2020
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,16 +18,8 @@
|
||||
|
||||
package appeng.block;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.misc.BlockLightDetector;
|
||||
import appeng.block.misc.BlockSkyCompass;
|
||||
import appeng.block.networking.BlockWireless;
|
||||
import appeng.me.helpers.IGridProxyable;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -43,145 +35,128 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.misc.BlockLightDetector;
|
||||
import appeng.block.misc.BlockSkyCompass;
|
||||
import appeng.block.networking.BlockWireless;
|
||||
import appeng.me.helpers.IGridProxyable;
|
||||
import appeng.tile.AEBaseTile;
|
||||
|
||||
public class AEBaseBlockItem extends BlockItem
|
||||
{
|
||||
public class AEBaseBlockItem extends BlockItem {
|
||||
|
||||
private final AEBaseBlock blockType;
|
||||
private final AEBaseBlock blockType;
|
||||
|
||||
public AEBaseBlockItem(final Block id, Item.Properties props )
|
||||
{
|
||||
super( id, props );
|
||||
this.blockType = (AEBaseBlock) id;
|
||||
}
|
||||
public AEBaseBlockItem(final Block id, Item.Properties props) {
|
||||
super(id, props);
|
||||
this.blockType = (AEBaseBlock) id;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public final void addInformation( final ItemStack itemStack, final World world, final List<ITextComponent> toolTip, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
this.addCheckedInformation( itemStack, world, toolTip, advancedTooltips );
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public final void addInformation(final ItemStack itemStack, final World world, final List<ITextComponent> toolTip,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
this.addCheckedInformation(itemStack, world, toolTip, advancedTooltips);
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void addCheckedInformation(final ItemStack itemStack, final World world, final List<ITextComponent> toolTip, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
this.blockType.addInformation( itemStack, world, toolTip, advancedTooltips );
|
||||
}
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addCheckedInformation(final ItemStack itemStack, final World world, final List<ITextComponent> toolTip,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
this.blockType.addInformation(itemStack, world, toolTip, advancedTooltips);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBookEnchantable( final ItemStack itemstack1, final ItemStack itemstack2 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isBookEnchantable(final ItemStack itemstack1, final ItemStack itemstack2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTranslationKey( final ItemStack is )
|
||||
{
|
||||
return this.blockType.getTranslationKey();
|
||||
}
|
||||
@Override
|
||||
public String getTranslationKey(final ItemStack is) {
|
||||
return this.blockType.getTranslationKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType tryPlace(BlockItemUseContext context) {
|
||||
@Override
|
||||
public ActionResultType tryPlace(BlockItemUseContext context) {
|
||||
|
||||
Direction up = null;
|
||||
Direction forward = null;
|
||||
Direction up = null;
|
||||
Direction forward = null;
|
||||
|
||||
Direction side = context.getFace();
|
||||
PlayerEntity player = context.getPlayer();
|
||||
Direction side = context.getFace();
|
||||
PlayerEntity player = context.getPlayer();
|
||||
|
||||
if( this.blockType instanceof AEBaseTileBlock )
|
||||
{
|
||||
if( this.blockType instanceof BlockLightDetector)
|
||||
{
|
||||
up = side;
|
||||
if( up == Direction.UP || up == Direction.DOWN )
|
||||
{
|
||||
forward = Direction.SOUTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
forward = Direction.UP;
|
||||
}
|
||||
}
|
||||
else if( this.blockType instanceof BlockWireless || this.blockType instanceof BlockSkyCompass)
|
||||
{
|
||||
forward = side;
|
||||
if( forward == Direction.UP || forward == Direction.DOWN )
|
||||
{
|
||||
up = Direction.SOUTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
up = Direction.UP;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
up = Direction.UP;
|
||||
forward = context.getPlacementHorizontalFacing().getOpposite();
|
||||
if (this.blockType instanceof AEBaseTileBlock) {
|
||||
if (this.blockType instanceof BlockLightDetector) {
|
||||
up = side;
|
||||
if (up == Direction.UP || up == Direction.DOWN) {
|
||||
forward = Direction.SOUTH;
|
||||
} else {
|
||||
forward = Direction.UP;
|
||||
}
|
||||
} else if (this.blockType instanceof BlockWireless || this.blockType instanceof BlockSkyCompass) {
|
||||
forward = side;
|
||||
if (forward == Direction.UP || forward == Direction.DOWN) {
|
||||
up = Direction.SOUTH;
|
||||
} else {
|
||||
up = Direction.UP;
|
||||
}
|
||||
} else {
|
||||
up = Direction.UP;
|
||||
forward = context.getPlacementHorizontalFacing().getOpposite();
|
||||
|
||||
if (player != null) {
|
||||
if (player.rotationPitch > 65) {
|
||||
up = forward.getOpposite();
|
||||
forward = Direction.UP;
|
||||
} else if (player.rotationPitch < -65) {
|
||||
up = forward.getOpposite();
|
||||
forward = Direction.DOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (player != null) {
|
||||
if (player.rotationPitch > 65) {
|
||||
up = forward.getOpposite();
|
||||
forward = Direction.UP;
|
||||
} else if (player.rotationPitch < -65) {
|
||||
up = forward.getOpposite();
|
||||
forward = Direction.DOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IOrientable ori = null;
|
||||
if( this.blockType instanceof IOrientableBlock)
|
||||
{
|
||||
ori = ( (IOrientableBlock) this.blockType ).getOrientable( context.getWorld(), context.getPos() );
|
||||
up = side;
|
||||
forward = Direction.SOUTH;
|
||||
if( up.getYOffset() == 0 )
|
||||
{
|
||||
forward = Direction.UP;
|
||||
}
|
||||
}
|
||||
IOrientable ori = null;
|
||||
if (this.blockType instanceof IOrientableBlock) {
|
||||
ori = ((IOrientableBlock) this.blockType).getOrientable(context.getWorld(), context.getPos());
|
||||
up = side;
|
||||
forward = Direction.SOUTH;
|
||||
if (up.getYOffset() == 0) {
|
||||
forward = Direction.UP;
|
||||
}
|
||||
}
|
||||
|
||||
if( !this.blockType.isValidOrientation( context.getWorld(), context.getPos(), forward, up ) )
|
||||
{
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
if (!this.blockType.isValidOrientation(context.getWorld(), context.getPos(), forward, up)) {
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
ActionResultType result = super.tryPlace(context);
|
||||
if (result != ActionResultType.SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
ActionResultType result = super.tryPlace(context);
|
||||
if (result != ActionResultType.SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if( this.blockType instanceof AEBaseTileBlock && !( this.blockType instanceof BlockLightDetector ) )
|
||||
{
|
||||
final AEBaseTile tile = ( (AEBaseTileBlock<?>) this.blockType ).getTileEntity( context.getWorld(), context.getPos() );
|
||||
ori = tile;
|
||||
if (this.blockType instanceof AEBaseTileBlock && !(this.blockType instanceof BlockLightDetector)) {
|
||||
final AEBaseTile tile = ((AEBaseTileBlock<?>) this.blockType).getTileEntity(context.getWorld(),
|
||||
context.getPos());
|
||||
ori = tile;
|
||||
|
||||
if( tile == null )
|
||||
{
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
if (tile == null) {
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
if( ori.canBeRotated() && !this.blockType.hasCustomRotation() )
|
||||
{
|
||||
ori.setOrientation( forward, up );
|
||||
}
|
||||
if (ori.canBeRotated() && !this.blockType.hasCustomRotation()) {
|
||||
ori.setOrientation(forward, up);
|
||||
}
|
||||
|
||||
if( tile instanceof IGridProxyable)
|
||||
{
|
||||
( (IGridProxyable) tile ).getProxy().setOwner( player );
|
||||
}
|
||||
if (tile instanceof IGridProxyable) {
|
||||
((IGridProxyable) tile).getProxy().setOwner(player);
|
||||
}
|
||||
|
||||
tile.onPlacement( context );
|
||||
}
|
||||
else if( this.blockType instanceof IOrientableBlock )
|
||||
{
|
||||
ori.setOrientation( forward, up );
|
||||
}
|
||||
tile.onPlacement(context);
|
||||
} else if (this.blockType instanceof IOrientableBlock) {
|
||||
ori.setOrientation(forward, up);
|
||||
}
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
return ActionResultType.SUCCESS;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,9 @@
|
||||
|
||||
package appeng.block;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.core.localization.GuiText;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -37,128 +32,116 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
public class AEBaseBlockItemChargeable extends AEBaseBlockItem implements IAEItemPowerStorage {
|
||||
|
||||
public class AEBaseBlockItemChargeable extends AEBaseBlockItem implements IAEItemPowerStorage
|
||||
{
|
||||
public AEBaseBlockItemChargeable(Block id, Properties props) {
|
||||
super(id, props);
|
||||
|
||||
public AEBaseBlockItemChargeable(Block id, Properties props) {
|
||||
super(id, props);
|
||||
addPropertyOverride(new ResourceLocation("appliedenergistics2:fill_level"), (is, world, entity) -> {
|
||||
double curPower = getAECurrentPower(is);
|
||||
double maxPower = getAEMaxPower(is);
|
||||
|
||||
addPropertyOverride(new ResourceLocation("appliedenergistics2:fill_level"), (is, world, entity) -> {
|
||||
double curPower = getAECurrentPower(is);
|
||||
double maxPower = getAEMaxPower(is);
|
||||
return (int) Math.round(100 * curPower / maxPower);
|
||||
});
|
||||
}
|
||||
|
||||
return (int) Math.round(100 * curPower / maxPower);
|
||||
});
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addCheckedInformation(final ItemStack stack, final World world, final List<ITextComponent> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
double internalCurrentPower = 0;
|
||||
final double internalMaxPower = this.getMaxEnergyCapacity();
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void addCheckedInformation(final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
double internalCurrentPower = 0;
|
||||
final double internalMaxPower = this.getMaxEnergyCapacity();
|
||||
if (internalMaxPower > 0) {
|
||||
final CompoundNBT tag = stack.getTag();
|
||||
if (tag != null) {
|
||||
internalCurrentPower = tag.getDouble("internalCurrentPower");
|
||||
}
|
||||
|
||||
if( internalMaxPower > 0 )
|
||||
{
|
||||
final CompoundNBT tag = stack.getTag();
|
||||
if( tag != null )
|
||||
{
|
||||
internalCurrentPower = tag.getDouble( "internalCurrentPower" );
|
||||
}
|
||||
final double percent = internalCurrentPower / internalMaxPower;
|
||||
|
||||
final double percent = internalCurrentPower / internalMaxPower;
|
||||
lines.add(GuiText.StoredEnergy.textComponent()
|
||||
.appendText(':' + MessageFormat.format(" {0,number,#} ", internalCurrentPower))
|
||||
.appendSibling(new TranslationTextComponent(PowerUnits.AE.unlocalizedName))
|
||||
.appendText(" - " + MessageFormat.format("{0,number,#.##%}", percent)));
|
||||
}
|
||||
}
|
||||
|
||||
lines.add( GuiText.StoredEnergy.textComponent().appendText(':' + MessageFormat.format( " {0,number,#} ", internalCurrentPower ))
|
||||
.appendSibling(new TranslationTextComponent( PowerUnits.AE.unlocalizedName ))
|
||||
.appendText(" - " + MessageFormat.format( "{0,number,#.##%}", percent )));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public double injectAEPower(final ItemStack is, double amount, Actionable mode) {
|
||||
final double internalCurrentPower = this.getInternal(is);
|
||||
final double internalMaxPower = this.getAEMaxPower(is);
|
||||
final double required = internalMaxPower - internalCurrentPower;
|
||||
final double overflow = Math.max(0, amount - required);
|
||||
|
||||
@Override
|
||||
public double injectAEPower( final ItemStack is, double amount, Actionable mode )
|
||||
{
|
||||
final double internalCurrentPower = this.getInternal( is );
|
||||
final double internalMaxPower = this.getAEMaxPower( is );
|
||||
final double required = internalMaxPower - internalCurrentPower;
|
||||
final double overflow = Math.max( 0, amount - required );
|
||||
if (mode == Actionable.MODULATE) {
|
||||
final double toAdd = Math.min(required, amount);
|
||||
final double newPowerStored = internalCurrentPower + toAdd;
|
||||
|
||||
if( mode == Actionable.MODULATE )
|
||||
{
|
||||
final double toAdd = Math.min( required, amount );
|
||||
final double newPowerStored = internalCurrentPower + toAdd;
|
||||
this.setInternal(is, newPowerStored);
|
||||
}
|
||||
|
||||
this.setInternal( is, newPowerStored );
|
||||
}
|
||||
return overflow;
|
||||
}
|
||||
|
||||
return overflow;
|
||||
}
|
||||
@Override
|
||||
public double extractAEPower(final ItemStack is, double amount, Actionable mode) {
|
||||
final double internalCurrentPower = this.getInternal(is);
|
||||
final double fulfillable = Math.min(amount, internalCurrentPower);
|
||||
|
||||
@Override
|
||||
public double extractAEPower( final ItemStack is, double amount, Actionable mode )
|
||||
{
|
||||
final double internalCurrentPower = this.getInternal( is );
|
||||
final double fulfillable = Math.min( amount, internalCurrentPower );
|
||||
if (mode == Actionable.MODULATE) {
|
||||
final double newPowerStored = internalCurrentPower - fulfillable;
|
||||
|
||||
if( mode == Actionable.MODULATE )
|
||||
{
|
||||
final double newPowerStored = internalCurrentPower - fulfillable;
|
||||
this.setInternal(is, newPowerStored);
|
||||
}
|
||||
|
||||
this.setInternal( is, newPowerStored );
|
||||
}
|
||||
return fulfillable;
|
||||
}
|
||||
|
||||
return fulfillable;
|
||||
}
|
||||
@Override
|
||||
public double getAEMaxPower(final ItemStack is) {
|
||||
return this.getMaxEnergyCapacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAEMaxPower( final ItemStack is )
|
||||
{
|
||||
return this.getMaxEnergyCapacity();
|
||||
}
|
||||
@Override
|
||||
public double getAECurrentPower(final ItemStack is) {
|
||||
return this.getInternal(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAECurrentPower( final ItemStack is )
|
||||
{
|
||||
return this.getInternal( is );
|
||||
}
|
||||
@Override
|
||||
public AccessRestriction getPowerFlow(final ItemStack is) {
|
||||
return AccessRestriction.WRITE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessRestriction getPowerFlow( final ItemStack is )
|
||||
{
|
||||
return AccessRestriction.WRITE;
|
||||
}
|
||||
private double getMaxEnergyCapacity() {
|
||||
final Block blockID = Block.getBlockFromItem(this);
|
||||
final IBlockDefinition energyCell = AEApi.instance().definitions().blocks().energyCell();
|
||||
|
||||
private double getMaxEnergyCapacity()
|
||||
{
|
||||
final Block blockID = Block.getBlockFromItem( this );
|
||||
final IBlockDefinition energyCell = AEApi.instance().definitions().blocks().energyCell();
|
||||
return energyCell.maybeBlock().map(block -> {
|
||||
if (blockID == block) {
|
||||
return 200000;
|
||||
} else {
|
||||
return 8 * 200000;
|
||||
}
|
||||
}).orElse(0);
|
||||
}
|
||||
|
||||
return energyCell.maybeBlock().map( block ->
|
||||
{
|
||||
if( blockID == block )
|
||||
{
|
||||
return 200000;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 8 * 200000;
|
||||
}
|
||||
} ).orElse( 0 );
|
||||
}
|
||||
private double getInternal(final ItemStack is) {
|
||||
final CompoundNBT nbt = is.getOrCreateTag();
|
||||
return nbt.getDouble("internalCurrentPower");
|
||||
}
|
||||
|
||||
private double getInternal( final ItemStack is )
|
||||
{
|
||||
final CompoundNBT nbt = is.getOrCreateTag();
|
||||
return nbt.getDouble( "internalCurrentPower" );
|
||||
}
|
||||
|
||||
private void setInternal( final ItemStack is, final double amt )
|
||||
{
|
||||
final CompoundNBT nbt = is.getOrCreateTag();
|
||||
nbt.putDouble("internalCurrentPower", amt);
|
||||
}
|
||||
private void setInternal(final ItemStack is, final double amt) {
|
||||
final CompoundNBT nbt = is.getOrCreateTag();
|
||||
nbt.putDouble("internalCurrentPower", amt);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,20 +18,15 @@
|
||||
|
||||
package appeng.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.api.implementations.items.IMemoryCard;
|
||||
import appeng.api.implementations.items.MemoryCardMessages;
|
||||
import appeng.api.implementations.tiles.IColorableTile;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.SettingsFrom;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
@@ -50,292 +45,262 @@ import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
import appeng.api.implementations.items.IMemoryCard;
|
||||
import appeng.api.implementations.items.MemoryCardMessages;
|
||||
import appeng.api.implementations.tiles.IColorableTile;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.SettingsFrom;
|
||||
|
||||
public abstract class AEBaseTileBlock<T extends AEBaseTile> extends AEBaseBlock
|
||||
{
|
||||
public abstract class AEBaseTileBlock<T extends AEBaseTile> extends AEBaseBlock {
|
||||
|
||||
@Nonnull
|
||||
private Class<T> tileEntityClass;
|
||||
@Nonnull
|
||||
private Supplier<T> tileEntityFactory;
|
||||
@Nonnull
|
||||
private Class<T> tileEntityClass;
|
||||
@Nonnull
|
||||
private Supplier<T> tileEntityFactory;
|
||||
|
||||
public AEBaseTileBlock( final Block.Properties props )
|
||||
{
|
||||
super( props );
|
||||
}
|
||||
public AEBaseTileBlock(final Block.Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
// TODO : Was this change needed?
|
||||
public void setTileEntity( final Class<T> tileEntityClass, Supplier<T> factory )
|
||||
{
|
||||
this.tileEntityClass = tileEntityClass;
|
||||
this.tileEntityFactory = factory;
|
||||
this.setInventory( AEBaseInvTile.class.isAssignableFrom( tileEntityClass ) );
|
||||
}
|
||||
// TODO : Was this change needed?
|
||||
public void setTileEntity(final Class<T> tileEntityClass, Supplier<T> factory) {
|
||||
this.tileEntityClass = tileEntityClass;
|
||||
this.tileEntityFactory = factory;
|
||||
this.setInventory(AEBaseInvTile.class.isAssignableFrom(tileEntityClass));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity( BlockState state )
|
||||
{
|
||||
return this.hasBlockTileEntity();
|
||||
}
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return this.hasBlockTileEntity();
|
||||
}
|
||||
|
||||
private boolean hasBlockTileEntity()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
private boolean hasBlockTileEntity() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Class<T> getTileEntityClass()
|
||||
{
|
||||
return this.tileEntityClass;
|
||||
}
|
||||
public Class<T> getTileEntityClass() {
|
||||
return this.tileEntityClass;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public T getTileEntity( final IBlockReader w, final int x, final int y, final int z )
|
||||
{
|
||||
return this.getTileEntity( w, new BlockPos( x, y, z ) );
|
||||
}
|
||||
@Nullable
|
||||
public T getTileEntity(final IBlockReader w, final int x, final int y, final int z) {
|
||||
return this.getTileEntity(w, new BlockPos(x, y, z));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public T getTileEntity( final IBlockReader w, final BlockPos pos )
|
||||
{
|
||||
if( !this.hasBlockTileEntity() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Nullable
|
||||
public T getTileEntity(final IBlockReader w, final BlockPos pos) {
|
||||
if (!this.hasBlockTileEntity()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final TileEntity te = w.getTileEntity( pos );
|
||||
// FIXME: This gets called as part of building the block state cache
|
||||
if( this.tileEntityClass != null && this.tileEntityClass.isInstance( te ) )
|
||||
{
|
||||
return this.tileEntityClass.cast(te);
|
||||
}
|
||||
final TileEntity te = w.getTileEntity(pos);
|
||||
// FIXME: This gets called as part of building the block state cache
|
||||
if (this.tileEntityClass != null && this.tileEntityClass.isInstance(te)) {
|
||||
return this.tileEntityClass.cast(te);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final TileEntity createTileEntity( BlockState state, IBlockReader world )
|
||||
{
|
||||
return this.tileEntityFactory.get();
|
||||
}
|
||||
@Override
|
||||
public final TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||
return this.tileEntityFactory.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropXpOnBlockBreak(World worldIn, BlockPos pos, int amount) {
|
||||
super.dropXpOnBlockBreak(worldIn, pos, amount);
|
||||
}
|
||||
@Override
|
||||
public void dropXpOnBlockBreak(World worldIn, BlockPos pos, int amount) {
|
||||
super.dropXpOnBlockBreak(worldIn, pos, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (newState.getBlock() == state.getBlock()) {
|
||||
return; // Just a block state change
|
||||
}
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (newState.getBlock() == state.getBlock()) {
|
||||
return; // Just a block state change
|
||||
}
|
||||
|
||||
final AEBaseTile te = this.getTileEntity( w, pos );
|
||||
if( te != null )
|
||||
{
|
||||
final ArrayList<ItemStack> drops = new ArrayList<>();
|
||||
if( te.dropItems() )
|
||||
{
|
||||
te.getDrops( w, pos, drops );
|
||||
}
|
||||
else
|
||||
{
|
||||
te.getNoDrops( w, pos, drops );
|
||||
}
|
||||
final AEBaseTile te = this.getTileEntity(w, pos);
|
||||
if (te != null) {
|
||||
final ArrayList<ItemStack> drops = new ArrayList<>();
|
||||
if (te.dropItems()) {
|
||||
te.getDrops(w, pos, drops);
|
||||
} else {
|
||||
te.getNoDrops(w, pos, drops);
|
||||
}
|
||||
|
||||
// Cry ;_; ...
|
||||
Platform.spawnDrops( w, pos, drops );
|
||||
}
|
||||
// Cry ;_; ...
|
||||
Platform.spawnDrops(w, pos, drops);
|
||||
}
|
||||
|
||||
// super will remove the TE, as it is not an instance of BlockContainer
|
||||
super.onReplaced( state, w, pos, newState, isMoving );
|
||||
}
|
||||
// super will remove the TE, as it is not an instance of BlockContainer
|
||||
super.onReplaced(state, w, pos, newState, isMoving);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolorBlock( BlockState state, final IWorld world, final BlockPos pos, final Direction side, final DyeColor color )
|
||||
{
|
||||
final TileEntity te = this.getTileEntity( world, pos );
|
||||
@Override
|
||||
public boolean recolorBlock(BlockState state, final IWorld world, final BlockPos pos, final Direction side,
|
||||
final DyeColor color) {
|
||||
final TileEntity te = this.getTileEntity(world, pos);
|
||||
|
||||
if( te instanceof IColorableTile )
|
||||
{
|
||||
final IColorableTile ct = (IColorableTile) te;
|
||||
final AEColor c = ct.getColor();
|
||||
final AEColor newColor = AEColor.values()[color.ordinal()];
|
||||
if (te instanceof IColorableTile) {
|
||||
final IColorableTile ct = (IColorableTile) te;
|
||||
final AEColor c = ct.getColor();
|
||||
final AEColor newColor = AEColor.values()[color.ordinal()];
|
||||
|
||||
if( c != newColor )
|
||||
{
|
||||
ct.recolourBlock( side, newColor, null );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (c != newColor) {
|
||||
ct.recolourBlock(side, newColor, null);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return super.recolorBlock( state, world, pos, side, color );
|
||||
}
|
||||
return super.recolorBlock(state, world, pos, side, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride( BlockState state, final World w, final BlockPos pos )
|
||||
{
|
||||
final TileEntity te = this.getTileEntity( w, pos );
|
||||
if( te instanceof AEBaseInvTile )
|
||||
{
|
||||
AEBaseInvTile invTile = (AEBaseInvTile) te;
|
||||
if( invTile.getInternalInventory().getSlots() > 0 )
|
||||
{
|
||||
return ItemHandlerHelper.calcRedstoneFromInventory( invTile.getInternalInventory() );
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getComparatorInputOverride(BlockState state, final World w, final BlockPos pos) {
|
||||
final TileEntity te = this.getTileEntity(w, pos);
|
||||
if (te instanceof AEBaseInvTile) {
|
||||
AEBaseInvTile invTile = (AEBaseInvTile) te;
|
||||
if (invTile.getInternalInventory().getSlots() > 0) {
|
||||
return ItemHandlerHelper.calcRedstoneFromInventory(invTile.getInternalInventory());
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventReceived( final BlockState state, final World worldIn, final BlockPos pos, final int eventID, final int eventParam )
|
||||
{
|
||||
super.eventReceived( state, worldIn, pos, eventID, eventParam );
|
||||
final TileEntity tileentity = worldIn.getTileEntity( pos );
|
||||
return tileentity != null ? tileentity.receiveClientEvent( eventID, eventParam ) : false;
|
||||
}
|
||||
@Override
|
||||
public boolean eventReceived(final BlockState state, final World worldIn, final BlockPos pos, final int eventID,
|
||||
final int eventParam) {
|
||||
super.eventReceived(state, worldIn, pos, eventID, eventParam);
|
||||
final TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
return tileentity != null ? tileentity.receiveClientEvent(eventID, eventParam) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy( final World w, final BlockPos pos, final BlockState state, final LivingEntity placer, final ItemStack is )
|
||||
{
|
||||
if( is.hasDisplayName() )
|
||||
{
|
||||
final TileEntity te = this.getTileEntity( w, pos );
|
||||
if( te instanceof AEBaseTile )
|
||||
{
|
||||
// FIXME: Check if this will make it translated
|
||||
( (AEBaseTile) w.getTileEntity( pos ) ).setName( is.getDisplayName().getString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onBlockPlacedBy(final World w, final BlockPos pos, final BlockState state, final LivingEntity placer,
|
||||
final ItemStack is) {
|
||||
if (is.hasDisplayName()) {
|
||||
final TileEntity te = this.getTileEntity(w, pos);
|
||||
if (te instanceof AEBaseTile) {
|
||||
// FIXME: Check if this will make it translated
|
||||
((AEBaseTile) w.getTileEntity(pos)).setName(is.getDisplayName().getString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onBlockActivated( BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit )
|
||||
{
|
||||
ItemStack heldItem;
|
||||
if( player != null && !player.getHeldItem( hand ).isEmpty() )
|
||||
{
|
||||
heldItem = player.getHeldItem( hand );
|
||||
@Override
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player,
|
||||
Hand hand, BlockRayTraceResult hit) {
|
||||
ItemStack heldItem;
|
||||
if (player != null && !player.getHeldItem(hand).isEmpty()) {
|
||||
heldItem = player.getHeldItem(hand);
|
||||
|
||||
if( Platform.isWrench( player, heldItem, pos ) && player.isCrouching() )
|
||||
{
|
||||
final BlockState blockState = world.getBlockState( pos );
|
||||
final Block block = blockState.getBlock();
|
||||
if (Platform.isWrench(player, heldItem, pos) && player.isCrouching()) {
|
||||
final BlockState blockState = world.getBlockState(pos);
|
||||
final Block block = blockState.getBlock();
|
||||
|
||||
final AEBaseTile tile = this.getTileEntity( world, pos );
|
||||
final AEBaseTile tile = this.getTileEntity(world, pos);
|
||||
|
||||
if( tile == null )
|
||||
{
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
if (tile == null) {
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
if( tile instanceof TileCableBus || tile instanceof TileSkyChest)
|
||||
{
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
if (tile instanceof TileCableBus || tile instanceof TileSkyChest) {
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
final ItemStack[] itemDropCandidates = Platform.getBlockDrops( world, pos );
|
||||
final ItemStack op = new ItemStack( this );
|
||||
final ItemStack[] itemDropCandidates = Platform.getBlockDrops(world, pos);
|
||||
final ItemStack op = new ItemStack(this);
|
||||
|
||||
for( final ItemStack ol : itemDropCandidates )
|
||||
{
|
||||
if( Platform.itemComparisons().isEqualItemType( ol, op ) )
|
||||
{
|
||||
final CompoundNBT tag = tile.downloadSettings( SettingsFrom.DISMANTLE_ITEM );
|
||||
if( tag != null )
|
||||
{
|
||||
ol.setTag( tag );
|
||||
}
|
||||
}
|
||||
}
|
||||
for (final ItemStack ol : itemDropCandidates) {
|
||||
if (Platform.itemComparisons().isEqualItemType(ol, op)) {
|
||||
final CompoundNBT tag = tile.downloadSettings(SettingsFrom.DISMANTLE_ITEM);
|
||||
if (tag != null) {
|
||||
ol.setTag(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( block.removedByPlayer( blockState, world, pos, player, false, world.getFluidState(pos) ) )
|
||||
{
|
||||
final List<ItemStack> itemsToDrop = Lists.newArrayList( itemDropCandidates );
|
||||
Platform.spawnDrops( world, pos, itemsToDrop );
|
||||
world.removeBlock(pos, false);
|
||||
}
|
||||
if (block.removedByPlayer(blockState, world, pos, player, false, world.getFluidState(pos))) {
|
||||
final List<ItemStack> itemsToDrop = Lists.newArrayList(itemDropCandidates);
|
||||
Platform.spawnDrops(world, pos, itemsToDrop);
|
||||
world.removeBlock(pos, false);
|
||||
}
|
||||
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
if( heldItem.getItem() instanceof IMemoryCard && !( this instanceof BlockCableBus) )
|
||||
{
|
||||
final IMemoryCard memoryCard = (IMemoryCard) heldItem.getItem();
|
||||
final AEBaseTile tileEntity = this.getTileEntity( world, pos );
|
||||
if (heldItem.getItem() instanceof IMemoryCard && !(this instanceof BlockCableBus)) {
|
||||
final IMemoryCard memoryCard = (IMemoryCard) heldItem.getItem();
|
||||
final AEBaseTile tileEntity = this.getTileEntity(world, pos);
|
||||
|
||||
if( tileEntity == null )
|
||||
{
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
if (tileEntity == null) {
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
final String name = this.getTranslationKey();
|
||||
final String name = this.getTranslationKey();
|
||||
|
||||
if( player.isCrouching() )
|
||||
{
|
||||
final CompoundNBT data = tileEntity.downloadSettings( SettingsFrom.MEMORY_CARD );
|
||||
if( data != null )
|
||||
{
|
||||
memoryCard.setMemoryCardContents( heldItem, name, data );
|
||||
memoryCard.notifyUser( player, MemoryCardMessages.SETTINGS_SAVED );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final String savedName = memoryCard.getSettingsName( heldItem );
|
||||
final CompoundNBT data = memoryCard.getData( heldItem );
|
||||
if (player.isCrouching()) {
|
||||
final CompoundNBT data = tileEntity.downloadSettings(SettingsFrom.MEMORY_CARD);
|
||||
if (data != null) {
|
||||
memoryCard.setMemoryCardContents(heldItem, name, data);
|
||||
memoryCard.notifyUser(player, MemoryCardMessages.SETTINGS_SAVED);
|
||||
}
|
||||
} else {
|
||||
final String savedName = memoryCard.getSettingsName(heldItem);
|
||||
final CompoundNBT data = memoryCard.getData(heldItem);
|
||||
|
||||
if( this.getTranslationKey().equals( savedName ) )
|
||||
{
|
||||
tileEntity.uploadSettings( SettingsFrom.MEMORY_CARD, data );
|
||||
memoryCard.notifyUser( player, MemoryCardMessages.SETTINGS_LOADED );
|
||||
}
|
||||
else
|
||||
{
|
||||
memoryCard.notifyUser( player, MemoryCardMessages.INVALID_MACHINE );
|
||||
}
|
||||
}
|
||||
if (this.getTranslationKey().equals(savedName)) {
|
||||
tileEntity.uploadSettings(SettingsFrom.MEMORY_CARD, data);
|
||||
memoryCard.notifyUser(player, MemoryCardMessages.SETTINGS_LOADED);
|
||||
} else {
|
||||
memoryCard.notifyUser(player, MemoryCardMessages.INVALID_MACHINE);
|
||||
}
|
||||
}
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return this.onActivated( world, pos, player, hand, player.getHeldItem( hand ), hit );
|
||||
}
|
||||
return this.onActivated(world, pos, player, hand, player.getHeldItem(hand), hit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOrientable getOrientable(final IBlockReader w, final BlockPos pos )
|
||||
{
|
||||
return this.getTileEntity( w, pos );
|
||||
}
|
||||
@Override
|
||||
public IOrientable getOrientable(final IBlockReader w, final BlockPos pos) {
|
||||
return this.getTileEntity(w, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the BlockState based on the given BlockState while considering the state of the given TileEntity.
|
||||
*
|
||||
* If the given TileEntity is not of the right type for this block, the state is returned unchanged,
|
||||
* this is also the case if the given block state does not belong to this block.
|
||||
*/
|
||||
public final BlockState getTileEntityBlockState(BlockState current, TileEntity te) {
|
||||
if (current.getBlock() != this || !tileEntityClass.isInstance(te)) {
|
||||
return current;
|
||||
}
|
||||
/**
|
||||
* Returns the BlockState based on the given BlockState while considering the
|
||||
* state of the given TileEntity.
|
||||
*
|
||||
* If the given TileEntity is not of the right type for this block, the state is
|
||||
* returned unchanged, this is also the case if the given block state does not
|
||||
* belong to this block.
|
||||
*/
|
||||
public final BlockState getTileEntityBlockState(BlockState current, TileEntity te) {
|
||||
if (current.getBlock() != this || !tileEntityClass.isInstance(te)) {
|
||||
return current;
|
||||
}
|
||||
|
||||
return updateBlockStateFromTileEntity(current, tileEntityClass.cast(te));
|
||||
}
|
||||
return updateBlockStateFromTileEntity(current, tileEntityClass.cast(te));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reimplement this in subclasses to allow tile-entities to update the state of their block when their own
|
||||
* state changes.
|
||||
*
|
||||
* It is guaranteed that te is not-null and the block of the given block state is this exact block instance.
|
||||
*/
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, T te) {
|
||||
return currentState;
|
||||
}
|
||||
/**
|
||||
* Reimplement this in subclasses to allow tile-entities to update the state of
|
||||
* their block when their own state changes.
|
||||
*
|
||||
* It is guaranteed that te is not-null and the block of the given block state
|
||||
* is this exact block instance.
|
||||
*/
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, T te) {
|
||||
return currentState;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,13 +18,10 @@
|
||||
|
||||
package appeng.block.crafting;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerCraftingCPU;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
@@ -33,75 +30,71 @@ import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerCraftingCPU;
|
||||
import appeng.tile.crafting.TileCraftingTile;
|
||||
|
||||
public abstract class AbstractCraftingUnitBlock<T extends TileCraftingTile> extends AEBaseTileBlock<T> {
|
||||
public static final BooleanProperty FORMED = BooleanProperty.create("formed");
|
||||
public static final BooleanProperty POWERED = BooleanProperty.create("powered");
|
||||
|
||||
public abstract class AbstractCraftingUnitBlock<T extends TileCraftingTile> extends AEBaseTileBlock<T>
|
||||
{
|
||||
public static final BooleanProperty FORMED = BooleanProperty.create( "formed" );
|
||||
public static final BooleanProperty POWERED = BooleanProperty.create( "powered" );
|
||||
public final CraftingUnitType type;
|
||||
|
||||
public final CraftingUnitType type;
|
||||
public AbstractCraftingUnitBlock(Block.Properties props, final CraftingUnitType type) {
|
||||
super(props);
|
||||
this.type = type;
|
||||
this.setDefaultState(getDefaultState().with(FORMED, false).with(POWERED, false));
|
||||
}
|
||||
|
||||
public AbstractCraftingUnitBlock(Block.Properties props, final CraftingUnitType type )
|
||||
{
|
||||
super( props );
|
||||
this.type = type;
|
||||
this.setDefaultState(getDefaultState().with(FORMED, false).with(POWERED, false));
|
||||
}
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(POWERED);
|
||||
builder.add(FORMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(POWERED);
|
||||
builder.add(FORMED);
|
||||
}
|
||||
@Override
|
||||
public void neighborChanged(final BlockState state, final World worldIn, final BlockPos pos, final Block blockIn,
|
||||
final BlockPos fromPos, boolean isMoving) {
|
||||
final TileCraftingTile cp = this.getTileEntity(worldIn, pos);
|
||||
if (cp != null) {
|
||||
cp.updateMultiBlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged( final BlockState state, final World worldIn, final BlockPos pos, final Block blockIn, final BlockPos fromPos, boolean isMoving )
|
||||
{
|
||||
final TileCraftingTile cp = this.getTileEntity( worldIn, pos );
|
||||
if( cp != null )
|
||||
{
|
||||
cp.updateMultiBlock();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (newState.getBlock() == state.getBlock()) {
|
||||
return; // Just a block state change
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving)
|
||||
{
|
||||
if (newState.getBlock() == state.getBlock()) {
|
||||
return; // Just a block state change
|
||||
}
|
||||
final TileCraftingTile cp = this.getTileEntity(w, pos);
|
||||
if (cp != null) {
|
||||
cp.breakCluster();
|
||||
}
|
||||
|
||||
final TileCraftingTile cp = this.getTileEntity( w, pos );
|
||||
if( cp != null )
|
||||
{
|
||||
cp.breakCluster();
|
||||
}
|
||||
super.onReplaced(state, w, pos, newState, isMoving);
|
||||
}
|
||||
|
||||
super.onReplaced( state, w, pos, newState, isMoving );
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand,
|
||||
BlockRayTraceResult hit) {
|
||||
final TileCraftingTile tg = this.getTileEntity(w, pos);
|
||||
|
||||
@Override
|
||||
public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand, BlockRayTraceResult hit) {
|
||||
final TileCraftingTile tg = this.getTileEntity( w, pos );
|
||||
if (tg != null && !p.isCrouching() && tg.isFormed() && tg.isActive()) {
|
||||
if (!w.isRemote()) {
|
||||
ContainerOpener.openContainer(ContainerCraftingCPU.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
|
||||
if( tg != null && !p.isCrouching() && tg.isFormed() && tg.isActive() )
|
||||
{
|
||||
if ( !w.isRemote() )
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerCraftingCPU.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return super.onBlockActivated(state, w, pos, p, hand, hit);
|
||||
}
|
||||
|
||||
return super.onBlockActivated(state, w, pos, p, hand, hit);
|
||||
}
|
||||
|
||||
public enum CraftingUnitType
|
||||
{
|
||||
UNIT, ACCELERATOR, STORAGE_1K, STORAGE_4K, STORAGE_16K, STORAGE_64K, MONITOR
|
||||
}
|
||||
public enum CraftingUnitType {
|
||||
UNIT, ACCELERATOR, STORAGE_1K, STORAGE_4K, STORAGE_16K, STORAGE_64K, MONITOR
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,13 +18,10 @@
|
||||
|
||||
package appeng.block.crafting;
|
||||
|
||||
|
||||
import appeng.tile.crafting.TileCraftingMonitorTile;
|
||||
|
||||
public class BlockCraftingMonitor extends AbstractCraftingUnitBlock<TileCraftingMonitorTile>
|
||||
{
|
||||
public BlockCraftingMonitor(Properties props)
|
||||
{
|
||||
super( props, CraftingUnitType.MONITOR );
|
||||
}
|
||||
public class BlockCraftingMonitor extends AbstractCraftingUnitBlock<TileCraftingMonitorTile> {
|
||||
public BlockCraftingMonitor(Properties props) {
|
||||
super(props, CraftingUnitType.MONITOR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,12 @@
|
||||
|
||||
package appeng.block.crafting;
|
||||
|
||||
|
||||
import appeng.tile.crafting.TileCraftingStorageTile;
|
||||
|
||||
public class BlockCraftingStorage extends AbstractCraftingUnitBlock<TileCraftingStorageTile>
|
||||
{
|
||||
public class BlockCraftingStorage extends AbstractCraftingUnitBlock<TileCraftingStorageTile> {
|
||||
|
||||
public BlockCraftingStorage(Properties props, CraftingUnitType type) {
|
||||
super(props, type);
|
||||
}
|
||||
public BlockCraftingStorage(Properties props, CraftingUnitType type) {
|
||||
super(props, type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,13 +18,6 @@
|
||||
|
||||
package appeng.block.crafting;
|
||||
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerInscriber;
|
||||
import appeng.container.implementations.ContainerMAC;
|
||||
import appeng.tile.crafting.TileMolecularAssembler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -36,41 +29,46 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerInscriber;
|
||||
import appeng.container.implementations.ContainerMAC;
|
||||
import appeng.tile.crafting.TileMolecularAssembler;
|
||||
|
||||
public class BlockMolecularAssembler extends AEBaseTileBlock<TileMolecularAssembler>
|
||||
{
|
||||
public class BlockMolecularAssembler extends AEBaseTileBlock<TileMolecularAssembler> {
|
||||
|
||||
public static final BooleanProperty POWERED = BooleanProperty.create( "powered" );
|
||||
public static final BooleanProperty POWERED = BooleanProperty.create("powered");
|
||||
|
||||
public BlockMolecularAssembler(Block.Properties props)
|
||||
{
|
||||
super( props );
|
||||
setDefaultState(getDefaultState().with(POWERED, false));
|
||||
}
|
||||
public BlockMolecularAssembler(Block.Properties props) {
|
||||
super(props);
|
||||
setDefaultState(getDefaultState().with(POWERED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(POWERED);
|
||||
}
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(POWERED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileMolecularAssembler te) {
|
||||
return currentState.with(POWERED, te.isPowered());
|
||||
}
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileMolecularAssembler te) {
|
||||
return currentState.with(POWERED, te.isPowered());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand, BlockRayTraceResult hit) {
|
||||
final TileMolecularAssembler tg = this.getTileEntity( w, pos );
|
||||
if( tg != null && !p.isCrouching() )
|
||||
{
|
||||
if (!tg.isRemote()) {
|
||||
ContainerOpener.openContainer(ContainerMAC.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand,
|
||||
BlockRayTraceResult hit) {
|
||||
final TileMolecularAssembler tg = this.getTileEntity(w, pos);
|
||||
if (tg != null && !p.isCrouching()) {
|
||||
if (!tg.isRemote()) {
|
||||
ContainerOpener.openContainer(ContainerMAC.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
return super.onBlockActivated(state, w, pos, p, hand, hit);
|
||||
}
|
||||
return super.onBlockActivated(state, w, pos, p, hand, hit);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,15 +18,12 @@
|
||||
|
||||
package appeng.block.crafting;
|
||||
|
||||
|
||||
import appeng.tile.crafting.TileCraftingTile;
|
||||
|
||||
public class CraftingUnitBlock extends AbstractCraftingUnitBlock<TileCraftingTile> {
|
||||
|
||||
public class CraftingUnitBlock extends AbstractCraftingUnitBlock<TileCraftingTile>
|
||||
{
|
||||
|
||||
public CraftingUnitBlock(Properties props, CraftingUnitType type) {
|
||||
super(props, type);
|
||||
}
|
||||
public CraftingUnitBlock(Properties props, CraftingUnitType type) {
|
||||
super(props, type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,32 +18,27 @@
|
||||
|
||||
package appeng.block.crafting;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.block.AEBaseBlockItem;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.block.AEBaseBlockItem;
|
||||
import appeng.core.AEConfig;
|
||||
|
||||
public class ItemCraftingStorage extends AEBaseBlockItem {
|
||||
|
||||
public class ItemCraftingStorage extends AEBaseBlockItem
|
||||
{
|
||||
public ItemCraftingStorage(Block id, Properties props) {
|
||||
super(id, props);
|
||||
}
|
||||
|
||||
public ItemCraftingStorage(Block id, Properties props) {
|
||||
super(id, props);
|
||||
}
|
||||
@Override
|
||||
public ItemStack getContainerItem(final ItemStack itemStack) {
|
||||
return AEApi.instance().definitions().blocks().craftingUnit().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem( final ItemStack itemStack )
|
||||
{
|
||||
return AEApi.instance().definitions().blocks().craftingUnit().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem( final ItemStack stack )
|
||||
{
|
||||
return AEConfig.instance().isFeatureEnabled( AEFeature.ENABLE_DISASSEMBLY_CRAFTING );
|
||||
}
|
||||
@Override
|
||||
public boolean hasContainerItem(final ItemStack stack) {
|
||||
return AEConfig.instance().isFeatureEnabled(AEFeature.ENABLE_DISASSEMBLY_CRAFTING);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,8 @@
|
||||
|
||||
package appeng.block.grindstone;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.api.implementations.tiles.ICrankable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.stats.AeStats;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.grindstone.TileCrank;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -47,137 +43,122 @@ import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import appeng.api.implementations.tiles.ICrankable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.stats.AeStats;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.grindstone.TileCrank;
|
||||
|
||||
public class BlockCrank extends AEBaseTileBlock<TileCrank> {
|
||||
|
||||
public class BlockCrank extends AEBaseTileBlock<TileCrank>
|
||||
{
|
||||
public BlockCrank(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
public BlockCrank(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
if (player instanceof FakePlayer || player == null) {
|
||||
this.dropCrank(w, pos);
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
|
||||
{
|
||||
if( player instanceof FakePlayer || player == null )
|
||||
{
|
||||
this.dropCrank( w, pos );
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
final TileCrank tile = this.getTileEntity(w, pos);
|
||||
if (tile != null) {
|
||||
if (tile.power()) {
|
||||
AeStats.TurnedCranks.addToPlayer(player, 1);
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
final TileCrank tile = this.getTileEntity( w, pos );
|
||||
if( tile != null )
|
||||
{
|
||||
if( tile.power() )
|
||||
{
|
||||
AeStats.TurnedCranks.addToPlayer( player, 1 );
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
private void dropCrank(final World world, final BlockPos pos) {
|
||||
world.destroyBlock(pos, true);
|
||||
world.notifyBlockUpdate(pos, this.getDefaultState(), world.getBlockState(pos), 3);
|
||||
}
|
||||
|
||||
private void dropCrank( final World world, final BlockPos pos )
|
||||
{
|
||||
world.destroyBlock( pos, true );
|
||||
world.notifyBlockUpdate( pos, this.getDefaultState(), world.getBlockState( pos ), 3 );
|
||||
}
|
||||
@Override
|
||||
public void onBlockPlacedBy(final World world, final BlockPos pos, final BlockState state,
|
||||
final LivingEntity placer, final ItemStack stack) {
|
||||
final AEBaseTile tile = this.getTileEntity(world, pos);
|
||||
if (tile != null) {
|
||||
final Direction mnt = this.findCrankable(world, pos);
|
||||
Direction forward = Direction.UP;
|
||||
if (mnt == Direction.UP || mnt == Direction.DOWN) {
|
||||
forward = Direction.SOUTH;
|
||||
}
|
||||
tile.setOrientation(forward, mnt.getOpposite());
|
||||
} else {
|
||||
this.dropCrank(world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy( final World world, final BlockPos pos, final BlockState state, final LivingEntity placer, final ItemStack stack )
|
||||
{
|
||||
final AEBaseTile tile = this.getTileEntity( world, pos );
|
||||
if( tile != null )
|
||||
{
|
||||
final Direction mnt = this.findCrankable( world, pos );
|
||||
Direction forward = Direction.UP;
|
||||
if( mnt == Direction.UP || mnt == Direction.DOWN )
|
||||
{
|
||||
forward = Direction.SOUTH;
|
||||
}
|
||||
tile.setOrientation( forward, mnt.getOpposite() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dropCrank( world, pos );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean isValidOrientation(final IWorld w, final BlockPos pos, final Direction forward, final Direction up) {
|
||||
final TileEntity te = w.getTileEntity(pos);
|
||||
return !(te instanceof TileCrank) || this.isCrankable(w, pos, up.getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidOrientation( final IWorld w, final BlockPos pos, final Direction forward, final Direction up )
|
||||
{
|
||||
final TileEntity te = w.getTileEntity( pos );
|
||||
return !( te instanceof TileCrank ) || this.isCrankable( w, pos, up.getOpposite() );
|
||||
}
|
||||
private Direction findCrankable(final IBlockReader world, final BlockPos pos) {
|
||||
for (final Direction dir : Direction.values()) {
|
||||
if (this.isCrankable(world, pos, dir)) {
|
||||
return dir;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Direction findCrankable( final IBlockReader world, final BlockPos pos )
|
||||
{
|
||||
for( final Direction dir : Direction.values() )
|
||||
{
|
||||
if( this.isCrankable( world, pos, dir ) )
|
||||
{
|
||||
return dir;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private boolean isCrankable(final IBlockReader world, final BlockPos pos, final Direction offset) {
|
||||
final BlockPos o = pos.offset(offset);
|
||||
final TileEntity te = world.getTileEntity(o);
|
||||
|
||||
private boolean isCrankable( final IBlockReader world, final BlockPos pos, final Direction offset )
|
||||
{
|
||||
final BlockPos o = pos.offset( offset );
|
||||
final TileEntity te = world.getTileEntity( o );
|
||||
return te instanceof ICrankable && ((ICrankable) te).canCrankAttach(offset.getOpposite());
|
||||
}
|
||||
|
||||
return te instanceof ICrankable && ( (ICrankable) te ).canCrankAttach( offset.getOpposite() );
|
||||
}
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.ENTITYBLOCK_ANIMATED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state )
|
||||
{
|
||||
return BlockRenderType.ENTITYBLOCK_ANIMATED;
|
||||
}
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
final AEBaseTile tile = this.getTileEntity(world, pos);
|
||||
if (tile != null) {
|
||||
if (!this.isCrankable(world, pos, tile.getUp().getOpposite())) {
|
||||
this.dropCrank(world, pos);
|
||||
}
|
||||
} else {
|
||||
this.dropCrank(world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
|
||||
final AEBaseTile tile = this.getTileEntity( world, pos );
|
||||
if( tile != null )
|
||||
{
|
||||
if( !this.isCrankable( world, pos, tile.getUp().getOpposite() ) )
|
||||
{
|
||||
this.dropCrank( world, pos );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dropCrank( world, pos );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos) {
|
||||
return this.findCrankable(w, pos) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos)
|
||||
{
|
||||
return this.findCrankable( w, pos ) != null;
|
||||
}
|
||||
private Direction getUp(IBlockReader world, BlockPos pos) {
|
||||
TileCrank crank = getTileEntity(world, pos);
|
||||
return crank != null ? crank.getUp() : null;
|
||||
}
|
||||
|
||||
private Direction getUp(IBlockReader world, BlockPos pos) {
|
||||
TileCrank crank = getTileEntity(world, pos);
|
||||
return crank != null ? crank.getUp() : null;
|
||||
}
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) {
|
||||
Direction up = getUp(world, pos);
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) {
|
||||
Direction up = getUp(world, pos);
|
||||
if (up == null) {
|
||||
return VoxelShapes.empty();
|
||||
} else {
|
||||
// FIXME: Cache per direction, and build it 'precise', not just from AABB
|
||||
final double xOff = -0.15 * up.getXOffset();
|
||||
final double yOff = -0.15 * up.getYOffset();
|
||||
final double zOff = -0.15 * up.getZOffset();
|
||||
return VoxelShapes.create(
|
||||
new AxisAlignedBB(xOff + 0.15, yOff + 0.15, zOff + 0.15, xOff + 0.85, yOff + 0.85, zOff + 0.85));
|
||||
}
|
||||
|
||||
if (up == null) {
|
||||
return VoxelShapes.empty();
|
||||
} else {
|
||||
// FIXME: Cache per direction, and build it 'precise', not just from AABB
|
||||
final double xOff = -0.15 * up.getXOffset();
|
||||
final double yOff = -0.15 * up.getYOffset();
|
||||
final double zOff = -0.15 * up.getZOffset();
|
||||
return VoxelShapes.create(new AxisAlignedBB(xOff + 0.15, yOff + 0.15, zOff + 0.15, xOff + 0.85, yOff + 0.85, zOff + 0.85));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,8 @@
|
||||
|
||||
package appeng.block.grindstone;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerGrinder;
|
||||
import appeng.tile.grindstone.TileGrinder;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -33,27 +29,29 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerGrinder;
|
||||
import appeng.tile.grindstone.TileGrinder;
|
||||
|
||||
public class BlockGrinder extends AEBaseTileBlock<TileGrinder> {
|
||||
|
||||
public class BlockGrinder extends AEBaseTileBlock<TileGrinder>
|
||||
{
|
||||
public BlockGrinder(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
public BlockGrinder(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
|
||||
{
|
||||
final TileGrinder tg = this.getTileEntity( w, pos );
|
||||
if( tg != null && !p.isCrouching() )
|
||||
{
|
||||
if (p instanceof ServerPlayerEntity) {
|
||||
ContainerOpener.openContainer(ContainerGrinder.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
final TileGrinder tg = this.getTileEntity(w, pos);
|
||||
if (tg != null && !p.isCrouching()) {
|
||||
if (p instanceof ServerPlayerEntity) {
|
||||
ContainerOpener.openContainer(ContainerGrinder.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,8 @@
|
||||
|
||||
package appeng.block.misc;
|
||||
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.implementations.ContainerCellWorkbench;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -33,36 +30,31 @@ import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.implementations.ContainerCellWorkbench;
|
||||
import appeng.tile.misc.TileCellWorkbench;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockCellWorkbench extends AEBaseTileBlock<TileCellWorkbench> {
|
||||
|
||||
public class BlockCellWorkbench extends AEBaseTileBlock<TileCellWorkbench>
|
||||
{
|
||||
public BlockCellWorkbench() {
|
||||
super(defaultProps(Material.IRON));
|
||||
}
|
||||
|
||||
public BlockCellWorkbench()
|
||||
{
|
||||
super( defaultProps(Material.IRON) );
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
if (p.isCrouching()) {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
|
||||
{
|
||||
if( p.isCrouching() )
|
||||
{
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
final TileCellWorkbench tg = this.getTileEntity( w, pos );
|
||||
if( tg != null )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
ContainerCellWorkbench.open(p, ContainerLocator.forTileEntity(tg));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
final TileCellWorkbench tg = this.getTileEntity(w, pos);
|
||||
if (tg != null) {
|
||||
if (Platform.isServer()) {
|
||||
ContainerCellWorkbench.open(p, ContainerLocator.forTileEntity(tg));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,18 +18,14 @@
|
||||
|
||||
package appeng.block.misc;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.util.AEAxisAlignedBB;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.effects.ChargedOreFX;
|
||||
import appeng.client.render.effects.LightningFX;
|
||||
import appeng.client.render.renderable.ItemRenderable;
|
||||
import appeng.client.render.tesr.ModularTESR;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.misc.TileCharger;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -52,156 +48,145 @@ import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.util.AEAxisAlignedBB;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.effects.ChargedOreFX;
|
||||
import appeng.client.render.effects.LightningFX;
|
||||
import appeng.client.render.renderable.ItemRenderable;
|
||||
import appeng.client.render.tesr.ModularTESR;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.misc.TileCharger;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockCharger extends AEBaseTileBlock<TileCharger> {
|
||||
|
||||
public class BlockCharger extends AEBaseTileBlock<TileCharger>
|
||||
{
|
||||
public BlockCharger() {
|
||||
super(defaultProps(Material.IRON).notSolid());
|
||||
|
||||
public BlockCharger()
|
||||
{
|
||||
super( defaultProps(Material.IRON).notSolid() );
|
||||
this.setFullSize(this.setOpaque(false));
|
||||
}
|
||||
|
||||
this.setFullSize( this.setOpaque( false ) );
|
||||
}
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 2; // FIXME Double check this (esp. value range)
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 2; // FIXME Double check this (esp. value range)
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
if (player.isCrouching()) {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
|
||||
{
|
||||
if( player.isCrouching() )
|
||||
{
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
if (Platform.isServer()) {
|
||||
final TileCharger tc = this.getTileEntity(w, pos);
|
||||
if (tc != null) {
|
||||
tc.activate(player);
|
||||
}
|
||||
}
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
final TileCharger tc = this.getTileEntity( w, pos );
|
||||
if( tc != null )
|
||||
{
|
||||
tc.activate( player );
|
||||
}
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void animateTick(final BlockState state, final World w, final BlockPos pos, final Random r) {
|
||||
if (!AEConfig.instance().isEnableEffects()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void animateTick( final BlockState state, final World w, final BlockPos pos, final Random r )
|
||||
{
|
||||
if( !AEConfig.instance().isEnableEffects() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (r.nextFloat() < 0.98) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( r.nextFloat() < 0.98 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final TileCharger tile = this.getTileEntity(w, pos);
|
||||
if (tile != null) {
|
||||
if (AEApi.instance().definitions().materials().certusQuartzCrystalCharged()
|
||||
.isSameAs(tile.getInternalInventory().getStackInSlot(0))) {
|
||||
final double xOff = 0.0;
|
||||
final double yOff = 0.0;
|
||||
final double zOff = 0.0;
|
||||
|
||||
final TileCharger tile = this.getTileEntity( w, pos );
|
||||
if(tile != null)
|
||||
{
|
||||
if( AEApi.instance().definitions().materials().certusQuartzCrystalCharged().isSameAs( tile.getInternalInventory().getStackInSlot( 0 ) ) )
|
||||
{
|
||||
final double xOff = 0.0;
|
||||
final double yOff = 0.0;
|
||||
final double zOff = 0.0;
|
||||
for (int bolts = 0; bolts < 3; bolts++) {
|
||||
if (AppEng.proxy.shouldAddParticles(r)) {
|
||||
Minecraft.getInstance().particles.addParticle(LightningFX.TYPE, xOff + 0.5 + pos.getX(),
|
||||
yOff + 0.5 + pos.getY(), zOff + 0.5 + pos.getZ(), 0.0, 0.0, 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for( int bolts = 0; bolts < 3; bolts++ )
|
||||
{
|
||||
if( AppEng.proxy.shouldAddParticles( r ) )
|
||||
{
|
||||
Minecraft.getInstance().particles.addParticle(LightningFX.TYPE, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(), zOff + 0.5 + pos
|
||||
.getZ(), 0.0, 0.0, 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
|
||||
final TileCharger tile = this.getTileEntity(w, pos);
|
||||
if (tile != null) {
|
||||
final double twoPixels = 2.0 / 16.0;
|
||||
final Direction up = tile.getUp();
|
||||
final Direction forward = tile.getForward();
|
||||
final AEAxisAlignedBB bb = new AEAxisAlignedBB(twoPixels, twoPixels, twoPixels, 1.0 - twoPixels,
|
||||
1.0 - twoPixels, 1.0 - twoPixels);
|
||||
|
||||
final TileCharger tile = this.getTileEntity( w, pos );
|
||||
if( tile != null )
|
||||
{
|
||||
final double twoPixels = 2.0 / 16.0;
|
||||
final Direction up = tile.getUp();
|
||||
final Direction forward = tile.getForward();
|
||||
final AEAxisAlignedBB bb = new AEAxisAlignedBB( twoPixels, twoPixels, twoPixels, 1.0 - twoPixels, 1.0 - twoPixels, 1.0 - twoPixels );
|
||||
if (up.getXOffset() != 0) {
|
||||
bb.minX = 0;
|
||||
bb.maxX = 1;
|
||||
}
|
||||
if (up.getYOffset() != 0) {
|
||||
bb.minY = 0;
|
||||
bb.maxY = 1;
|
||||
}
|
||||
if (up.getZOffset() != 0) {
|
||||
bb.minZ = 0;
|
||||
bb.maxZ = 1;
|
||||
}
|
||||
|
||||
if( up.getXOffset() != 0 )
|
||||
{
|
||||
bb.minX = 0;
|
||||
bb.maxX = 1;
|
||||
}
|
||||
if( up.getYOffset() != 0 )
|
||||
{
|
||||
bb.minY = 0;
|
||||
bb.maxY = 1;
|
||||
}
|
||||
if( up.getZOffset() != 0 )
|
||||
{
|
||||
bb.minZ = 0;
|
||||
bb.maxZ = 1;
|
||||
}
|
||||
switch (forward) {
|
||||
case DOWN:
|
||||
bb.maxY = 1;
|
||||
break;
|
||||
case UP:
|
||||
bb.minY = 0;
|
||||
break;
|
||||
case NORTH:
|
||||
bb.maxZ = 1;
|
||||
break;
|
||||
case SOUTH:
|
||||
bb.minZ = 0;
|
||||
break;
|
||||
case EAST:
|
||||
bb.minX = 0;
|
||||
break;
|
||||
case WEST:
|
||||
bb.maxX = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch( forward )
|
||||
{
|
||||
case DOWN:
|
||||
bb.maxY = 1;
|
||||
break;
|
||||
case UP:
|
||||
bb.minY = 0;
|
||||
break;
|
||||
case NORTH:
|
||||
bb.maxZ = 1;
|
||||
break;
|
||||
case SOUTH:
|
||||
bb.minZ = 0;
|
||||
break;
|
||||
case EAST:
|
||||
bb.minX = 0;
|
||||
break;
|
||||
case WEST:
|
||||
bb.maxX = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return VoxelShapes.create(bb.getBoundingBox());
|
||||
}
|
||||
return VoxelShapes.create(new AxisAlignedBB(0.0, 0, 0.0, 1.0, 1.0, 1.0));
|
||||
}
|
||||
|
||||
return VoxelShapes.create(bb.getBoundingBox());
|
||||
}
|
||||
return VoxelShapes.create( new AxisAlignedBB( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) );
|
||||
}
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos,
|
||||
ISelectionContext context) {
|
||||
return VoxelShapes.create(new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 1.0, 1.0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
return VoxelShapes.create( new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
|
||||
}
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static Function<TileEntityRendererDispatcher, TileEntityRenderer<TileCharger>> createTesr() {
|
||||
return dispatcher -> new ModularTESR<>(dispatcher, new ItemRenderable<>(BlockCharger::getRenderedItem));
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public static Function<TileEntityRendererDispatcher, TileEntityRenderer<TileCharger>> createTesr()
|
||||
{
|
||||
return dispatcher -> new ModularTESR<>( dispatcher, new ItemRenderable<>( BlockCharger::getRenderedItem ) );
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private static Pair<ItemStack, TransformationMatrix> getRenderedItem(TileCharger tile )
|
||||
{
|
||||
TransformationMatrix transform = new TransformationMatrix(new Vector3f( 0.5f, 0.375f, 0.5f ), null, null, null);
|
||||
return new ImmutablePair<>( tile.getInternalInventory().getStackInSlot( 0 ), transform );
|
||||
}
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static Pair<ItemStack, TransformationMatrix> getRenderedItem(TileCharger tile) {
|
||||
TransformationMatrix transform = new TransformationMatrix(new Vector3f(0.5f, 0.375f, 0.5f), null, null, null);
|
||||
return new ImmutablePair<>(tile.getInternalInventory().getStackInSlot(0), transform);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,13 +18,8 @@
|
||||
|
||||
package appeng.block.misc;
|
||||
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerCondenser;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -36,37 +31,35 @@ import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerCondenser;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import appeng.tile.misc.TileCondenser;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockCondenser extends AEBaseTileBlock<TileCondenser> {
|
||||
|
||||
public class BlockCondenser extends AEBaseTileBlock<TileCondenser>
|
||||
{
|
||||
public BlockCondenser() {
|
||||
super(defaultProps(Material.IRON));
|
||||
}
|
||||
|
||||
public BlockCondenser()
|
||||
{
|
||||
super( defaultProps(Material.IRON) );
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
if (player.isCrouching()) {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
|
||||
{
|
||||
if( player.isCrouching() )
|
||||
{
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
if (Platform.isServer()) {
|
||||
final TileCondenser tc = this.getTileEntity(w, pos);
|
||||
if (tc != null && !player.isCrouching()) {
|
||||
ContainerOpener.openContainer(ContainerCondenser.TYPE, player,
|
||||
ContainerLocator.forTileEntitySide(tc, hit.getFace()));
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
final TileCondenser tc = this.getTileEntity( w, pos );
|
||||
if( tc != null && !player.isCrouching() )
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerCondenser.TYPE, player, ContainerLocator.forTileEntitySide(tc, hit.getFace()));
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,8 @@
|
||||
|
||||
package appeng.block.misc;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerInscriber;
|
||||
import appeng.container.implementations.ContainerInterface;
|
||||
import appeng.fluids.container.ContainerFluidLevelEmitter;
|
||||
import appeng.tile.misc.TileInscriber;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -36,7 +30,13 @@ import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerInscriber;
|
||||
import appeng.container.implementations.ContainerInterface;
|
||||
import appeng.fluids.container.ContainerFluidLevelEmitter;
|
||||
import appeng.tile.misc.TileInscriber;
|
||||
|
||||
public class BlockInscriber extends AEBaseTileBlock<TileInscriber> {
|
||||
|
||||
@@ -46,17 +46,20 @@ public class BlockInscriber extends AEBaseTileBlock<TileInscriber> {
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 2; // FIXME validate this. a) possibly not required because of getShape b) value range. was 2 in 1.10
|
||||
return 2; // FIXME validate this. a) possibly not required because of getShape b) value
|
||||
// range. was 2 in 1.10
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
if (!p.isCrouching()) {
|
||||
final TileInscriber tg = this.getTileEntity(w, pos);
|
||||
if (tg != null) {
|
||||
if (!tg.isRemote()) {
|
||||
ContainerOpener.openContainer(ContainerInscriber.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
if (!tg.isRemote()) {
|
||||
ContainerOpener.openContainer(ContainerInscriber.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,8 @@
|
||||
|
||||
package appeng.block.misc;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import appeng.container.implementations.ContainerInterface;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -42,62 +35,61 @@ import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import appeng.container.implementations.ContainerInterface;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockInterface extends AEBaseTileBlock<TileInterface> {
|
||||
|
||||
public class BlockInterface extends AEBaseTileBlock<TileInterface>
|
||||
{
|
||||
private static final BooleanProperty OMNIDIRECTIONAL = BooleanProperty.create("omnidirectional");
|
||||
|
||||
private static final BooleanProperty OMNIDIRECTIONAL = BooleanProperty.create( "omnidirectional" );
|
||||
public BlockInterface() {
|
||||
super(defaultProps(Material.IRON));
|
||||
}
|
||||
|
||||
public BlockInterface()
|
||||
{
|
||||
super( defaultProps(Material.IRON) );
|
||||
}
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(OMNIDIRECTIONAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(OMNIDIRECTIONAL);
|
||||
}
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileInterface te) {
|
||||
return currentState.with(OMNIDIRECTIONAL, te.isOmniDirectional());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileInterface te) {
|
||||
return currentState.with(OMNIDIRECTIONAL, te.isOmniDirectional());
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
if (p.isCrouching()) {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
|
||||
{
|
||||
if( p.isCrouching() )
|
||||
{
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
final TileInterface tg = this.getTileEntity(w, pos);
|
||||
if (tg != null) {
|
||||
if (Platform.isServer()) {
|
||||
ContainerOpener.openContainer(ContainerInterface.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
final TileInterface tg = this.getTileEntity( w, pos );
|
||||
if( tg != null )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerInterface.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
@Override
|
||||
protected boolean hasCustomRotation() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasCustomRotation()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customRotateBlock( final IOrientable rotatable, final Direction axis )
|
||||
{
|
||||
if( rotatable instanceof TileInterface )
|
||||
{
|
||||
( (TileInterface) rotatable ).setSide( axis );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void customRotateBlock(final IOrientable rotatable, final Direction axis) {
|
||||
if (rotatable instanceof TileInterface) {
|
||||
((TileInterface) rotatable).setSide(axis);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,8 @@
|
||||
|
||||
package appeng.block.misc;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.helpers.MetaRotation;
|
||||
import appeng.tile.misc.TileLightDetector;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -41,122 +37,114 @@ import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Random;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.helpers.MetaRotation;
|
||||
import appeng.tile.misc.TileLightDetector;
|
||||
|
||||
public class BlockLightDetector extends AEBaseTileBlock<TileLightDetector> implements IOrientableBlock {
|
||||
|
||||
public class BlockLightDetector extends AEBaseTileBlock<TileLightDetector> implements IOrientableBlock
|
||||
{
|
||||
// Used to alternate between two variants of the fixture on adjacent blocks
|
||||
public static final BooleanProperty ODD = BooleanProperty.create("odd");
|
||||
|
||||
// Used to alternate between two variants of the fixture on adjacent blocks
|
||||
public static final BooleanProperty ODD = BooleanProperty.create( "odd" );
|
||||
public BlockLightDetector() {
|
||||
super(defaultProps(Material.MISCELLANEOUS).notSolid());
|
||||
|
||||
public BlockLightDetector()
|
||||
{
|
||||
super( defaultProps(Material.MISCELLANEOUS).notSolid() );
|
||||
this.setDefaultState(this.getDefaultState().with(BlockStateProperties.FACING, Direction.UP).with(ODD, false));
|
||||
}
|
||||
|
||||
this.setDefaultState( this.getDefaultState().with(BlockStateProperties.FACING, Direction.UP ).with( ODD, false ) );
|
||||
}
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(BlockStateProperties.FACING);
|
||||
builder.add(ODD);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(BlockStateProperties.FACING);
|
||||
builder.add(ODD);
|
||||
}
|
||||
@Override
|
||||
public int getWeakPower(final BlockState state, final IBlockReader w, final BlockPos pos, final Direction side) {
|
||||
if (w instanceof World && this.getTileEntity(w, pos).isReady()) {
|
||||
// FIXME: This is ... uhm... fishy
|
||||
return ((World) w).getLight(pos) - 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWeakPower( final BlockState state, final IBlockReader w, final BlockPos pos, final Direction side )
|
||||
{
|
||||
if( w instanceof World && this.getTileEntity( w, pos ).isReady() )
|
||||
{
|
||||
// FIXME: This is ... uhm... fishy
|
||||
return ( (World) w ).getLight( pos ) - 6;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) {
|
||||
super.onNeighborChange(state, world, pos, neighbor);
|
||||
|
||||
@Override
|
||||
public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) {
|
||||
super.onNeighborChange( state, world, pos, neighbor );
|
||||
final TileLightDetector tld = this.getTileEntity(world, pos);
|
||||
if (tld != null) {
|
||||
tld.updateLight();
|
||||
}
|
||||
}
|
||||
|
||||
final TileLightDetector tld = this.getTileEntity( world, pos );
|
||||
if( tld != null )
|
||||
{
|
||||
tld.updateLight();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void animateTick(final BlockState state, final World worldIn, final BlockPos pos, final Random rand) {
|
||||
// cancel out lightning
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animateTick( final BlockState state, final World worldIn, final BlockPos pos, final Random rand )
|
||||
{
|
||||
// cancel out lightning
|
||||
}
|
||||
@Override
|
||||
public boolean isValidOrientation(final IWorld w, final BlockPos pos, final Direction forward, final Direction up) {
|
||||
return this.canPlaceAt(w, pos, up.getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidOrientation(final IWorld w, final BlockPos pos, final Direction forward, final Direction up )
|
||||
{
|
||||
return this.canPlaceAt( w, pos, up.getOpposite() );
|
||||
}
|
||||
private boolean canPlaceAt(final IBlockReader w, final BlockPos pos, final Direction dir) {
|
||||
final BlockPos test = pos.offset(dir);
|
||||
BlockState blockstate = w.getBlockState(test);
|
||||
return blockstate.isSolidSide(w, test, dir.getOpposite());
|
||||
}
|
||||
|
||||
private boolean canPlaceAt( final IBlockReader w, final BlockPos pos, final Direction dir )
|
||||
{
|
||||
final BlockPos test = pos.offset( dir );
|
||||
BlockState blockstate = w.getBlockState(test);
|
||||
return blockstate.isSolidSide(w, test, dir.getOpposite());
|
||||
}
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
|
||||
// FIXME: We should / rather MUST use state here because at startup, this gets
|
||||
// called without a world
|
||||
|
||||
// FIXME: We should / rather MUST use state here because at startup, this gets called without a world
|
||||
final Direction up = this.getOrientable(w, pos).getUp();
|
||||
final double xOff = -0.3 * up.getXOffset();
|
||||
final double yOff = -0.3 * up.getYOffset();
|
||||
final double zOff = -0.3 * up.getZOffset();
|
||||
return VoxelShapes
|
||||
.create(new AxisAlignedBB(xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7));
|
||||
}
|
||||
|
||||
final Direction up = this.getOrientable( w, pos ).getUp();
|
||||
final double xOff = -0.3 * up.getXOffset();
|
||||
final double yOff = -0.3 * up.getYOffset();
|
||||
final double zOff = -0.3 * up.getZOffset();
|
||||
return VoxelShapes.create( new AxisAlignedBB( xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7 ) );
|
||||
}
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos,
|
||||
ISelectionContext context) {
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
final Direction up = this.getOrientable(world, pos).getUp();
|
||||
if (!this.canPlaceAt(world, pos, up.getOpposite())) {
|
||||
this.dropTorch(world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving )
|
||||
{
|
||||
final Direction up = this.getOrientable( world, pos ).getUp();
|
||||
if( !this.canPlaceAt( world, pos, up.getOpposite() ) )
|
||||
{
|
||||
this.dropTorch( world, pos );
|
||||
}
|
||||
}
|
||||
private void dropTorch(final World w, final BlockPos pos) {
|
||||
final BlockState prev = w.getBlockState(pos);
|
||||
w.destroyBlock(pos, true);
|
||||
w.notifyBlockUpdate(pos, prev, w.getBlockState(pos), 3);
|
||||
}
|
||||
|
||||
private void dropTorch( final World w, final BlockPos pos )
|
||||
{
|
||||
final BlockState prev = w.getBlockState( pos );
|
||||
w.destroyBlock( pos, true );
|
||||
w.notifyBlockUpdate( pos, prev, w.getBlockState( pos ), 3 );
|
||||
}
|
||||
@Override
|
||||
public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos) {
|
||||
for (final Direction dir : Direction.values()) {
|
||||
if (this.canPlaceAt(w, pos, dir)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos)
|
||||
{
|
||||
for( final Direction dir : Direction.values() )
|
||||
{
|
||||
if( this.canPlaceAt( w, pos, dir ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOrientable getOrientable( final IBlockReader w, final BlockPos pos )
|
||||
{
|
||||
return new MetaRotation( w, pos, BlockStateProperties.FACING );
|
||||
}
|
||||
@Override
|
||||
public IOrientable getOrientable(final IBlockReader w, final BlockPos pos) {
|
||||
return new MetaRotation(w, pos, BlockStateProperties.FACING);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,14 +18,12 @@
|
||||
|
||||
package appeng.block.misc;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.effects.LightningFX;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.helpers.MetaRotation;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
@@ -49,170 +47,162 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.effects.LightningFX;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.helpers.MetaRotation;
|
||||
|
||||
public class BlockQuartzFixture extends AEBaseBlock implements IOrientableBlock {
|
||||
|
||||
public class BlockQuartzFixture extends AEBaseBlock implements IOrientableBlock
|
||||
{
|
||||
// Cache VoxelShapes for each facing
|
||||
private static final Map<Direction, VoxelShape> SHAPES;
|
||||
|
||||
// Cache VoxelShapes for each facing
|
||||
private static final Map<Direction, VoxelShape> SHAPES;
|
||||
static {
|
||||
SHAPES = new EnumMap<>(Direction.class);
|
||||
|
||||
static {
|
||||
SHAPES = new EnumMap<>(Direction.class);
|
||||
for (Direction facing : Direction.values()) {
|
||||
final double xOff = -0.3 * facing.getXOffset();
|
||||
final double yOff = -0.3 * facing.getYOffset();
|
||||
final double zOff = -0.3 * facing.getZOffset();
|
||||
VoxelShape shape = VoxelShapes
|
||||
.create(new AxisAlignedBB(xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7));
|
||||
SHAPES.put(facing, shape);
|
||||
}
|
||||
}
|
||||
|
||||
for (Direction facing : Direction.values()) {
|
||||
final double xOff = -0.3 * facing.getXOffset();
|
||||
final double yOff = -0.3 * facing.getYOffset();
|
||||
final double zOff = -0.3 * facing.getZOffset();
|
||||
VoxelShape shape = VoxelShapes.create(new AxisAlignedBB(xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7));
|
||||
SHAPES.put(facing, shape);
|
||||
}
|
||||
}
|
||||
// Cannot use the vanilla FACING property here because it excludes facing DOWN
|
||||
public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
||||
|
||||
// Cannot use the vanilla FACING property here because it excludes facing DOWN
|
||||
public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
||||
// Used to alternate between two variants of the fixture on adjacent blocks
|
||||
public static final BooleanProperty ODD = BooleanProperty.create("odd");
|
||||
|
||||
// Used to alternate between two variants of the fixture on adjacent blocks
|
||||
public static final BooleanProperty ODD = BooleanProperty.create( "odd" );
|
||||
public BlockQuartzFixture() {
|
||||
super(defaultProps(Material.MISCELLANEOUS).doesNotBlockMovement().hardnessAndResistance(0).lightValue(14)
|
||||
.sound(SoundType.GLASS));
|
||||
|
||||
public BlockQuartzFixture()
|
||||
{
|
||||
super(defaultProps(Material.MISCELLANEOUS).doesNotBlockMovement().hardnessAndResistance(0).lightValue(14).sound(SoundType.GLASS));
|
||||
this.setDefaultState(getDefaultState().with(FACING, Direction.UP).with(ODD, false));
|
||||
this.setFullSize(false);
|
||||
this.setOpaque(false);
|
||||
}
|
||||
|
||||
this.setDefaultState( getDefaultState().with( FACING, Direction.UP ).with( ODD, false ) );
|
||||
this.setFullSize( false );
|
||||
this.setOpaque( false );
|
||||
}
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(FACING, ODD);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(FACING, ODD);
|
||||
}
|
||||
// For reference, see WallTorchBlock
|
||||
@Nullable
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
BlockState blockstate = super.getStateForPlacement(context);
|
||||
BlockPos pos = context.getPos();
|
||||
|
||||
// For reference, see WallTorchBlock
|
||||
@Nullable
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
BlockState blockstate = super.getStateForPlacement(context);
|
||||
BlockPos pos = context.getPos();
|
||||
// Set the even/odd property
|
||||
boolean oddPlacement = ((pos.getX() + pos.getY() + pos.getZ()) % 2) != 0;
|
||||
blockstate = blockstate.with(ODD, oddPlacement);
|
||||
|
||||
// Set the even/odd property
|
||||
boolean oddPlacement = ( ( pos.getX() + pos.getY() + pos.getZ() ) % 2 ) != 0;
|
||||
blockstate = blockstate.with( ODD, oddPlacement );
|
||||
IWorldReader iworldreader = context.getWorld();
|
||||
Direction[] adirection = context.getNearestLookingDirections();
|
||||
|
||||
IWorldReader iworldreader = context.getWorld();
|
||||
Direction[] adirection = context.getNearestLookingDirections();
|
||||
for (Direction direction : adirection) {
|
||||
if (canPlaceAt(iworldreader, pos, direction)) {
|
||||
return blockstate.with(FACING, direction.getOpposite());
|
||||
}
|
||||
}
|
||||
|
||||
for(Direction direction : adirection) {
|
||||
if (canPlaceAt(iworldreader, pos, direction)) {
|
||||
return blockstate.with(FACING, direction.getOpposite());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
// Break the fixture if the block it is attached to is changed so that it could
|
||||
// no longer be placed
|
||||
@Override
|
||||
public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld worldIn,
|
||||
BlockPos pos, BlockPos facingPos) {
|
||||
Direction fixtureFacing = state.get(FACING);
|
||||
if (facing.getOpposite() == fixtureFacing && !canPlaceAt(worldIn, pos, facing)) {
|
||||
return Blocks.AIR.getDefaultState();
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
// Break the fixture if the block it is attached to is changed so that it could no longer be placed
|
||||
@Override
|
||||
public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld worldIn, BlockPos pos, BlockPos facingPos) {
|
||||
Direction fixtureFacing = state.get(FACING);
|
||||
if (facing.getOpposite() == fixtureFacing && !canPlaceAt(worldIn, pos, facing)) {
|
||||
return Blocks.AIR.getDefaultState();
|
||||
}
|
||||
return state;
|
||||
}
|
||||
@Override
|
||||
public boolean isValidOrientation(final IWorld w, final BlockPos pos, final Direction forward, final Direction up) {
|
||||
// FIXME: I think this entire method -> not required, but not sure... are quartz
|
||||
// fixtures rotateable???
|
||||
return this.canPlaceAt(w, pos, up.getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidOrientation( final IWorld w, final BlockPos pos, final Direction forward, final Direction up )
|
||||
{
|
||||
// FIXME: I think this entire method -> not required, but not sure... are quartz fixtures rotateable???
|
||||
return this.canPlaceAt( w, pos, up.getOpposite() );
|
||||
}
|
||||
private boolean canPlaceAt(final IWorldReader w, final BlockPos pos, final Direction dir) {
|
||||
final BlockPos test = pos.offset(dir);
|
||||
BlockState blockstate = w.getBlockState(test);
|
||||
return blockstate.isSolidSide(w, test, dir.getOpposite());
|
||||
}
|
||||
|
||||
private boolean canPlaceAt( final IWorldReader w, final BlockPos pos, final Direction dir )
|
||||
{
|
||||
final BlockPos test = pos.offset( dir );
|
||||
BlockState blockstate = w.getBlockState(test);
|
||||
return blockstate.isSolidSide(w, test, dir.getOpposite());
|
||||
}
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
Direction facing = state.get(FACING);
|
||||
return SHAPES.get(facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
Direction facing = state.get(FACING);
|
||||
return SHAPES.get(facing);
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void animateTick(final BlockState state, final World w, final BlockPos pos, final Random r) {
|
||||
if (!AEConfig.instance().isEnableEffects()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void animateTick( final BlockState state, final World w, final BlockPos pos, final Random r )
|
||||
{
|
||||
if( !AEConfig.instance().isEnableEffects() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (r.nextFloat() < 0.98) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( r.nextFloat() < 0.98 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final Direction up = this.getOrientable(w, pos).getUp();
|
||||
final double xOff = -0.3 * up.getXOffset();
|
||||
final double yOff = -0.3 * up.getYOffset();
|
||||
final double zOff = -0.3 * up.getZOffset();
|
||||
for (int bolts = 0; bolts < 3; bolts++) {
|
||||
if (AppEng.proxy.shouldAddParticles(r)) {
|
||||
w.addParticle(LightningFX.TYPE, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(),
|
||||
zOff + 0.5 + pos.getZ(), 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Direction up = this.getOrientable( w, pos ).getUp();
|
||||
final double xOff = -0.3 * up.getXOffset();
|
||||
final double yOff = -0.3 * up.getYOffset();
|
||||
final double zOff = -0.3 * up.getZOffset();
|
||||
for( int bolts = 0; bolts < 3; bolts++ )
|
||||
{
|
||||
if( AppEng.proxy.shouldAddParticles( r ) )
|
||||
{
|
||||
w.addParticle(LightningFX.TYPE, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(), zOff + 0.5 + pos.getZ(), 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
// FIXME: Replaced by the postPlaceupdate stuff above, but check item drops!
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
final Direction up = this.getOrientable(world, pos).getUp();
|
||||
if (!this.canPlaceAt(world, pos, up.getOpposite())) {
|
||||
this.dropTorch(world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: Replaced by the postPlaceupdate stuff above, but check item drops!
|
||||
@Override
|
||||
public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving )
|
||||
{
|
||||
final Direction up = this.getOrientable( world, pos ).getUp();
|
||||
if( !this.canPlaceAt( world, pos, up.getOpposite() ) )
|
||||
{
|
||||
this.dropTorch( world, pos );
|
||||
}
|
||||
}
|
||||
private void dropTorch(final World w, final BlockPos pos) {
|
||||
final BlockState prev = w.getBlockState(pos);
|
||||
w.destroyBlock(pos, true);
|
||||
w.notifyBlockUpdate(pos, prev, w.getBlockState(pos), 3);
|
||||
}
|
||||
|
||||
private void dropTorch( final World w, final BlockPos pos )
|
||||
{
|
||||
final BlockState prev = w.getBlockState( pos );
|
||||
w.destroyBlock( pos, true );
|
||||
w.notifyBlockUpdate( pos, prev, w.getBlockState( pos ), 3 );
|
||||
}
|
||||
@Override
|
||||
public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos) {
|
||||
for (final Direction dir : Direction.values()) {
|
||||
if (this.canPlaceAt(w, pos, dir)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos)
|
||||
{
|
||||
for( final Direction dir : Direction.values() )
|
||||
{
|
||||
if( this.canPlaceAt( w, pos, dir ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public IOrientable getOrientable(final IBlockReader w, final BlockPos pos) {
|
||||
return new MetaRotation(w, pos, FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOrientable getOrientable( final IBlockReader w, final BlockPos pos )
|
||||
{
|
||||
return new MetaRotation( w, pos, FACING );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaque()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isOpaque() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,14 +18,8 @@
|
||||
|
||||
package appeng.block.misc;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.effects.LightningFX;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.misc.TileQuartzGrowthAccelerator;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
@@ -40,110 +34,109 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import java.util.Random;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.effects.LightningFX;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.misc.TileQuartzGrowthAccelerator;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock<TileQuartzGrowthAccelerator>
|
||||
implements IOrientableBlock {
|
||||
|
||||
public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock<TileQuartzGrowthAccelerator> implements IOrientableBlock
|
||||
{
|
||||
private static final BooleanProperty POWERED = BooleanProperty.create("powered");
|
||||
|
||||
private static final BooleanProperty POWERED = BooleanProperty.create( "powered" );
|
||||
public BlockQuartzGrowthAccelerator() {
|
||||
super(defaultProps(Material.ROCK).sound(SoundType.METAL));
|
||||
this.setDefaultState(this.getDefaultState().with(POWERED, false));
|
||||
}
|
||||
|
||||
public BlockQuartzGrowthAccelerator()
|
||||
{
|
||||
super( defaultProps(Material.ROCK).sound(SoundType.METAL) );
|
||||
this.setDefaultState( this.getDefaultState().with( POWERED, false ) );
|
||||
}
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileQuartzGrowthAccelerator te) {
|
||||
return currentState.with(POWERED, te.isPowered());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileQuartzGrowthAccelerator te) {
|
||||
return currentState.with( POWERED, te.isPowered() );
|
||||
}
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(POWERED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(POWERED);
|
||||
}
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void animateTick(final BlockState state, final World w, final BlockPos pos, final Random r) {
|
||||
if (!AEConfig.instance().isEnableEffects()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
@Override
|
||||
public void animateTick( final BlockState state, final World w, final BlockPos pos, final Random r )
|
||||
{
|
||||
if( !AEConfig.instance().isEnableEffects() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final TileQuartzGrowthAccelerator cga = this.getTileEntity(w, pos);
|
||||
|
||||
final TileQuartzGrowthAccelerator cga = this.getTileEntity( w, pos );
|
||||
if (cga != null && cga.isPowered() && AppEng.proxy.shouldAddParticles(r)) {
|
||||
final double d0 = r.nextFloat() - 0.5F;
|
||||
final double d1 = r.nextFloat() - 0.5F;
|
||||
|
||||
if( cga != null && cga.isPowered() && AppEng.proxy.shouldAddParticles( r ) )
|
||||
{
|
||||
final double d0 = r.nextFloat() - 0.5F;
|
||||
final double d1 = r.nextFloat() - 0.5F;
|
||||
final Direction up = cga.getUp();
|
||||
final Direction forward = cga.getForward();
|
||||
final Direction west = Platform.crossProduct(forward, up);
|
||||
|
||||
final Direction up = cga.getUp();
|
||||
final Direction forward = cga.getForward();
|
||||
final Direction west = Platform.crossProduct( forward, up );
|
||||
double rx = 0.5 + pos.getX();
|
||||
double ry = 0.5 + pos.getY();
|
||||
double rz = 0.5 + pos.getZ();
|
||||
|
||||
double rx = 0.5 + pos.getX();
|
||||
double ry = 0.5 + pos.getY();
|
||||
double rz = 0.5 + pos.getZ();
|
||||
rx += up.getXOffset() * d0;
|
||||
ry += up.getYOffset() * d0;
|
||||
rz += up.getZOffset() * d0;
|
||||
|
||||
rx += up.getXOffset() * d0;
|
||||
ry += up.getYOffset() * d0;
|
||||
rz += up.getZOffset() * d0;
|
||||
final int x = pos.getX();
|
||||
final int y = pos.getY();
|
||||
final int z = pos.getZ();
|
||||
|
||||
final int x = pos.getX();
|
||||
final int y = pos.getY();
|
||||
final int z = pos.getZ();
|
||||
double dz = 0;
|
||||
double dx = 0;
|
||||
BlockPos pt = null;
|
||||
|
||||
double dz = 0;
|
||||
double dx = 0;
|
||||
BlockPos pt = null;
|
||||
switch (r.nextInt(4)) {
|
||||
case 0:
|
||||
dx = 0.6;
|
||||
dz = d1;
|
||||
pt = new BlockPos(x + west.getXOffset(), y + west.getYOffset(), z + west.getZOffset());
|
||||
|
||||
switch( r.nextInt( 4 ) )
|
||||
{
|
||||
case 0:
|
||||
dx = 0.6;
|
||||
dz = d1;
|
||||
pt = new BlockPos( x + west.getXOffset(), y + west.getYOffset(), z + west.getZOffset() );
|
||||
break;
|
||||
case 1:
|
||||
dx = d1;
|
||||
dz += 0.6;
|
||||
pt = new BlockPos(x + forward.getXOffset(), y + forward.getYOffset(), z + forward.getZOffset());
|
||||
|
||||
break;
|
||||
case 1:
|
||||
dx = d1;
|
||||
dz += 0.6;
|
||||
pt = new BlockPos( x + forward.getXOffset(), y + forward.getYOffset(), z + forward.getZOffset() );
|
||||
break;
|
||||
case 2:
|
||||
dx = d1;
|
||||
dz = -0.6;
|
||||
pt = new BlockPos(x - forward.getXOffset(), y - forward.getYOffset(), z - forward.getZOffset());
|
||||
|
||||
break;
|
||||
case 2:
|
||||
dx = d1;
|
||||
dz = -0.6;
|
||||
pt = new BlockPos( x - forward.getXOffset(), y - forward.getYOffset(), z - forward.getZOffset() );
|
||||
break;
|
||||
case 3:
|
||||
dx = -0.6;
|
||||
dz = d1;
|
||||
pt = new BlockPos(x - west.getXOffset(), y - west.getYOffset(), z - west.getZOffset());
|
||||
|
||||
break;
|
||||
case 3:
|
||||
dx = -0.6;
|
||||
dz = d1;
|
||||
pt = new BlockPos( x - west.getXOffset(), y - west.getYOffset(), z - west.getZOffset() );
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
if (!w.getBlockState(pt).getBlock().isAir(w.getBlockState(pt), w, pt)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( !w.getBlockState( pt ).getBlock().isAir( w.getBlockState( pt ), w, pt ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
rx += dx * west.getXOffset();
|
||||
ry += dx * west.getYOffset();
|
||||
rz += dx * west.getZOffset();
|
||||
|
||||
rx += dx * west.getXOffset();
|
||||
ry += dx * west.getYOffset();
|
||||
rz += dx * west.getZOffset();
|
||||
rx += dz * forward.getXOffset();
|
||||
ry += dz * forward.getYOffset();
|
||||
rz += dz * forward.getZOffset();
|
||||
|
||||
rx += dz * forward.getXOffset();
|
||||
ry += dz * forward.getYOffset();
|
||||
rz += dz * forward.getZOffset();
|
||||
|
||||
Minecraft.getInstance().particles.addParticle(LightningFX.TYPE, rx, ry, rz, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
Minecraft.getInstance().particles.addParticle(LightningFX.TYPE, rx, ry, rz, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,20 +18,14 @@
|
||||
|
||||
package appeng.block.misc;
|
||||
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerFormationPlane;
|
||||
import appeng.container.implementations.ContainerSecurityStation;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
@@ -43,53 +37,51 @@ import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerFormationPlane;
|
||||
import appeng.container.implementations.ContainerSecurityStation;
|
||||
import appeng.tile.misc.TileSecurityStation;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockSecurityStation extends AEBaseTileBlock<TileSecurityStation> {
|
||||
|
||||
public class BlockSecurityStation extends AEBaseTileBlock<TileSecurityStation>
|
||||
{
|
||||
private static final BooleanProperty POWERED = BooleanProperty.create("powered");
|
||||
|
||||
private static final BooleanProperty POWERED = BooleanProperty.create( "powered" );
|
||||
public BlockSecurityStation() {
|
||||
super(defaultProps(Material.IRON));
|
||||
|
||||
public BlockSecurityStation()
|
||||
{
|
||||
super( defaultProps(Material.IRON) );
|
||||
this.setDefaultState(this.getDefaultState().with(POWERED, false));
|
||||
}
|
||||
|
||||
this.setDefaultState( this.getDefaultState().with( POWERED, false ) );
|
||||
}
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(POWERED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(POWERED);
|
||||
}
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileSecurityStation te) {
|
||||
return currentState.with(POWERED, te.isActive());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileSecurityStation te) {
|
||||
return currentState.with( POWERED, te.isActive() );
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
if (p.isCrouching()) {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
|
||||
{
|
||||
if( p.isCrouching() )
|
||||
{
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
final TileSecurityStation tg = this.getTileEntity(w, pos);
|
||||
if (tg != null) {
|
||||
if (w.isRemote()) {
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
final TileSecurityStation tg = this.getTileEntity( w, pos );
|
||||
if( tg != null )
|
||||
{
|
||||
if( w.isRemote() )
|
||||
{
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
ContainerOpener.openContainer(ContainerSecurityStation.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
ContainerOpener.openContainer(ContainerSecurityStation.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
package appeng.block.misc;
|
||||
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -37,137 +35,124 @@ import net.minecraft.world.World;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.tile.misc.TileSkyCompass;
|
||||
|
||||
public class BlockSkyCompass extends AEBaseTileBlock<TileSkyCompass> {
|
||||
|
||||
public class BlockSkyCompass extends AEBaseTileBlock<TileSkyCompass>
|
||||
{
|
||||
public BlockSkyCompass(Block.Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
public BlockSkyCompass(Block.Properties props)
|
||||
{
|
||||
super(props);
|
||||
}
|
||||
@Override
|
||||
public boolean isValidOrientation(final IWorld w, final BlockPos pos, final Direction forward, final Direction up) {
|
||||
final TileSkyCompass sc = this.getTileEntity(w, pos);
|
||||
if (sc != null) {
|
||||
return false;
|
||||
}
|
||||
return this.canPlaceAt(w, pos, forward.getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidOrientation(final IWorld w, final BlockPos pos, final Direction forward, final Direction up )
|
||||
{
|
||||
final TileSkyCompass sc = this.getTileEntity( w, pos );
|
||||
if( sc != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return this.canPlaceAt( w, pos, forward.getOpposite() );
|
||||
}
|
||||
private boolean canPlaceAt(final IBlockReader w, final BlockPos pos, final Direction dir) {
|
||||
final BlockPos test = pos.offset(dir);
|
||||
BlockState blockstate = w.getBlockState(test);
|
||||
return blockstate.isSolidSide(w, test, dir.getOpposite());
|
||||
}
|
||||
|
||||
private boolean canPlaceAt( final IBlockReader w, final BlockPos pos, final Direction dir )
|
||||
{
|
||||
final BlockPos test = pos.offset( dir );
|
||||
BlockState blockstate = w.getBlockState(test);
|
||||
return blockstate.isSolidSide(w, test, dir.getOpposite());
|
||||
}
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
final TileSkyCompass sc = this.getTileEntity(world, pos);
|
||||
final Direction forward = sc.getForward();
|
||||
if (!this.canPlaceAt(world, pos, forward.getOpposite())) {
|
||||
this.dropTorch(world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving )
|
||||
{
|
||||
final TileSkyCompass sc = this.getTileEntity( world, pos );
|
||||
final Direction forward = sc.getForward();
|
||||
if( !this.canPlaceAt( world, pos, forward.getOpposite() ) )
|
||||
{
|
||||
this.dropTorch( world, pos );
|
||||
}
|
||||
}
|
||||
private void dropTorch(final World w, final BlockPos pos) {
|
||||
final BlockState prev = w.getBlockState(pos);
|
||||
w.destroyBlock(pos, true);
|
||||
w.notifyBlockUpdate(pos, prev, w.getBlockState(pos), 3);
|
||||
}
|
||||
|
||||
private void dropTorch( final World w, final BlockPos pos )
|
||||
{
|
||||
final BlockState prev = w.getBlockState( pos );
|
||||
w.destroyBlock( pos, true );
|
||||
w.notifyBlockUpdate( pos, prev, w.getBlockState( pos ), 3 );
|
||||
}
|
||||
@Override
|
||||
public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos) {
|
||||
for (final Direction dir : Direction.values()) {
|
||||
if (this.canPlaceAt(w, pos, dir)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos)
|
||||
{
|
||||
for( final Direction dir : Direction.values() )
|
||||
{
|
||||
if( this.canPlaceAt( w, pos, dir ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
|
||||
// TODO: This definitely needs to be memoized
|
||||
|
||||
// TODO: This definitely needs to be memoized
|
||||
final TileSkyCompass tile = this.getTileEntity(w, pos);
|
||||
if (tile != null) {
|
||||
final Direction forward = tile.getForward();
|
||||
|
||||
final TileSkyCompass tile = this.getTileEntity( w, pos );
|
||||
if( tile != null )
|
||||
{
|
||||
final Direction forward = tile.getForward();
|
||||
double minX = 0;
|
||||
double minY = 0;
|
||||
double minZ = 0;
|
||||
double maxX = 1;
|
||||
double maxY = 1;
|
||||
double maxZ = 1;
|
||||
|
||||
double minX = 0;
|
||||
double minY = 0;
|
||||
double minZ = 0;
|
||||
double maxX = 1;
|
||||
double maxY = 1;
|
||||
double maxZ = 1;
|
||||
switch (forward) {
|
||||
case DOWN:
|
||||
minZ = minX = 5.0 / 16.0;
|
||||
maxZ = maxX = 11.0 / 16.0;
|
||||
maxY = 1.0;
|
||||
minY = 14.0 / 16.0;
|
||||
break;
|
||||
case EAST:
|
||||
minZ = minY = 5.0 / 16.0;
|
||||
maxZ = maxY = 11.0 / 16.0;
|
||||
maxX = 2.0 / 16.0;
|
||||
minX = 0.0;
|
||||
break;
|
||||
case NORTH:
|
||||
minY = minX = 5.0 / 16.0;
|
||||
maxY = maxX = 11.0 / 16.0;
|
||||
maxZ = 1.0;
|
||||
minZ = 14.0 / 16.0;
|
||||
break;
|
||||
case SOUTH:
|
||||
minY = minX = 5.0 / 16.0;
|
||||
maxY = maxX = 11.0 / 16.0;
|
||||
maxZ = 2.0 / 16.0;
|
||||
minZ = 0.0;
|
||||
break;
|
||||
case UP:
|
||||
minZ = minX = 5.0 / 16.0;
|
||||
maxZ = maxX = 11.0 / 16.0;
|
||||
maxY = 2.0 / 16.0;
|
||||
minY = 0.0;
|
||||
break;
|
||||
case WEST:
|
||||
minZ = minY = 5.0 / 16.0;
|
||||
maxZ = maxY = 11.0 / 16.0;
|
||||
maxX = 1.0;
|
||||
minX = 14.0 / 16.0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch( forward )
|
||||
{
|
||||
case DOWN:
|
||||
minZ = minX = 5.0 / 16.0;
|
||||
maxZ = maxX = 11.0 / 16.0;
|
||||
maxY = 1.0;
|
||||
minY = 14.0 / 16.0;
|
||||
break;
|
||||
case EAST:
|
||||
minZ = minY = 5.0 / 16.0;
|
||||
maxZ = maxY = 11.0 / 16.0;
|
||||
maxX = 2.0 / 16.0;
|
||||
minX = 0.0;
|
||||
break;
|
||||
case NORTH:
|
||||
minY = minX = 5.0 / 16.0;
|
||||
maxY = maxX = 11.0 / 16.0;
|
||||
maxZ = 1.0;
|
||||
minZ = 14.0 / 16.0;
|
||||
break;
|
||||
case SOUTH:
|
||||
minY = minX = 5.0 / 16.0;
|
||||
maxY = maxX = 11.0 / 16.0;
|
||||
maxZ = 2.0 / 16.0;
|
||||
minZ = 0.0;
|
||||
break;
|
||||
case UP:
|
||||
minZ = minX = 5.0 / 16.0;
|
||||
maxZ = maxX = 11.0 / 16.0;
|
||||
maxY = 2.0 / 16.0;
|
||||
minY = 0.0;
|
||||
break;
|
||||
case WEST:
|
||||
minZ = minY = 5.0 / 16.0;
|
||||
maxZ = maxY = 11.0 / 16.0;
|
||||
maxX = 1.0;
|
||||
minX = 14.0 / 16.0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return VoxelShapes.create(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ));
|
||||
}
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
|
||||
return VoxelShapes.create(new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ) );
|
||||
}
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos,
|
||||
ISelectionContext context) {
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state )
|
||||
{
|
||||
return BlockRenderType.ENTITYBLOCK_ANIMATED;
|
||||
}
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.ENTITYBLOCK_ANIMATED;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,19 +18,18 @@
|
||||
|
||||
package appeng.block.misc;
|
||||
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.projectile.AbstractArrowEntity;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
@@ -44,124 +43,111 @@ import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.entity.EntityTinyTNTPrimed;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
public class BlockTinyTNT extends AEBaseBlock {
|
||||
|
||||
public class BlockTinyTNT extends AEBaseBlock
|
||||
{
|
||||
private static final VoxelShape SHAPE = VoxelShapes
|
||||
.create(new AxisAlignedBB(0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f));
|
||||
|
||||
private static final VoxelShape SHAPE = VoxelShapes.create(new AxisAlignedBB( 0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f ));
|
||||
public BlockTinyTNT(Block.Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
public BlockTinyTNT(Block.Properties props)
|
||||
{
|
||||
super(props);
|
||||
}
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 2; // FIXME: Validate that this is the correct value range
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 2; // FIXME: Validate that this is the correct value range
|
||||
}
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
if (heldItem != null && heldItem.getItem() == Items.FLINT_AND_STEEL) {
|
||||
this.startFuse(w, pos, player);
|
||||
w.removeBlock(pos, false);
|
||||
heldItem.damageItem(1, player, p -> {
|
||||
p.sendBreakAnimation(hand);
|
||||
}); // FIXME Check if onBroken is equivalent
|
||||
return ActionResultType.SUCCESS;
|
||||
} else {
|
||||
return super.onActivated(w, pos, player, hand, heldItem, hit);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
|
||||
{
|
||||
if( heldItem != null && heldItem.getItem() == Items.FLINT_AND_STEEL )
|
||||
{
|
||||
this.startFuse( w, pos, player );
|
||||
w.removeBlock(pos, false);
|
||||
heldItem.damageItem( 1, player, p -> {
|
||||
p.sendBreakAnimation(hand);
|
||||
} ); // FIXME Check if onBroken is equivalent
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.onActivated( w, pos, player, hand, heldItem, hit);
|
||||
}
|
||||
}
|
||||
public void startFuse(final World w, final BlockPos pos, final LivingEntity igniter) {
|
||||
if (!w.isRemote) {
|
||||
final EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed(w, pos.getX() + 0.5F,
|
||||
pos.getY() + 0.5F, pos.getZ() + 0.5F, igniter);
|
||||
w.addEntity(primedTinyTNTEntity);
|
||||
w.playSound(null, primedTinyTNTEntity.getPosX(), primedTinyTNTEntity.getPosY(),
|
||||
primedTinyTNTEntity.getPosZ(), SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void startFuse( final World w, final BlockPos pos, final LivingEntity igniter )
|
||||
{
|
||||
if( !w.isRemote )
|
||||
{
|
||||
final EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, igniter );
|
||||
w.addEntity( primedTinyTNTEntity );
|
||||
w.playSound( null, primedTinyTNTEntity.getPosX(), primedTinyTNTEntity.getPosY(), primedTinyTNTEntity.getPosZ(), SoundEvents.ENTITY_TNT_PRIMED,
|
||||
SoundCategory.BLOCKS, 1, 1 );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
if (world.getRedstonePowerFromNeighbors(pos) > 0) {
|
||||
this.startFuse(world, pos, null);
|
||||
world.removeBlock(pos, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving )
|
||||
{
|
||||
if( world.getRedstonePowerFromNeighbors( pos ) > 0 )
|
||||
{
|
||||
this.startFuse( world, pos, null );
|
||||
world.removeBlock(pos, false);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onBlockAdded(BlockState state, World w, BlockPos pos, BlockState oldState, boolean isMoving) {
|
||||
super.onBlockAdded(state, w, pos, oldState, isMoving);
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(BlockState state, World w, BlockPos pos, BlockState oldState, boolean isMoving) {
|
||||
super.onBlockAdded( state, w, pos, oldState, isMoving );
|
||||
if (w.getRedstonePowerFromNeighbors(pos) > 0) {
|
||||
this.startFuse(w, pos, null);
|
||||
w.removeBlock(pos, false);
|
||||
}
|
||||
}
|
||||
|
||||
if( w.getRedstonePowerFromNeighbors( pos ) > 0 )
|
||||
{
|
||||
this.startFuse( w, pos, null );
|
||||
w.removeBlock(pos, false);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onEntityWalk(final World w, final BlockPos pos, final Entity entity) {
|
||||
if (entity instanceof AbstractArrowEntity && !w.isRemote) {
|
||||
final AbstractArrowEntity entityarrow = (AbstractArrowEntity) entity;
|
||||
|
||||
@Override
|
||||
public void onEntityWalk( final World w, final BlockPos pos, final Entity entity )
|
||||
{
|
||||
if( entity instanceof AbstractArrowEntity && !w.isRemote )
|
||||
{
|
||||
final AbstractArrowEntity entityarrow = (AbstractArrowEntity) entity;
|
||||
if (entityarrow.isBurning()) {
|
||||
LivingEntity igniter = null;
|
||||
// Check if the shooter still exists
|
||||
if (w instanceof ServerWorld) {
|
||||
ServerWorld serverWorld = (ServerWorld) w;
|
||||
Entity shooter = serverWorld.getEntityByUuid(entityarrow.shootingEntity);
|
||||
if (shooter instanceof LivingEntity) {
|
||||
igniter = (LivingEntity) shooter;
|
||||
}
|
||||
|
||||
if( entityarrow.isBurning() )
|
||||
{
|
||||
LivingEntity igniter = null;
|
||||
// Check if the shooter still exists
|
||||
if (w instanceof ServerWorld) {
|
||||
ServerWorld serverWorld = (ServerWorld) w;
|
||||
Entity shooter = serverWorld.getEntityByUuid(entityarrow.shootingEntity);
|
||||
if (shooter instanceof LivingEntity) {
|
||||
igniter = (LivingEntity) shooter;
|
||||
}
|
||||
}
|
||||
this.startFuse(w, pos, igniter);
|
||||
w.removeBlock(pos, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
this.startFuse( w, pos, igniter );
|
||||
w.removeBlock(pos, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean canDropFromExplosion(final Explosion exp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDropFromExplosion( final Explosion exp )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExplosionDestroy( final World w, final BlockPos pos, final Explosion exp )
|
||||
{
|
||||
super.onExplosionDestroy( w, pos, exp );
|
||||
if( !w.isRemote )
|
||||
{
|
||||
final EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, exp
|
||||
.getExplosivePlacedBy() );
|
||||
primedTinyTNTEntity.setFuse( w.rand.nextInt( primedTinyTNTEntity.getFuse() / 4 ) + primedTinyTNTEntity.getFuse() / 8 );
|
||||
w.addEntity( primedTinyTNTEntity );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onExplosionDestroy(final World w, final BlockPos pos, final Explosion exp) {
|
||||
super.onExplosionDestroy(w, pos, exp);
|
||||
if (!w.isRemote) {
|
||||
final EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed(w, pos.getX() + 0.5F,
|
||||
pos.getY() + 0.5F, pos.getZ() + 0.5F, exp.getExplosivePlacedBy());
|
||||
primedTinyTNTEntity
|
||||
.setFuse(w.rand.nextInt(primedTinyTNTEntity.getFuse() / 4) + primedTinyTNTEntity.getFuse() / 8);
|
||||
w.addEntity(primedTinyTNTEntity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,16 +18,10 @@
|
||||
|
||||
package appeng.block.misc;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import appeng.container.implementations.ContainerVibrationChamber;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.misc.TileVibrationChamber;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -44,97 +38,95 @@ import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Random;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import appeng.container.implementations.ContainerVibrationChamber;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.misc.TileVibrationChamber;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public final class BlockVibrationChamber extends AEBaseTileBlock<TileVibrationChamber> {
|
||||
|
||||
public final class BlockVibrationChamber extends AEBaseTileBlock<TileVibrationChamber>
|
||||
{
|
||||
// Indicates that the vibration chamber is currently working
|
||||
private static final BooleanProperty ACTIVE = BooleanProperty.create("active");
|
||||
|
||||
// Indicates that the vibration chamber is currently working
|
||||
private static final BooleanProperty ACTIVE = BooleanProperty.create( "active" );
|
||||
public BlockVibrationChamber() {
|
||||
super(defaultProps(Material.IRON).hardnessAndResistance(4.2F));
|
||||
this.setDefaultState(this.getDefaultState().with(ACTIVE, false));
|
||||
}
|
||||
|
||||
public BlockVibrationChamber()
|
||||
{
|
||||
super( defaultProps(Material.IRON).hardnessAndResistance(4.2F) );
|
||||
this.setDefaultState( this.getDefaultState().with( ACTIVE, false ) );
|
||||
}
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileVibrationChamber te) {
|
||||
return currentState.with(ACTIVE, te.isOn);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileVibrationChamber te) {
|
||||
return currentState.with( ACTIVE, te.isOn );
|
||||
}
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(ACTIVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(ACTIVE);
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
if (player.isCrouching()) {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
|
||||
{
|
||||
if( player.isCrouching() )
|
||||
{
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
if (Platform.isServer()) {
|
||||
final TileVibrationChamber tc = this.getTileEntity(w, pos);
|
||||
if (tc != null && !player.isCrouching()) {
|
||||
ContainerOpener.openContainer(ContainerVibrationChamber.TYPE, player,
|
||||
ContainerLocator.forTileEntitySide(tc, hit.getFace()));
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
final TileVibrationChamber tc = this.getTileEntity( w, pos );
|
||||
if( tc != null && !player.isCrouching() )
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerVibrationChamber.TYPE, player, ContainerLocator.forTileEntitySide(tc, hit.getFace()));
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
@Override
|
||||
public void animateTick(final BlockState state, final World w, final BlockPos pos, final Random r) {
|
||||
if (!AEConfig.instance().isEnableEffects()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animateTick( final BlockState state, final World w, final BlockPos pos, final Random r )
|
||||
{
|
||||
if( !AEConfig.instance().isEnableEffects() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final AEBaseTile tile = this.getTileEntity(w, pos);
|
||||
if (tile instanceof TileVibrationChamber) {
|
||||
final TileVibrationChamber tc = (TileVibrationChamber) tile;
|
||||
if (tc.isOn) {
|
||||
double f1 = pos.getX() + 0.5F;
|
||||
double f2 = pos.getY() + 0.5F;
|
||||
double f3 = pos.getZ() + 0.5F;
|
||||
|
||||
final AEBaseTile tile = this.getTileEntity( w, pos );
|
||||
if( tile instanceof TileVibrationChamber )
|
||||
{
|
||||
final TileVibrationChamber tc = (TileVibrationChamber) tile;
|
||||
if( tc.isOn )
|
||||
{
|
||||
double f1 = pos.getX() + 0.5F;
|
||||
double f2 = pos.getY() + 0.5F;
|
||||
double f3 = pos.getZ() + 0.5F;
|
||||
final Direction forward = tc.getForward();
|
||||
final Direction up = tc.getUp();
|
||||
|
||||
final Direction forward = tc.getForward();
|
||||
final Direction up = tc.getUp();
|
||||
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();
|
||||
f1 += forward.getXOffset() * 0.6;
|
||||
f2 += forward.getYOffset() * 0.6;
|
||||
f3 += forward.getZOffset() * 0.6;
|
||||
|
||||
f1 += forward.getXOffset() * 0.6;
|
||||
f2 += forward.getYOffset() * 0.6;
|
||||
f3 += forward.getZOffset() * 0.6;
|
||||
final double ox = r.nextDouble();
|
||||
final double oy = r.nextDouble() * 0.2f;
|
||||
|
||||
final double ox = r.nextDouble();
|
||||
final double oy = r.nextDouble() * 0.2f;
|
||||
f1 += up.getXOffset() * (-0.3 + oy);
|
||||
f2 += up.getYOffset() * (-0.3 + oy);
|
||||
f3 += up.getZOffset() * (-0.3 + oy);
|
||||
|
||||
f1 += up.getXOffset() * ( -0.3 + oy );
|
||||
f2 += up.getYOffset() * ( -0.3 + oy );
|
||||
f3 += up.getZOffset() * ( -0.3 + oy );
|
||||
f1 += west_x * (0.3 * ox - 0.15);
|
||||
f2 += west_y * (0.3 * ox - 0.15);
|
||||
f3 += west_z * (0.3 * ox - 0.15);
|
||||
|
||||
f1 += west_x * ( 0.3 * ox - 0.15 );
|
||||
f2 += west_y * ( 0.3 * ox - 0.15 );
|
||||
f3 += west_z * ( 0.3 * ox - 0.15 );
|
||||
|
||||
w.addParticle(ParticleTypes.SMOKE, f1, f2, f3, 0.0D, 0.0D, 0.0D );
|
||||
w.addParticle(ParticleTypes.FLAME, f1, f2, f3, 0.0D, 0.0D, 0.0D );
|
||||
}
|
||||
}
|
||||
}
|
||||
w.addParticle(ParticleTypes.SMOKE, f1, f2, f3, 0.0D, 0.0D, 0.0D);
|
||||
w.addParticle(ParticleTypes.FLAME, f1, f2, f3, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,19 @@
|
||||
|
||||
package appeng.block.misc;
|
||||
|
||||
|
||||
import appeng.bootstrap.*;
|
||||
import appeng.tile.misc.TileInscriber;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.bootstrap.*;
|
||||
import appeng.client.render.tesr.InscriberTESR;
|
||||
import appeng.tile.misc.TileInscriber;
|
||||
|
||||
public class InscriberRendering extends TileEntityRenderingCustomizer<TileInscriber> {
|
||||
|
||||
public class InscriberRendering extends TileEntityRenderingCustomizer<TileInscriber>
|
||||
{
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
@Override
|
||||
public void customize(TileEntityRendering<TileInscriber> rendering) {
|
||||
rendering.tileEntityRenderer( InscriberTESR::new );
|
||||
}
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void customize(TileEntityRendering<TileInscriber> rendering) {
|
||||
rendering.tileEntityRenderer(InscriberTESR::new);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.block.misc;
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -30,16 +29,13 @@ import appeng.bootstrap.IItemRendering;
|
||||
import appeng.client.render.ColorableTileBlockColor;
|
||||
import appeng.client.render.StaticItemColor;
|
||||
|
||||
public class SecurityStationRendering extends BlockRenderingCustomizer {
|
||||
|
||||
public class SecurityStationRendering extends BlockRenderingCustomizer
|
||||
{
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||
{
|
||||
rendering.renderType(RenderType.getCutout());
|
||||
rendering.blockColor( ColorableTileBlockColor.INSTANCE );
|
||||
itemRendering.color( new StaticItemColor( AEColor.TRANSPARENT ) );
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||
rendering.renderType(RenderType.getCutout());
|
||||
rendering.blockColor(ColorableTileBlockColor.INSTANCE);
|
||||
itemRendering.color(new StaticItemColor(AEColor.TRANSPARENT));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,22 +18,19 @@
|
||||
|
||||
package appeng.block.misc;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.bootstrap.*;
|
||||
import appeng.client.render.tesr.SkyCompassTESR;
|
||||
import appeng.tile.misc.TileSkyCompass;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public class SkyCompassRendering extends TileEntityRenderingCustomizer<TileSkyCompass> {
|
||||
|
||||
|
||||
public class SkyCompassRendering extends TileEntityRenderingCustomizer<TileSkyCompass>
|
||||
{
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void customize(TileEntityRendering<TileSkyCompass> rendering) {
|
||||
rendering.tileEntityRenderer( SkyCompassTESR::new );
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void customize(TileEntityRendering<TileSkyCompass> rendering) {
|
||||
rendering.tileEntityRenderer(SkyCompassTESR::new);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,24 +18,12 @@
|
||||
|
||||
package appeng.block.networking;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.api.parts.IFacadeContainer;
|
||||
import appeng.api.parts.PartItemStack;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.cablebus.CableBusBakedModel;
|
||||
import appeng.client.render.cablebus.CableBusBreakingParticle;
|
||||
import appeng.client.render.cablebus.CableBusRenderState;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketClick;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.parts.ICableBusContainer;
|
||||
import appeng.parts.NullCableBusContainer;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.tile.networking.TileCableBusTESR;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -66,71 +54,83 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import appeng.api.parts.IFacadeContainer;
|
||||
import appeng.api.parts.PartItemStack;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.cablebus.CableBusBakedModel;
|
||||
import appeng.client.render.cablebus.CableBusBreakingParticle;
|
||||
import appeng.client.render.cablebus.CableBusRenderState;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketClick;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.parts.ICableBusContainer;
|
||||
import appeng.parts.NullCableBusContainer;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.tile.networking.TileCableBusTESR;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implements IAEFacade */ {
|
||||
|
||||
private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer();
|
||||
private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer();
|
||||
|
||||
public BlockCableBus() {
|
||||
super(defaultProps(AEGlassMaterial.INSTANCE).notSolid().noDrops());
|
||||
}
|
||||
public BlockCableBus() {
|
||||
super(defaultProps(AEGlassMaterial.INSTANCE).notSolid().noDrops());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animateTick(final BlockState state, final World worldIn, final BlockPos pos, final Random rand) {
|
||||
this.cb(worldIn, pos).animateTick(worldIn, pos, rand);
|
||||
}
|
||||
@Override
|
||||
public void animateTick(final BlockState state, final World worldIn, final BlockPos pos, final Random rand) {
|
||||
this.cb(worldIn, pos).animateTick(worldIn, pos, rand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChange(BlockState state, IWorldReader w, BlockPos pos, BlockPos neighbor) {
|
||||
this.cb(w, pos).onNeighborChanged(w, pos, neighbor);
|
||||
}
|
||||
@Override
|
||||
public void onNeighborChange(BlockState state, IWorldReader w, BlockPos pos, BlockPos neighbor) {
|
||||
this.cb(w, pos).onNeighborChanged(w, pos, neighbor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWeakPower(final BlockState state, final IBlockReader w, final BlockPos pos, final Direction side) {
|
||||
return this.cb(w, pos).isProvidingWeakPower(side.getOpposite()); // TODO:
|
||||
// IS
|
||||
// OPPOSITE!?
|
||||
}
|
||||
@Override
|
||||
public int getWeakPower(final BlockState state, final IBlockReader w, final BlockPos pos, final Direction side) {
|
||||
return this.cb(w, pos).isProvidingWeakPower(side.getOpposite()); // TODO:
|
||||
// IS
|
||||
// OPPOSITE!?
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvidePower(final BlockState state) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canProvidePower(final BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(BlockState state, World w, BlockPos pos, Entity entityIn) {
|
||||
this.cb(w, pos).onEntityCollision(entityIn);
|
||||
}
|
||||
@Override
|
||||
public void onEntityCollision(BlockState state, World w, BlockPos pos, Entity entityIn) {
|
||||
this.cb(w, pos).onEntityCollision(entityIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStrongPower(final BlockState state, final IBlockReader w, final BlockPos pos, final Direction side) {
|
||||
return this.cb(w, pos).isProvidingStrongPower(side.getOpposite()); // TODO:
|
||||
// IS
|
||||
// OPPOSITE!?
|
||||
}
|
||||
@Override
|
||||
public int getStrongPower(final BlockState state, final IBlockReader w, final BlockPos pos, final Direction side) {
|
||||
return this.cb(w, pos).isProvidingStrongPower(side.getOpposite()); // TODO:
|
||||
// IS
|
||||
// OPPOSITE!?
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(final BlockState state, final IBlockReader world, final BlockPos pos) {
|
||||
if (state.getBlock() != this) {
|
||||
return state.getBlock().getLightValue(state, world, pos);
|
||||
}
|
||||
return this.cb(world, pos).getLightValue();
|
||||
}
|
||||
@Override
|
||||
public int getLightValue(final BlockState state, final IBlockReader world, final BlockPos pos) {
|
||||
if (state.getBlock() != this) {
|
||||
return state.getBlock().getLightValue(state, world, pos);
|
||||
}
|
||||
return this.cb(world, pos).getLightValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLadder(BlockState state, IWorldReader world, BlockPos pos, LivingEntity entity) {
|
||||
return this.cb(world, pos).isLadder(entity);
|
||||
}
|
||||
@Override
|
||||
public boolean isLadder(BlockState state, IWorldReader world, BlockPos pos, LivingEntity entity) {
|
||||
return this.cb(world, pos).isLadder(entity);
|
||||
}
|
||||
|
||||
// FIXME: This is now derived from the collision shape, and cannot be decided programatically anymore.
|
||||
// FIXME: see Block.hasSolidSide. We need to remove isSolidOnSide
|
||||
@@ -140,213 +140,222 @@ public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implem
|
||||
// FIXME return this.cb( w, pos ).isSolidOnSide( side );
|
||||
// FIXME }
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) {
|
||||
// FIXME: Potentially check the fluid one too
|
||||
return super.isReplaceable(state, useContext) && this.cb(useContext.getWorld(), useContext.getPos()).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) {
|
||||
// FIXME: Potentially check the fluid one too
|
||||
return super.isReplaceable(state, useContext) && this.cb(useContext.getWorld(), useContext.getPos()).isEmpty();
|
||||
}
|
||||
@Override
|
||||
public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player,
|
||||
boolean willHarvest, IFluidState fluid) {
|
||||
if (player.abilities.isCreativeMode) {
|
||||
final AEBaseTile tile = this.getTileEntity(world, pos);
|
||||
if (tile != null) {
|
||||
tile.disableDrops();
|
||||
}
|
||||
// maybe ray trace?
|
||||
}
|
||||
return super.removedByPlayer(state, world, pos, player, willHarvest, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest, IFluidState fluid) {
|
||||
if (player.abilities.isCreativeMode) {
|
||||
final AEBaseTile tile = this.getTileEntity(world, pos);
|
||||
if (tile != null) {
|
||||
tile.disableDrops();
|
||||
}
|
||||
// maybe ray trace?
|
||||
}
|
||||
return super.removedByPlayer(state, world, pos, player, willHarvest, fluid);
|
||||
}
|
||||
@Override
|
||||
public boolean canConnectRedstone(final BlockState state, final IBlockReader w, final BlockPos pos,
|
||||
Direction side) {
|
||||
if (side == null) {
|
||||
side = Direction.UP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone(final BlockState state, final IBlockReader w, final BlockPos pos, Direction side) {
|
||||
if (side == null) {
|
||||
side = Direction.UP;
|
||||
}
|
||||
return this.cb(w, pos).canConnectRedstone(EnumSet.of(side));
|
||||
}
|
||||
|
||||
return this.cb(w, pos).canConnectRedstone(EnumSet.of(side));
|
||||
}
|
||||
@Override
|
||||
public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos,
|
||||
PlayerEntity player) {
|
||||
final Vec3d v3 = target.getHitVec().subtract(pos.getX(), pos.getY(), pos.getZ());
|
||||
final SelectedPart sp = this.cb(world, pos).selectPart(v3);
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, PlayerEntity player) {
|
||||
final Vec3d v3 = target.getHitVec().subtract(pos.getX(), pos.getY(), pos.getZ());
|
||||
final SelectedPart sp = this.cb(world, pos).selectPart(v3);
|
||||
if (sp.part != null) {
|
||||
return sp.part.getItemStack(PartItemStack.PICK);
|
||||
} else if (sp.facade != null) {
|
||||
return sp.facade.getItemStack();
|
||||
}
|
||||
|
||||
if (sp.part != null) {
|
||||
return sp.part.getItemStack(PartItemStack.PICK);
|
||||
} else if (sp.facade != null) {
|
||||
return sp.facade.getItemStack();
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public boolean addHitEffects(final BlockState state, final World world, final RayTraceResult target,
|
||||
final ParticleManager effectRenderer) {
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public boolean addHitEffects(final BlockState state, final World world, final RayTraceResult target, final ParticleManager effectRenderer) {
|
||||
// Half the particle rate. Since we're spawning concentrated on a specific spot,
|
||||
// our particle effect otherwise looks too strong
|
||||
if (Platform.getRandom().nextBoolean()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Half the particle rate. Since we're spawning concentrated on a specific spot,
|
||||
// our particle effect otherwise looks too strong
|
||||
if (Platform.getRandom().nextBoolean()) {
|
||||
return true;
|
||||
}
|
||||
if (target.getType() != Type.BLOCK) {
|
||||
return false;
|
||||
}
|
||||
BlockPos blockPos = new BlockPos(target.getHitVec().x, target.getHitVec().y, target.getHitVec().z);
|
||||
|
||||
if (target.getType() != Type.BLOCK) {
|
||||
return false;
|
||||
}
|
||||
BlockPos blockPos = new BlockPos(target.getHitVec().x, target.getHitVec().y, target.getHitVec().z);
|
||||
ICableBusContainer cb = this.cb(world, blockPos);
|
||||
|
||||
ICableBusContainer cb = this.cb(world, blockPos);
|
||||
// Our built-in model has the actual baked sprites we need
|
||||
IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher()
|
||||
.getModelForState(this.getDefaultState());
|
||||
|
||||
// Our built-in model has the actual baked sprites we need
|
||||
IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(this.getDefaultState());
|
||||
// We cannot add the effect if we don't have the model
|
||||
if (!(model instanceof CableBusBakedModel)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// We cannot add the effect if we don't have the model
|
||||
if (!(model instanceof CableBusBakedModel)) {
|
||||
return true;
|
||||
}
|
||||
CableBusBakedModel cableBusModel = (CableBusBakedModel) model;
|
||||
|
||||
CableBusBakedModel cableBusModel = (CableBusBakedModel) model;
|
||||
CableBusRenderState renderState = cb.getRenderState();
|
||||
|
||||
CableBusRenderState renderState = cb.getRenderState();
|
||||
// Spawn a particle for one of the particle textures
|
||||
TextureAtlasSprite texture = Platform.pickRandom(cableBusModel.getParticleTextures(renderState));
|
||||
if (texture != null) {
|
||||
double x = target.getHitVec().x;
|
||||
double y = target.getHitVec().y;
|
||||
double z = target.getHitVec().z;
|
||||
// FIXME: Check how this looks, probably like shit, maybe provide parts the
|
||||
// ability to supply particle textures???
|
||||
effectRenderer
|
||||
.addEffect(new CableBusBreakingParticle(world, x, y, z, texture).multiplyParticleScaleBy(0.8F));
|
||||
}
|
||||
|
||||
// Spawn a particle for one of the particle textures
|
||||
TextureAtlasSprite texture = Platform.pickRandom(cableBusModel.getParticleTextures(renderState));
|
||||
if (texture != null) {
|
||||
double x = target.getHitVec().x;
|
||||
double y = target.getHitVec().y;
|
||||
double z = target.getHitVec().z;
|
||||
// FIXME: Check how this looks, probably like shit, maybe provide parts the ability to supply particle textures???
|
||||
effectRenderer.addEffect(new CableBusBreakingParticle(world, x, y, z, texture)
|
||||
.multiplyParticleScaleBy(0.8F));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean addDestroyEffects(BlockState state, World world, BlockPos pos, ParticleManager effectRenderer) {
|
||||
ICableBusContainer cb = this.cb(world, pos);
|
||||
|
||||
@Override
|
||||
public boolean addDestroyEffects(BlockState state, World world, BlockPos pos, ParticleManager effectRenderer) {
|
||||
ICableBusContainer cb = this.cb(world, pos);
|
||||
// Our built-in model has the actual baked sprites we need
|
||||
IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher()
|
||||
.getModelForState(this.getDefaultState());
|
||||
|
||||
// Our built-in model has the actual baked sprites we need
|
||||
IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(this.getDefaultState());
|
||||
// We cannot add the effect if we dont have the model
|
||||
if (!(model instanceof CableBusBakedModel)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// We cannot add the effect if we dont have the model
|
||||
if (!(model instanceof CableBusBakedModel)) {
|
||||
return true;
|
||||
}
|
||||
CableBusBakedModel cableBusModel = (CableBusBakedModel) model;
|
||||
|
||||
CableBusBakedModel cableBusModel = (CableBusBakedModel) model;
|
||||
CableBusRenderState renderState = cb.getRenderState();
|
||||
|
||||
CableBusRenderState renderState = cb.getRenderState();
|
||||
List<TextureAtlasSprite> textures = cableBusModel.getParticleTextures(renderState);
|
||||
|
||||
List<TextureAtlasSprite> textures = cableBusModel.getParticleTextures(renderState);
|
||||
if (!textures.isEmpty()) {
|
||||
// Shamelessly inspired by ParticleManager.addBlockDestroyEffects
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
for (int k = 0; k < 4; ++k) {
|
||||
for (int l = 0; l < 4; ++l) {
|
||||
// Randomly select one of the textures if the cable bus has more than just one
|
||||
// possibility here
|
||||
final TextureAtlasSprite texture = Platform.pickRandom(textures);
|
||||
|
||||
if (!textures.isEmpty()) {
|
||||
// Shamelessly inspired by ParticleManager.addBlockDestroyEffects
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
for (int k = 0; k < 4; ++k) {
|
||||
for (int l = 0; l < 4; ++l) {
|
||||
// Randomly select one of the textures if the cable bus has more than just one possibility here
|
||||
final TextureAtlasSprite texture = Platform.pickRandom(textures);
|
||||
final double x = pos.getX() + (j + 0.5D) / 4.0D;
|
||||
final double y = pos.getY() + (k + 0.5D) / 4.0D;
|
||||
final double z = pos.getZ() + (l + 0.5D) / 4.0D;
|
||||
|
||||
final double x = pos.getX() + (j + 0.5D) / 4.0D;
|
||||
final double y = pos.getY() + (k + 0.5D) / 4.0D;
|
||||
final double z = pos.getZ() + (l + 0.5D) / 4.0D;
|
||||
// FIXME: Check how this looks, probably like shit, maybe provide parts the
|
||||
// ability to supply particle textures???
|
||||
Particle effect = new CableBusBreakingParticle(world, x, y, z, x - pos.getX() - 0.5D,
|
||||
y - pos.getY() - 0.5D, z - pos.getZ() - 0.5D, texture);
|
||||
effectRenderer.addEffect(effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: Check how this looks, probably like shit, maybe provide parts the ability to supply particle textures???
|
||||
Particle effect = new CableBusBreakingParticle(world, x, y, z, x - pos.getX() - 0.5D,
|
||||
y - pos.getY() - 0.5D, z - pos.getZ() - 0.5D, texture);
|
||||
effectRenderer.addEffect(effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
if (Platform.isServer()) {
|
||||
this.cb(world, pos).onNeighborChanged(world, pos, fromPos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
|
||||
if (Platform.isServer()) {
|
||||
this.cb(world, pos).onNeighborChanged(world, pos, fromPos);
|
||||
}
|
||||
}
|
||||
private ICableBusContainer cb(final IBlockReader w, final BlockPos pos) {
|
||||
final TileEntity te = w.getTileEntity(pos);
|
||||
ICableBusContainer out = null;
|
||||
|
||||
private ICableBusContainer cb(final IBlockReader w, final BlockPos pos) {
|
||||
final TileEntity te = w.getTileEntity(pos);
|
||||
ICableBusContainer out = null;
|
||||
if (te instanceof TileCableBus) {
|
||||
out = ((TileCableBus) te).getCableBus();
|
||||
}
|
||||
|
||||
if (te instanceof TileCableBus) {
|
||||
out = ((TileCableBus) te).getCableBus();
|
||||
}
|
||||
return out == null ? NULL_CABLE_BUS : out;
|
||||
}
|
||||
|
||||
return out == null ? NULL_CABLE_BUS : out;
|
||||
}
|
||||
@Nullable
|
||||
private IFacadeContainer fc(final IBlockReader w, final BlockPos pos) {
|
||||
final TileEntity te = w.getTileEntity(pos);
|
||||
IFacadeContainer out = null;
|
||||
|
||||
@Nullable
|
||||
private IFacadeContainer fc(final IBlockReader w, final BlockPos pos) {
|
||||
final TileEntity te = w.getTileEntity(pos);
|
||||
IFacadeContainer out = null;
|
||||
if (te instanceof TileCableBus) {
|
||||
out = ((TileCableBus) te).getCableBus().getFacadeContainer();
|
||||
}
|
||||
|
||||
if (te instanceof TileCableBus) {
|
||||
out = ((TileCableBus) te).getCableBus().getFacadeContainer();
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
@Override
|
||||
public void onBlockClicked(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) {
|
||||
if (worldIn.isRemote()) {
|
||||
final RayTraceResult rtr = Minecraft.getInstance().objectMouseOver;
|
||||
if (rtr instanceof BlockRayTraceResult) {
|
||||
BlockRayTraceResult brtr = (BlockRayTraceResult) rtr;
|
||||
if (brtr.getPos().equals(pos)) {
|
||||
final Vec3d hitVec = rtr.getHitVec().subtract(new Vec3d(pos));
|
||||
|
||||
@Override
|
||||
public void onBlockClicked(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) {
|
||||
if (worldIn.isRemote()) {
|
||||
final RayTraceResult rtr = Minecraft.getInstance().objectMouseOver;
|
||||
if (rtr instanceof BlockRayTraceResult) {
|
||||
BlockRayTraceResult brtr = (BlockRayTraceResult) rtr;
|
||||
if (brtr.getPos().equals(pos)) {
|
||||
final Vec3d hitVec = rtr.getHitVec().subtract(new Vec3d(pos));
|
||||
if (this.cb(worldIn, pos).clicked(player, Hand.MAIN_HAND, hitVec)) {
|
||||
NetworkHandler.instance().sendToServer(new PacketClick(pos, brtr.getFace(), (float) hitVec.x,
|
||||
(float) hitVec.y, (float) hitVec.z, Hand.MAIN_HAND, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.cb(worldIn, pos).clicked(player, Hand.MAIN_HAND, hitVec)) {
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(
|
||||
new PacketClick(pos, brtr.getFace(), (float) hitVec.x, (float) hitVec.y, (float) hitVec.z, Hand.MAIN_HAND, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void onBlockClickPacket(World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Vec3d hitVec) {
|
||||
this.cb(worldIn, pos).clicked(playerIn, hand, hitVec);
|
||||
}
|
||||
|
||||
public void onBlockClickPacket(World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Vec3d hitVec) {
|
||||
this.cb(worldIn, pos).clicked(playerIn, hand, hitVec);
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
// Transform from world into block space
|
||||
Vec3d hitVec = hit.getHitVec();
|
||||
Vec3d hitInBlock = new Vec3d(hitVec.x - pos.getX(), hitVec.y - pos.getY(), hitVec.z - pos.getZ());
|
||||
return this.cb(w, pos).activate(player, hand, hitInBlock) ? ActionResultType.SUCCESS : ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
// Transform from world into block space
|
||||
Vec3d hitVec = hit.getHitVec();
|
||||
Vec3d hitInBlock = new Vec3d(hitVec.x - pos.getX(), hitVec.y - pos.getY(), hitVec.z - pos.getZ());
|
||||
return this.cb(w, pos).activate(player, hand, hitInBlock) ? ActionResultType.SUCCESS
|
||||
: ActionResultType.PASS;
|
||||
}
|
||||
@Override
|
||||
public boolean recolorBlock(BlockState state, IWorld world, BlockPos pos, Direction side, DyeColor color) {
|
||||
return recolorBlock(world, pos, side, color, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolorBlock(BlockState state, IWorld world, BlockPos pos, Direction side, DyeColor color) {
|
||||
return recolorBlock(world, pos, side, color, null);
|
||||
}
|
||||
public boolean recolorBlock(final IBlockReader world, final BlockPos pos, final Direction side,
|
||||
final DyeColor color, final PlayerEntity who) {
|
||||
try {
|
||||
return this.cb(world, pos).recolourBlock(side, AEColor.values()[color.ordinal()], who);
|
||||
} catch (final Throwable ignored) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean recolorBlock(final IBlockReader world, final BlockPos pos, final Direction side, final DyeColor color, final PlayerEntity who) {
|
||||
try {
|
||||
return this.cb(world, pos).recolourBlock(side, AEColor.values()[color.ordinal()], who);
|
||||
} catch (final Throwable ignored) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> itemStacks) {
|
||||
// do nothing
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> itemStacks) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
// FIXME FACADES @Override
|
||||
// FIXME FACADES public BlockState getFacadeState( IBlockReader world, BlockPos pos, Direction side )
|
||||
@@ -366,40 +375,38 @@ public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implem
|
||||
// FIXME FACADES return world.getBlockState( pos );
|
||||
// FIXME FACADES }
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
|
||||
|
||||
// FIXME: this has to be cached, optimized, fixed in all kinds of ways
|
||||
TileCableBus te = getTileEntity(w, pos);
|
||||
VoxelShape result = VoxelShapes.empty();
|
||||
if (te != null) {
|
||||
for (final AxisAlignedBB bx : te.getCableBus().getSelectedBoundingBoxesFromPool(false, true, context.getEntity(), true)) {
|
||||
result = VoxelShapes.or(
|
||||
result,
|
||||
VoxelShapes.create(new AxisAlignedBB(bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ))
|
||||
);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
// FIXME: this has to be cached, optimized, fixed in all kinds of ways
|
||||
TileCableBus te = getTileEntity(w, pos);
|
||||
VoxelShape result = VoxelShapes.empty();
|
||||
if (te != null) {
|
||||
for (final AxisAlignedBB bx : te.getCableBus().getSelectedBoundingBoxesFromPool(false, true,
|
||||
context.getEntity(), true)) {
|
||||
result = VoxelShapes.or(result,
|
||||
VoxelShapes.create(new AxisAlignedBB(bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ)));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
|
||||
|
||||
// FIXME: this has to be cached, optimized, fixed in all kinds of ways
|
||||
TileCableBus te = getTileEntity(w, pos);
|
||||
VoxelShape result = VoxelShapes.empty();
|
||||
if (te != null) {
|
||||
for (final AxisAlignedBB bx : te.getCableBus().getSelectedBoundingBoxesFromPool(false, true, context.getEntity(), false)) {
|
||||
result = VoxelShapes.or(
|
||||
result,
|
||||
VoxelShapes.create(new AxisAlignedBB(bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ))
|
||||
);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
// FIXME: this has to be cached, optimized, fixed in all kinds of ways
|
||||
TileCableBus te = getTileEntity(w, pos);
|
||||
VoxelShape result = VoxelShapes.empty();
|
||||
if (te != null) {
|
||||
for (final AxisAlignedBB bx : te.getCableBus().getSelectedBoundingBoxesFromPool(false, true,
|
||||
context.getEntity(), false)) {
|
||||
result = VoxelShapes.or(result,
|
||||
VoxelShapes.create(new AxisAlignedBB(bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ)));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,11 +18,9 @@
|
||||
|
||||
package appeng.block.networking;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.util.Direction;
|
||||
@@ -35,121 +33,109 @@ import net.minecraft.world.World;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.tile.networking.TileController;
|
||||
|
||||
public class BlockController extends AEBaseTileBlock<TileController> {
|
||||
|
||||
public class BlockController extends AEBaseTileBlock<TileController>
|
||||
{
|
||||
public enum ControllerBlockState implements IStringSerializable {
|
||||
offline, online, conflicted;
|
||||
|
||||
public enum ControllerBlockState implements IStringSerializable
|
||||
{
|
||||
offline, online, conflicted;
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return this.name();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Controls the rendering of the controller block (connected texture style).
|
||||
* inside_a and inside_b are alternating patterns for a controller that is
|
||||
* enclosed by other controllers, and since they are always offline, they do not
|
||||
* have the usual sub-states.
|
||||
*/
|
||||
public enum ControllerRenderType implements IStringSerializable {
|
||||
block, column_x, column_y, column_z, inside_a, inside_b;
|
||||
|
||||
/**
|
||||
* Controls the rendering of the controller block (connected texture style).
|
||||
* inside_a and inside_b are alternating patterns for a controller that is enclosed by other controllers,
|
||||
* and since they are always offline, they do not have the usual sub-states.
|
||||
*/
|
||||
public enum ControllerRenderType implements IStringSerializable
|
||||
{
|
||||
block, column_x, column_y, column_z, inside_a, inside_b;
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return this.name();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public static final EnumProperty<ControllerBlockState> CONTROLLER_STATE = EnumProperty.create("state",
|
||||
ControllerBlockState.class);
|
||||
|
||||
public static final EnumProperty<ControllerBlockState> CONTROLLER_STATE = EnumProperty.create( "state", ControllerBlockState.class );
|
||||
public static final EnumProperty<ControllerRenderType> CONTROLLER_TYPE = EnumProperty.create("type",
|
||||
ControllerRenderType.class);
|
||||
|
||||
public static final EnumProperty<ControllerRenderType> CONTROLLER_TYPE = EnumProperty.create( "type", ControllerRenderType.class );
|
||||
public BlockController() {
|
||||
super(defaultProps(Material.IRON).hardnessAndResistance(6));
|
||||
this.setDefaultState(this.getDefaultState().with(CONTROLLER_STATE, ControllerBlockState.offline)
|
||||
.with(CONTROLLER_TYPE, ControllerRenderType.block));
|
||||
}
|
||||
|
||||
public BlockController()
|
||||
{
|
||||
super( defaultProps(Material.IRON).hardnessAndResistance(6) );
|
||||
this.setDefaultState( this.getDefaultState()
|
||||
.with( CONTROLLER_STATE, ControllerBlockState.offline )
|
||||
.with( CONTROLLER_TYPE, ControllerRenderType.block ) );
|
||||
}
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(CONTROLLER_STATE);
|
||||
builder.add(CONTROLLER_TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(CONTROLLER_STATE);
|
||||
builder.add(CONTROLLER_TYPE);
|
||||
}
|
||||
/**
|
||||
* This will compute the AE_BLOCK_FORWARD, AE_BLOCK_UP and CONTROLLER_TYPE block
|
||||
* states based on adjacent controllers and the network state of this controller
|
||||
* (offline, online, conflicted). This is used to get a rudimentary connected
|
||||
* texture feel for the controller based on how it is placed.
|
||||
*/
|
||||
@Override
|
||||
public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world,
|
||||
BlockPos pos, BlockPos facingPos) {
|
||||
|
||||
/**
|
||||
* This will compute the AE_BLOCK_FORWARD, AE_BLOCK_UP and CONTROLLER_TYPE block states based on adjacent
|
||||
* controllers and the network state of this controller (offline, online, conflicted). This is used to
|
||||
* get a rudimentary connected texture feel for the controller based on how it is placed.
|
||||
*/
|
||||
@Override
|
||||
public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world, BlockPos pos, BlockPos facingPos) {
|
||||
// FIXME: this might work, or might _NOT_ work, but needs to be investigated
|
||||
|
||||
// FIXME: this might work, or might _NOT_ work, but needs to be investigated
|
||||
// Only used for columns, really
|
||||
ControllerRenderType type = ControllerRenderType.block;
|
||||
|
||||
// Only used for columns, really
|
||||
ControllerRenderType type = ControllerRenderType.block;
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
// Detect whether controllers are on both sides of the x, y, and z axes
|
||||
final boolean xx = this.getTileEntity(world, x - 1, y, z) != null
|
||||
&& this.getTileEntity(world, x + 1, y, z) != null;
|
||||
final boolean yy = this.getTileEntity(world, x, y - 1, z) != null
|
||||
&& this.getTileEntity(world, x, y + 1, z) != null;
|
||||
final boolean zz = this.getTileEntity(world, x, y, z - 1) != null
|
||||
&& this.getTileEntity(world, x, y, z + 1) != null;
|
||||
|
||||
// Detect whether controllers are on both sides of the x, y, and z axes
|
||||
final boolean xx = this.getTileEntity(world, x - 1, y, z) != null
|
||||
&& this.getTileEntity(world, x + 1, y, z) != null;
|
||||
final boolean yy = this.getTileEntity(world, x, y - 1, z) != null
|
||||
&& this.getTileEntity(world, x, y + 1, z) != null;
|
||||
final boolean zz = this.getTileEntity(world, x, y, z - 1) != null
|
||||
&& this.getTileEntity(world, x, y, z + 1) != null;
|
||||
if (xx && !yy && !zz) {
|
||||
type = ControllerRenderType.column_x;
|
||||
} else if (!xx && yy && !zz) {
|
||||
type = ControllerRenderType.column_y;
|
||||
} else if (!xx && !yy && zz) {
|
||||
type = ControllerRenderType.column_z;
|
||||
} else if ((xx ? 1 : 0) + (yy ? 1 : 0) + (zz ? 1 : 0) >= 2) {
|
||||
final int v = (Math.abs(x) + Math.abs(y) + Math.abs(z)) % 2;
|
||||
|
||||
if( xx && !yy && !zz )
|
||||
{
|
||||
type = ControllerRenderType.column_x;
|
||||
}
|
||||
else if( !xx && yy && !zz )
|
||||
{
|
||||
type = ControllerRenderType.column_y;
|
||||
}
|
||||
else if( !xx && !yy && zz )
|
||||
{
|
||||
type = ControllerRenderType.column_z;
|
||||
}
|
||||
else if( ( xx ? 1 : 0 ) + ( yy ? 1 : 0 ) + ( zz ? 1 : 0 ) >= 2 )
|
||||
{
|
||||
final int v = ( Math.abs( x ) + Math.abs( y ) + Math.abs( z ) ) % 2;
|
||||
// While i'd like this to be based on the blockstate randomization feature, this
|
||||
// generates
|
||||
// an alternating pattern based on world position, so this is not 100% doable
|
||||
// with blockstates.
|
||||
if (v == 0) {
|
||||
type = ControllerRenderType.inside_a;
|
||||
} else {
|
||||
type = ControllerRenderType.inside_b;
|
||||
}
|
||||
}
|
||||
|
||||
// While i'd like this to be based on the blockstate randomization feature, this generates
|
||||
// an alternating pattern based on world position, so this is not 100% doable with blockstates.
|
||||
if( v == 0 )
|
||||
{
|
||||
type = ControllerRenderType.inside_a;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = ControllerRenderType.inside_b;
|
||||
}
|
||||
}
|
||||
return state.with(CONTROLLER_TYPE, type);
|
||||
}
|
||||
|
||||
return state.with( CONTROLLER_TYPE, type );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving )
|
||||
{
|
||||
final TileController tc = this.getTileEntity( world, pos );
|
||||
if( tc != null )
|
||||
{
|
||||
tc.onNeighborChange( false );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
final TileController tc = this.getTileEntity(world, pos);
|
||||
if (tc != null) {
|
||||
tc.onNeighborChange(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,17 +18,13 @@
|
||||
|
||||
package appeng.block.networking;
|
||||
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.tile.networking.TileCreativeEnergyCell;
|
||||
|
||||
public class BlockCreativeEnergyCell extends AEBaseTileBlock<TileCreativeEnergyCell> {
|
||||
|
||||
public class BlockCreativeEnergyCell extends AEBaseTileBlock<TileCreativeEnergyCell>
|
||||
{
|
||||
|
||||
public BlockCreativeEnergyCell()
|
||||
{
|
||||
super( defaultProps(AEGlassMaterial.INSTANCE) );
|
||||
}
|
||||
public BlockCreativeEnergyCell() {
|
||||
super(defaultProps(AEGlassMaterial.INSTANCE));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,18 +18,14 @@
|
||||
|
||||
package appeng.block.networking;
|
||||
|
||||
public class BlockDenseEnergyCell extends BlockEnergyCell {
|
||||
|
||||
public class BlockDenseEnergyCell extends BlockEnergyCell
|
||||
{
|
||||
public BlockDenseEnergyCell() {
|
||||
|
||||
public BlockDenseEnergyCell()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
return 200000.0 * 8.0;
|
||||
}
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
return 200000.0 * 8.0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,19 +18,15 @@
|
||||
|
||||
package appeng.block.networking;
|
||||
|
||||
|
||||
import appeng.tile.networking.TileEnergyAcceptor;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.tile.networking.TileEnergyAcceptor;
|
||||
|
||||
public class BlockEnergyAcceptor extends AEBaseTileBlock<TileEnergyAcceptor> {
|
||||
|
||||
public class BlockEnergyAcceptor extends AEBaseTileBlock<TileEnergyAcceptor>
|
||||
{
|
||||
|
||||
public BlockEnergyAcceptor()
|
||||
{
|
||||
super(defaultProps(Material.IRON) );
|
||||
}
|
||||
public BlockEnergyAcceptor() {
|
||||
super(defaultProps(Material.IRON));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
package appeng.block.networking;
|
||||
|
||||
|
||||
import appeng.tile.networking.TileEnergyCell;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
@@ -33,40 +31,37 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.tile.networking.TileEnergyCell;
|
||||
|
||||
public class BlockEnergyCell extends AEBaseTileBlock<TileEnergyCell>
|
||||
{
|
||||
public class BlockEnergyCell extends AEBaseTileBlock<TileEnergyCell> {
|
||||
|
||||
public static final IntegerProperty ENERGY_STORAGE = IntegerProperty.create( "fullness", 0, 7 );
|
||||
public static final IntegerProperty ENERGY_STORAGE = IntegerProperty.create("fullness", 0, 7);
|
||||
|
||||
public BlockEnergyCell()
|
||||
{
|
||||
super( defaultProps(AEGlassMaterial.INSTANCE) );
|
||||
}
|
||||
public BlockEnergyCell() {
|
||||
super(defaultProps(AEGlassMaterial.INSTANCE));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> itemStacks)
|
||||
{
|
||||
super.fillItemGroup( group, itemStacks );
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> itemStacks) {
|
||||
super.fillItemGroup(group, itemStacks);
|
||||
|
||||
final ItemStack charged = new ItemStack(this, 1);
|
||||
final CompoundNBT tag = charged.getOrCreateTag();
|
||||
tag.putDouble("internalCurrentPower", this.getMaxPower());
|
||||
tag.putDouble("internalMaxPower", this.getMaxPower());
|
||||
final ItemStack charged = new ItemStack(this, 1);
|
||||
final CompoundNBT tag = charged.getOrCreateTag();
|
||||
tag.putDouble("internalCurrentPower", this.getMaxPower());
|
||||
tag.putDouble("internalMaxPower", this.getMaxPower());
|
||||
|
||||
itemStacks.add(charged);
|
||||
}
|
||||
itemStacks.add(charged);
|
||||
}
|
||||
|
||||
public double getMaxPower()
|
||||
{
|
||||
return 200000.0;
|
||||
}
|
||||
public double getMaxPower() {
|
||||
return 200000.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(ENERGY_STORAGE);
|
||||
}
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(ENERGY_STORAGE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.block.networking;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
@@ -28,21 +27,17 @@ import appeng.bootstrap.BlockRenderingCustomizer;
|
||||
import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
|
||||
|
||||
// FIXME REMOVE
|
||||
public class BlockEnergyCellRendering extends BlockRenderingCustomizer
|
||||
{
|
||||
public class BlockEnergyCellRendering extends BlockRenderingCustomizer {
|
||||
|
||||
private final ResourceLocation baseModel;
|
||||
private final ResourceLocation baseModel;
|
||||
|
||||
public BlockEnergyCellRendering( ResourceLocation baseModel )
|
||||
{
|
||||
this.baseModel = baseModel;
|
||||
}
|
||||
public BlockEnergyCellRendering(ResourceLocation baseModel) {
|
||||
this.baseModel = baseModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||
{
|
||||
// Note: Since we use the block models, we dont need to register custom variants
|
||||
}
|
||||
@Override
|
||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||
// Note: Since we use the block models, we dont need to register custom variants
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,6 @@
|
||||
|
||||
package appeng.block.networking;
|
||||
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerWireless;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -46,200 +38,192 @@ import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerWireless;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockWireless extends AEBaseTileBlock<TileWireless>
|
||||
{
|
||||
public class BlockWireless extends AEBaseTileBlock<TileWireless> {
|
||||
|
||||
enum State implements IStringSerializable
|
||||
{
|
||||
OFF,
|
||||
ON,
|
||||
HAS_CHANNEL;
|
||||
enum State implements IStringSerializable {
|
||||
OFF, ON, HAS_CHANNEL;
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
public static final EnumProperty<State> STATE = EnumProperty.create( "state", State.class );
|
||||
public static final EnumProperty<State> STATE = EnumProperty.create("state", State.class);
|
||||
|
||||
public BlockWireless()
|
||||
{
|
||||
super( defaultProps(AEGlassMaterial.INSTANCE).notSolid() );
|
||||
this.setFullSize( false );
|
||||
this.setOpaque( false );
|
||||
this.setDefaultState( this.getDefaultState().with( STATE, State.OFF ) );
|
||||
}
|
||||
public BlockWireless() {
|
||||
super(defaultProps(AEGlassMaterial.INSTANCE).notSolid());
|
||||
this.setFullSize(false);
|
||||
this.setOpaque(false);
|
||||
this.setDefaultState(this.getDefaultState().with(STATE, State.OFF));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileWireless te) {
|
||||
State teState = State.OFF;
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileWireless te) {
|
||||
State teState = State.OFF;
|
||||
|
||||
if( te.isActive() )
|
||||
{
|
||||
teState = State.HAS_CHANNEL;
|
||||
}
|
||||
else if( te.isPowered() )
|
||||
{
|
||||
teState = State.ON;
|
||||
}
|
||||
if (te.isActive()) {
|
||||
teState = State.HAS_CHANNEL;
|
||||
} else if (te.isPowered()) {
|
||||
teState = State.ON;
|
||||
}
|
||||
|
||||
return currentState.with(STATE, teState);
|
||||
}
|
||||
return currentState.with(STATE, teState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(STATE);
|
||||
}
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(STATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
final TileWireless tg = this.getTileEntity( w, pos );
|
||||
@Override
|
||||
public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity player, Hand hand,
|
||||
BlockRayTraceResult hit) {
|
||||
final TileWireless tg = this.getTileEntity(w, pos);
|
||||
|
||||
if( tg != null && !player.isCrouching() )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerWireless.TYPE, player, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
if (tg != null && !player.isCrouching()) {
|
||||
if (Platform.isServer()) {
|
||||
ContainerOpener.openContainer(ContainerWireless.TYPE, player,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
return super.onBlockActivated( state, w, pos, player, hand, hit );
|
||||
}
|
||||
return super.onBlockActivated(state, w, pos, player, hand, hit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
|
||||
final TileWireless tile = this.getTileEntity( w, pos );
|
||||
if( tile != null )
|
||||
{
|
||||
final Direction forward = tile.getForward();
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
|
||||
final TileWireless tile = this.getTileEntity(w, pos);
|
||||
if (tile != null) {
|
||||
final Direction forward = tile.getForward();
|
||||
|
||||
double minX = 0;
|
||||
double minY = 0;
|
||||
double minZ = 0;
|
||||
double maxX = 1;
|
||||
double maxY = 1;
|
||||
double maxZ = 1;
|
||||
double minX = 0;
|
||||
double minY = 0;
|
||||
double minZ = 0;
|
||||
double maxX = 1;
|
||||
double maxY = 1;
|
||||
double maxZ = 1;
|
||||
|
||||
switch( forward )
|
||||
{
|
||||
case DOWN:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 1.0;
|
||||
minY = 5.0 / 16.0;
|
||||
break;
|
||||
case EAST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 11.0 / 16.0;
|
||||
minX = 0.0;
|
||||
break;
|
||||
case NORTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 1.0;
|
||||
minZ = 5.0 / 16.0;
|
||||
break;
|
||||
case SOUTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 11.0 / 16.0;
|
||||
minZ = 0.0;
|
||||
break;
|
||||
case UP:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 11.0 / 16.0;
|
||||
minY = 0.0;
|
||||
break;
|
||||
case WEST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 1.0;
|
||||
minX = 5.0 / 16.0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (forward) {
|
||||
case DOWN:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 1.0;
|
||||
minY = 5.0 / 16.0;
|
||||
break;
|
||||
case EAST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 11.0 / 16.0;
|
||||
minX = 0.0;
|
||||
break;
|
||||
case NORTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 1.0;
|
||||
minZ = 5.0 / 16.0;
|
||||
break;
|
||||
case SOUTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 11.0 / 16.0;
|
||||
minZ = 0.0;
|
||||
break;
|
||||
case UP:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 11.0 / 16.0;
|
||||
minY = 0.0;
|
||||
break;
|
||||
case WEST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 1.0;
|
||||
minX = 5.0 / 16.0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return VoxelShapes.create( new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ) );
|
||||
}
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
return VoxelShapes.create(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ));
|
||||
}
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
|
||||
|
||||
final TileWireless tile = this.getTileEntity( w, pos );
|
||||
if( tile != null )
|
||||
{
|
||||
final Direction forward = tile.getForward();
|
||||
final TileWireless tile = this.getTileEntity(w, pos);
|
||||
if (tile != null) {
|
||||
final Direction forward = tile.getForward();
|
||||
|
||||
double minX = 0;
|
||||
double minY = 0;
|
||||
double minZ = 0;
|
||||
double maxX = 1;
|
||||
double maxY = 1;
|
||||
double maxZ = 1;
|
||||
double minX = 0;
|
||||
double minY = 0;
|
||||
double minZ = 0;
|
||||
double maxX = 1;
|
||||
double maxY = 1;
|
||||
double maxZ = 1;
|
||||
|
||||
switch( forward )
|
||||
{
|
||||
case DOWN:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 1.0;
|
||||
minY = 5.0 / 16.0;
|
||||
break;
|
||||
case EAST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 11.0 / 16.0;
|
||||
minX = 0.0;
|
||||
break;
|
||||
case NORTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 1.0;
|
||||
minZ = 5.0 / 16.0;
|
||||
break;
|
||||
case SOUTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 11.0 / 16.0;
|
||||
minZ = 0.0;
|
||||
break;
|
||||
case UP:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 11.0 / 16.0;
|
||||
minY = 0.0;
|
||||
break;
|
||||
case WEST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 1.0;
|
||||
minX = 5.0 / 16.0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (forward) {
|
||||
case DOWN:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 1.0;
|
||||
minY = 5.0 / 16.0;
|
||||
break;
|
||||
case EAST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 11.0 / 16.0;
|
||||
minX = 0.0;
|
||||
break;
|
||||
case NORTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 1.0;
|
||||
minZ = 5.0 / 16.0;
|
||||
break;
|
||||
case SOUTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 11.0 / 16.0;
|
||||
minZ = 0.0;
|
||||
break;
|
||||
case UP:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 11.0 / 16.0;
|
||||
minY = 0.0;
|
||||
break;
|
||||
case WEST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 1.0;
|
||||
minX = 5.0 / 16.0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return VoxelShapes.create( new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
}
|
||||
return VoxelShapes.create(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ));
|
||||
} else {
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,8 @@
|
||||
|
||||
package appeng.block.networking;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.parts.CableBusContainer;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.color.IBlockColor;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -32,32 +31,31 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.client.render.cablebus.CableBusRenderState;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.parts.CableBusContainer;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
|
||||
/**
|
||||
* Exposes the cable bus color as tint indices 0 (dark variant), 1 (medium variant) and 2 (bright variant).
|
||||
* Exposes the cable bus color as tint indices 0 (dark variant), 1 (medium
|
||||
* variant) and 2 (bright variant).
|
||||
*/
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public class CableBusColor implements IBlockColor
|
||||
{
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class CableBusColor implements IBlockColor {
|
||||
|
||||
@Override
|
||||
public int getColor(BlockState state, @Nullable ILightReader worldIn, @Nullable BlockPos pos, int color) {
|
||||
@Override
|
||||
public int getColor(BlockState state, @Nullable ILightReader worldIn, @Nullable BlockPos pos, int color) {
|
||||
|
||||
// FIXME: Once COLOR becomes part of the block state, change this
|
||||
AEColor busColor = AEColor.TRANSPARENT;
|
||||
// FIXME: Once COLOR becomes part of the block state, change this
|
||||
AEColor busColor = AEColor.TRANSPARENT;
|
||||
|
||||
if (worldIn != null && pos != null) {
|
||||
TileEntity tileEntity = worldIn.getTileEntity(pos);
|
||||
if (tileEntity instanceof TileCableBus) {
|
||||
CableBusContainer container = ((TileCableBus) tileEntity).getCableBus();
|
||||
busColor = container.getColor();
|
||||
}
|
||||
}
|
||||
if (worldIn != null && pos != null) {
|
||||
TileEntity tileEntity = worldIn.getTileEntity(pos);
|
||||
if (tileEntity instanceof TileCableBus) {
|
||||
CableBusContainer container = ((TileCableBus) tileEntity).getCableBus();
|
||||
busColor = container.getColor();
|
||||
}
|
||||
}
|
||||
|
||||
return busColor.getVariantByTintIndex( color );
|
||||
return busColor.getVariantByTintIndex(color);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.block.networking;
|
||||
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@@ -28,28 +27,24 @@ import appeng.bootstrap.IItemRendering;
|
||||
import appeng.client.render.cablebus.CableBusModel;
|
||||
import appeng.core.features.registries.PartModels;
|
||||
|
||||
|
||||
/**
|
||||
* Customizes the rendering behavior for cable busses, which are the biggest multipart of AE2.
|
||||
* Customizes the rendering behavior for cable busses, which are the biggest
|
||||
* multipart of AE2.
|
||||
*/
|
||||
public class CableBusRendering extends BlockRenderingCustomizer
|
||||
{
|
||||
public class CableBusRendering extends BlockRenderingCustomizer {
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||
{
|
||||
/* FIXME this was previously
|
||||
*
|
||||
@Override
|
||||
public boolean canRenderInLayer( BlockState state, BlockRenderLayer layer )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
rendering.renderType(rt -> true);
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||
/*
|
||||
* FIXME this was previously
|
||||
*
|
||||
* @Override public boolean canRenderInLayer( BlockState state, BlockRenderLayer
|
||||
* layer ) { return true; }
|
||||
*/
|
||||
rendering.renderType(rt -> true);
|
||||
|
||||
rendering.blockColor( new CableBusColor() );
|
||||
rendering.modelCustomizer( ( loc, model ) -> model );
|
||||
}
|
||||
rendering.blockColor(new CableBusColor());
|
||||
rendering.modelCustomizer((loc, model) -> model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,20 +18,17 @@
|
||||
|
||||
package appeng.block.networking;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
||||
import appeng.bootstrap.BlockRenderingCustomizer;
|
||||
import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
||||
|
||||
public class ControllerRendering extends BlockRenderingCustomizer
|
||||
{
|
||||
@Override
|
||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||
{
|
||||
// Disables the default model rotator
|
||||
rendering.modelCustomizer( ( loc, model ) -> model );
|
||||
rendering.renderType(RenderType.getCutout());
|
||||
}
|
||||
public class ControllerRendering extends BlockRenderingCustomizer {
|
||||
@Override
|
||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||
// Disables the default model rotator
|
||||
rendering.modelCustomizer((loc, model) -> model);
|
||||
rendering.renderType(RenderType.getCutout());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
package appeng.block.networking;
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -12,14 +11,11 @@ import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.client.render.StaticBlockColor;
|
||||
|
||||
|
||||
public class WirelessRendering extends BlockRenderingCustomizer
|
||||
{
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||
{
|
||||
rendering.renderType(RenderType.getCutout());
|
||||
rendering.blockColor( new StaticBlockColor( AEColor.TRANSPARENT ) );
|
||||
}
|
||||
public class WirelessRendering extends BlockRenderingCustomizer {
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||
rendering.renderType(RenderType.getCutout());
|
||||
rendering.blockColor(new StaticBlockColor(AEColor.TRANSPARENT));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,6 @@
|
||||
|
||||
package appeng.block.paint;
|
||||
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.tile.misc.TilePaint;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -40,75 +36,69 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.tile.misc.TilePaint;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockPaint extends AEBaseTileBlock<TilePaint>
|
||||
{
|
||||
public BlockPaint()
|
||||
{
|
||||
super(defaultProps(Material.WATER, MaterialColor.AIR));
|
||||
this.setFullSize( false );
|
||||
this.setOpaque( false );
|
||||
}
|
||||
public class BlockPaint extends AEBaseTileBlock<TilePaint> {
|
||||
public BlockPaint() {
|
||||
super(defaultProps(Material.WATER, MaterialColor.AIR));
|
||||
this.setFullSize(false);
|
||||
this.setOpaque(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> itemStacks)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> itemStacks) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving )
|
||||
{
|
||||
final TilePaint tp = this.getTileEntity( world, pos );
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
final TilePaint tp = this.getTileEntity(world, pos);
|
||||
|
||||
if( tp != null )
|
||||
{
|
||||
tp.neighborChanged();
|
||||
}
|
||||
}
|
||||
if (tp != null) {
|
||||
tp.neighborChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillWithRain( final World w, final BlockPos pos )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
w.removeBlock(pos, false);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void fillWithRain(final World w, final BlockPos pos) {
|
||||
if (Platform.isServer()) {
|
||||
w.removeBlock(pos, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue( final BlockState state, final IBlockReader w, final BlockPos pos )
|
||||
{
|
||||
final TilePaint tp = this.getTileEntity( w, pos );
|
||||
@Override
|
||||
public int getLightValue(final BlockState state, final IBlockReader w, final BlockPos pos) {
|
||||
final TilePaint tp = this.getTileEntity(w, pos);
|
||||
|
||||
if( tp != null )
|
||||
{
|
||||
return tp.getLightLevel();
|
||||
}
|
||||
if (tp != null) {
|
||||
return tp.getLightLevel();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAir( final BlockState state, final IBlockReader world, final BlockPos pos )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isAir(final BlockState state, final IBlockReader world, final BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable(BlockState p_225541_1_, Fluid p_225541_2_) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isReplaceable(BlockState p_225541_1_, Fluid p_225541_2_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
package appeng.block.paint;
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -10,16 +9,13 @@ import appeng.bootstrap.BlockRenderingCustomizer;
|
||||
import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
|
||||
public class PaintRendering extends BlockRenderingCustomizer {
|
||||
|
||||
public class PaintRendering extends BlockRenderingCustomizer
|
||||
{
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||
{
|
||||
rendering.renderType(RenderType.getCutout());
|
||||
// Disable auto rotation
|
||||
rendering.modelCustomizer( ( location, model ) -> model );
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||
rendering.renderType(RenderType.getCutout());
|
||||
// Disable auto rotation
|
||||
rendering.modelCustomizer((location, model) -> model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
package appeng.block.paint;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@@ -9,23 +8,20 @@ import com.google.common.collect.ImmutableList;
|
||||
|
||||
import appeng.helpers.Splotch;
|
||||
|
||||
|
||||
/**
|
||||
* Used to transfer the state about paint splotches from the game thread to the render thread.
|
||||
* Used to transfer the state about paint splotches from the game thread to the
|
||||
* render thread.
|
||||
*/
|
||||
public class PaintSplotches
|
||||
{
|
||||
public class PaintSplotches {
|
||||
|
||||
private final List<Splotch> splotches;
|
||||
private final List<Splotch> splotches;
|
||||
|
||||
public PaintSplotches( Collection<Splotch> splotches )
|
||||
{
|
||||
this.splotches = ImmutableList.copyOf( splotches );
|
||||
}
|
||||
public PaintSplotches(Collection<Splotch> splotches) {
|
||||
this.splotches = ImmutableList.copyOf(splotches);
|
||||
}
|
||||
|
||||
List<Splotch> getSplotches()
|
||||
{
|
||||
return this.splotches;
|
||||
}
|
||||
List<Splotch> getSplotches() {
|
||||
return this.splotches;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
package appeng.block.paint;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -11,7 +10,6 @@ import java.util.function.Function;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.tile.misc.TilePaint;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -24,172 +22,158 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.data.IDynamicBakedModel;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
import appeng.client.render.cablebus.CubeBuilder;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.helpers.Splotch;
|
||||
import net.minecraftforge.client.model.data.IDynamicBakedModel;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
import appeng.tile.misc.TilePaint;
|
||||
|
||||
/**
|
||||
* Renders paint blocks, which render multiple "splotches" that have been applied to the sides of adjacent blocks using
|
||||
* a
|
||||
* matter cannon with paint balls.
|
||||
* Renders paint blocks, which render multiple "splotches" that have been
|
||||
* applied to the sides of adjacent blocks using a matter cannon with paint
|
||||
* balls.
|
||||
*/
|
||||
class PaintSplotchesBakedModel implements IDynamicBakedModel
|
||||
{
|
||||
class PaintSplotchesBakedModel implements IDynamicBakedModel {
|
||||
|
||||
private static final Material TEXTURE_PAINT1 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(AppEng.MOD_ID, "block/paint1" ));
|
||||
private static final Material TEXTURE_PAINT2 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "block/paint2" ));
|
||||
private static final Material TEXTURE_PAINT3 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "block/paint3" ));
|
||||
private static final Material TEXTURE_PAINT1 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
||||
new ResourceLocation(AppEng.MOD_ID, "block/paint1"));
|
||||
private static final Material TEXTURE_PAINT2 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
||||
new ResourceLocation(AppEng.MOD_ID, "block/paint2"));
|
||||
private static final Material TEXTURE_PAINT3 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
||||
new ResourceLocation(AppEng.MOD_ID, "block/paint3"));
|
||||
|
||||
private final TextureAtlasSprite[] textures;
|
||||
private final TextureAtlasSprite[] textures;
|
||||
|
||||
PaintSplotchesBakedModel(Function<Material, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
this.textures = new TextureAtlasSprite[] {
|
||||
bakedTextureGetter.apply( TEXTURE_PAINT1 ),
|
||||
bakedTextureGetter.apply( TEXTURE_PAINT2 ),
|
||||
bakedTextureGetter.apply( TEXTURE_PAINT3 )
|
||||
};
|
||||
}
|
||||
PaintSplotchesBakedModel(Function<Material, TextureAtlasSprite> bakedTextureGetter) {
|
||||
this.textures = new TextureAtlasSprite[] { bakedTextureGetter.apply(TEXTURE_PAINT1),
|
||||
bakedTextureGetter.apply(TEXTURE_PAINT2), bakedTextureGetter.apply(TEXTURE_PAINT3) };
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand,
|
||||
@Nonnull IModelData extraData) {
|
||||
|
||||
if( side != null )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (side != null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
PaintSplotches splotchesState = extraData.getData(TilePaint.SPLOTCHES);
|
||||
PaintSplotches splotchesState = extraData.getData(TilePaint.SPLOTCHES);
|
||||
|
||||
if( splotchesState == null )
|
||||
{
|
||||
// This is the inventory model which should usually not be used other than in special cases
|
||||
List<BakedQuad> quads = new ArrayList<>( 1 );
|
||||
CubeBuilder builder = new CubeBuilder( quads );
|
||||
builder.setTexture( this.textures[0] );
|
||||
builder.addCube( 0, 0, 0, 16, 16, 16 );
|
||||
return quads;
|
||||
}
|
||||
if (splotchesState == null) {
|
||||
// This is the inventory model which should usually not be used other than in
|
||||
// special cases
|
||||
List<BakedQuad> quads = new ArrayList<>(1);
|
||||
CubeBuilder builder = new CubeBuilder(quads);
|
||||
builder.setTexture(this.textures[0]);
|
||||
builder.addCube(0, 0, 0, 16, 16, 16);
|
||||
return quads;
|
||||
}
|
||||
|
||||
List<Splotch> splotches = splotchesState.getSplotches();
|
||||
List<Splotch> splotches = splotchesState.getSplotches();
|
||||
|
||||
CubeBuilder builder = new CubeBuilder( );
|
||||
CubeBuilder builder = new CubeBuilder();
|
||||
|
||||
float offsetConstant = 0.001f;
|
||||
for( final Splotch s : splotches )
|
||||
{
|
||||
float offsetConstant = 0.001f;
|
||||
for (final Splotch s : splotches) {
|
||||
|
||||
if( s.isLumen() )
|
||||
{
|
||||
builder.setColorRGB( s.getColor().whiteVariant );
|
||||
builder.setRenderFullBright( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.setColorRGB( s.getColor().mediumVariant );
|
||||
builder.setRenderFullBright( false );
|
||||
}
|
||||
if (s.isLumen()) {
|
||||
builder.setColorRGB(s.getColor().whiteVariant);
|
||||
builder.setRenderFullBright(true);
|
||||
} else {
|
||||
builder.setColorRGB(s.getColor().mediumVariant);
|
||||
builder.setRenderFullBright(false);
|
||||
}
|
||||
|
||||
float offset = offsetConstant;
|
||||
offsetConstant += 0.001f;
|
||||
float offset = offsetConstant;
|
||||
offsetConstant += 0.001f;
|
||||
|
||||
final float buffer = 0.1f;
|
||||
final float buffer = 0.1f;
|
||||
|
||||
float pos_x = s.x();
|
||||
float pos_y = s.y();
|
||||
float pos_x = s.x();
|
||||
float pos_y = s.y();
|
||||
|
||||
pos_x = Math.max( buffer, Math.min( 1.0f - buffer, pos_x ) );
|
||||
pos_y = Math.max( buffer, Math.min( 1.0f - buffer, pos_y ) );
|
||||
pos_x = Math.max(buffer, Math.min(1.0f - buffer, pos_x));
|
||||
pos_y = Math.max(buffer, Math.min(1.0f - buffer, pos_y));
|
||||
|
||||
TextureAtlasSprite ico = this.textures[s.getSeed() % this.textures.length];
|
||||
builder.setTexture( ico );
|
||||
builder.setCustomUv( s.getSide().getOpposite(), 0, 0, 16, 16 );
|
||||
TextureAtlasSprite ico = this.textures[s.getSeed() % this.textures.length];
|
||||
builder.setTexture(ico);
|
||||
builder.setCustomUv(s.getSide().getOpposite(), 0, 0, 16, 16);
|
||||
|
||||
switch( s.getSide() )
|
||||
{
|
||||
case UP:
|
||||
offset = 1.0f - offset;
|
||||
builder.addQuad( Direction.DOWN, pos_x - buffer, offset, pos_y - buffer,
|
||||
pos_x + buffer, offset, pos_y + buffer );
|
||||
break;
|
||||
switch (s.getSide()) {
|
||||
case UP:
|
||||
offset = 1.0f - offset;
|
||||
builder.addQuad(Direction.DOWN, pos_x - buffer, offset, pos_y - buffer, pos_x + buffer, offset,
|
||||
pos_y + buffer);
|
||||
break;
|
||||
|
||||
case DOWN:
|
||||
builder.addQuad( Direction.UP, pos_x - buffer, offset, pos_y - buffer,
|
||||
pos_x + buffer, offset, pos_y + buffer );
|
||||
break;
|
||||
case DOWN:
|
||||
builder.addQuad(Direction.UP, pos_x - buffer, offset, pos_y - buffer, pos_x + buffer, offset,
|
||||
pos_y + buffer);
|
||||
break;
|
||||
|
||||
case EAST:
|
||||
offset = 1.0f - offset;
|
||||
builder.addQuad( Direction.WEST, offset, pos_x - buffer, pos_y - buffer,
|
||||
offset, pos_x + buffer, pos_y + buffer );
|
||||
break;
|
||||
case EAST:
|
||||
offset = 1.0f - offset;
|
||||
builder.addQuad(Direction.WEST, offset, pos_x - buffer, pos_y - buffer, offset, pos_x + buffer,
|
||||
pos_y + buffer);
|
||||
break;
|
||||
|
||||
case WEST:
|
||||
builder.addQuad( Direction.EAST, offset, pos_x - buffer, pos_y - buffer,
|
||||
offset, pos_x + buffer, pos_y + buffer );
|
||||
break;
|
||||
case WEST:
|
||||
builder.addQuad(Direction.EAST, offset, pos_x - buffer, pos_y - buffer, offset, pos_x + buffer,
|
||||
pos_y + buffer);
|
||||
break;
|
||||
|
||||
case SOUTH:
|
||||
offset = 1.0f - offset;
|
||||
builder.addQuad( Direction.NORTH, pos_x - buffer, pos_y - buffer, offset,
|
||||
pos_x + buffer, pos_y + buffer, offset );
|
||||
break;
|
||||
case SOUTH:
|
||||
offset = 1.0f - offset;
|
||||
builder.addQuad(Direction.NORTH, pos_x - buffer, pos_y - buffer, offset, pos_x + buffer,
|
||||
pos_y + buffer, offset);
|
||||
break;
|
||||
|
||||
case NORTH:
|
||||
builder.addQuad( Direction.SOUTH, pos_x - buffer, pos_y - buffer, offset,
|
||||
pos_x + buffer, pos_y + buffer, offset );
|
||||
break;
|
||||
case NORTH:
|
||||
builder.addQuad(Direction.SOUTH, pos_x - buffer, pos_y - buffer, offset, pos_x + buffer,
|
||||
pos_y + buffer, offset);
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
}
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
return builder.getOutput();
|
||||
}
|
||||
return builder.getOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isAmbientOcclusion() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isGui3d() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isBuiltInRenderer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
return this.textures[0];
|
||||
}
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture() {
|
||||
return this.textures[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return ItemOverrideList.EMPTY;
|
||||
}
|
||||
@Override
|
||||
public ItemOverrideList getOverrides() {
|
||||
return ItemOverrideList.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_230044_c_() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean func_230044_c_() {
|
||||
return false;
|
||||
}
|
||||
|
||||
static List<Material> getRequiredTextures()
|
||||
{
|
||||
return ImmutableList.of(
|
||||
TEXTURE_PAINT1, TEXTURE_PAINT2, TEXTURE_PAINT3 );
|
||||
}
|
||||
static List<Material> getRequiredTextures() {
|
||||
return ImmutableList.of(TEXTURE_PAINT1, TEXTURE_PAINT2, TEXTURE_PAINT3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,31 @@
|
||||
|
||||
package appeng.block.paint;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModelConfiguration;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
public class PaintSplotchesModel implements IModelGeometry<PaintSplotchesModel> {
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery,
|
||||
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
|
||||
ItemOverrideList overrides, ResourceLocation modelLocation) {
|
||||
return new PaintSplotchesBakedModel(spriteGetter);
|
||||
}
|
||||
|
||||
public class PaintSplotchesModel implements IModelGeometry<PaintSplotchesModel>
|
||||
{
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) {
|
||||
return new PaintSplotchesBakedModel( spriteGetter );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return PaintSplotchesBakedModel.getRequiredTextures();
|
||||
}
|
||||
@Override
|
||||
public Collection<Material> getTextures(IModelConfiguration owner,
|
||||
Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return PaintSplotchesBakedModel.getRequiredTextures();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
|
||||
package appeng.block.qnb;
|
||||
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
@@ -35,64 +32,63 @@ import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
|
||||
public abstract class BlockQuantumBase extends AEBaseTileBlock<TileQuantumBridge>
|
||||
{
|
||||
public abstract class BlockQuantumBase extends AEBaseTileBlock<TileQuantumBridge> {
|
||||
|
||||
public static final BooleanProperty FORMED = BooleanProperty.create( "formed" );
|
||||
public static final BooleanProperty FORMED = BooleanProperty.create("formed");
|
||||
|
||||
private static final VoxelShape SHAPE;
|
||||
private static final VoxelShape SHAPE;
|
||||
|
||||
static {
|
||||
final float shave = 2.0f / 16.0f;
|
||||
SHAPE = VoxelShapes.create(new AxisAlignedBB(shave, shave, shave, 1.0f - shave, 1.0f - shave, 1.0f - shave));
|
||||
}
|
||||
static {
|
||||
final float shave = 2.0f / 16.0f;
|
||||
SHAPE = VoxelShapes.create(new AxisAlignedBB(shave, shave, shave, 1.0f - shave, 1.0f - shave, 1.0f - shave));
|
||||
}
|
||||
|
||||
public BlockQuantumBase(Block.Properties props) {
|
||||
super(props);
|
||||
this.setFullSize(this.setOpaque(false));
|
||||
this.setDefaultState(this.getDefaultState().with(FORMED, false));
|
||||
}
|
||||
public BlockQuantumBase(Block.Properties props) {
|
||||
super(props);
|
||||
this.setFullSize(this.setOpaque(false));
|
||||
this.setDefaultState(this.getDefaultState().with(FORMED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(FORMED);
|
||||
}
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(FORMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileQuantumBridge te) {
|
||||
return currentState.with(FORMED, te.isFormed());
|
||||
}
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileQuantumBridge te) {
|
||||
return currentState.with(FORMED, te.isFormed());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving )
|
||||
{
|
||||
final TileQuantumBridge bridge = this.getTileEntity( world, pos );
|
||||
if( bridge != null )
|
||||
{
|
||||
bridge.neighborUpdate();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
final TileQuantumBridge bridge = this.getTileEntity(world, pos);
|
||||
if (bridge != null) {
|
||||
bridge.neighborUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (newState.getBlock() == state.getBlock()) {
|
||||
return; // Just a block state change
|
||||
}
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (newState.getBlock() == state.getBlock()) {
|
||||
return; // Just a block state change
|
||||
}
|
||||
|
||||
final TileQuantumBridge bridge = this.getTileEntity( w, pos );
|
||||
if( bridge != null )
|
||||
{
|
||||
bridge.breakCluster();
|
||||
}
|
||||
final TileQuantumBridge bridge = this.getTileEntity(w, pos);
|
||||
if (bridge != null) {
|
||||
bridge.breakCluster();
|
||||
}
|
||||
|
||||
super.onReplaced( state, w, pos, newState, isMoving );
|
||||
}
|
||||
super.onReplaced(state, w, pos, newState, isMoving);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,16 +18,12 @@
|
||||
|
||||
package appeng.block.qnb;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerQNB;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -46,67 +42,61 @@ import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.client.EffectType;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerQNB;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockQuantumLinkChamber extends BlockQuantumBase {
|
||||
|
||||
public class BlockQuantumLinkChamber extends BlockQuantumBase
|
||||
{
|
||||
private static final VoxelShape SHAPE;
|
||||
|
||||
private static final VoxelShape SHAPE;
|
||||
static {
|
||||
final double onePixel = 2.0 / 16.0;
|
||||
SHAPE = VoxelShapes.create(
|
||||
new AxisAlignedBB(onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel));
|
||||
}
|
||||
|
||||
static {
|
||||
final double onePixel = 2.0 / 16.0;
|
||||
SHAPE = VoxelShapes.create( new AxisAlignedBB( onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel ) );
|
||||
}
|
||||
public BlockQuantumLinkChamber() {
|
||||
super(defaultProps(AEGlassMaterial.INSTANCE));
|
||||
}
|
||||
|
||||
public BlockQuantumLinkChamber()
|
||||
{
|
||||
super(defaultProps(AEGlassMaterial.INSTANCE) );
|
||||
}
|
||||
@Override
|
||||
public void animateTick(final BlockState state, final World w, final BlockPos pos, final Random rand) {
|
||||
final TileQuantumBridge bridge = this.getTileEntity(w, pos);
|
||||
if (bridge != null) {
|
||||
if (bridge.hasQES()) {
|
||||
if (AppEng.proxy.shouldAddParticles(rand)) {
|
||||
AppEng.proxy.spawnEffect(EffectType.Energy, w, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
|
||||
null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animateTick( final BlockState state, final World w, final BlockPos pos, final Random rand )
|
||||
{
|
||||
final TileQuantumBridge bridge = this.getTileEntity( w, pos );
|
||||
if( bridge != null )
|
||||
{
|
||||
if( bridge.hasQES() )
|
||||
{
|
||||
if( AppEng.proxy.shouldAddParticles( rand ) )
|
||||
{
|
||||
AppEng.proxy.spawnEffect( EffectType.Energy, w, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, null );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
if (p.isCrouching()) {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
|
||||
{
|
||||
if( p.isCrouching() )
|
||||
{
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
final TileQuantumBridge tg = this.getTileEntity(w, pos);
|
||||
if (tg != null) {
|
||||
if (Platform.isServer()) {
|
||||
ContainerOpener.openContainer(ContainerQNB.TYPE, p, ContainerLocator.forTileEntity(tg));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
final TileQuantumBridge tg = this.getTileEntity( w, pos );
|
||||
if( tg != null )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerQNB.TYPE, p, ContainerLocator.forTileEntity(tg));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
package appeng.block.qnb;
|
||||
|
||||
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
@@ -29,6 +27,7 @@ import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
|
||||
public class BlockQuantumRing extends BlockQuantumBase {
|
||||
|
||||
@@ -52,6 +51,7 @@ public class BlockQuantumRing extends BlockQuantumBase {
|
||||
}
|
||||
|
||||
private static VoxelShape createShape(double onePixel) {
|
||||
return VoxelShapes.create(new AxisAlignedBB(onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel));
|
||||
return VoxelShapes.create(
|
||||
new AxisAlignedBB(onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
|
||||
package appeng.block.qnb;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.client.render.cablebus.CubeBuilder;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
@@ -20,219 +21,203 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.data.IDynamicBakedModel;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.client.render.cablebus.CubeBuilder;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
|
||||
class QnbFormedBakedModel implements IDynamicBakedModel
|
||||
{
|
||||
class QnbFormedBakedModel implements IDynamicBakedModel {
|
||||
|
||||
private static final Material TEXTURE_LINK = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(AppEng.MOD_ID, "block/quantum_link" ));
|
||||
private static final Material TEXTURE_RING = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "block/quantum_ring" ));
|
||||
private static final Material TEXTURE_RING_LIGHT = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "block/quantum_ring_light" ));
|
||||
private static final Material TEXTURE_RING_LIGHT_CORNER = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "block/quantum_ring_light_corner" ));
|
||||
private static final Material TEXTURE_CABLE_GLASS = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "parts/cable/glass/transparent" ));
|
||||
private static final Material TEXTURE_COVERED_CABLE = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "parts/cable/covered/transparent" ));
|
||||
private static final Material TEXTURE_LINK = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
||||
new ResourceLocation(AppEng.MOD_ID, "block/quantum_link"));
|
||||
private static final Material TEXTURE_RING = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
||||
new ResourceLocation(AppEng.MOD_ID, "block/quantum_ring"));
|
||||
private static final Material TEXTURE_RING_LIGHT = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
||||
new ResourceLocation(AppEng.MOD_ID, "block/quantum_ring_light"));
|
||||
private static final Material TEXTURE_RING_LIGHT_CORNER = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
||||
new ResourceLocation(AppEng.MOD_ID, "block/quantum_ring_light_corner"));
|
||||
private static final Material TEXTURE_CABLE_GLASS = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
||||
new ResourceLocation(AppEng.MOD_ID, "parts/cable/glass/transparent"));
|
||||
private static final Material TEXTURE_COVERED_CABLE = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
||||
new ResourceLocation(AppEng.MOD_ID, "parts/cable/covered/transparent"));
|
||||
|
||||
private static final float DEFAULT_RENDER_MIN = 2.0f;
|
||||
private static final float DEFAULT_RENDER_MAX = 14.0f;
|
||||
private static final float DEFAULT_RENDER_MIN = 2.0f;
|
||||
private static final float DEFAULT_RENDER_MAX = 14.0f;
|
||||
|
||||
private static final float CORNER_POWERED_RENDER_MIN = 3.9f;
|
||||
private static final float CORNER_POWERED_RENDER_MAX = 12.1f;
|
||||
private static final float CORNER_POWERED_RENDER_MIN = 3.9f;
|
||||
private static final float CORNER_POWERED_RENDER_MAX = 12.1f;
|
||||
|
||||
private static final float CENTER_POWERED_RENDER_MIN = -0.01f;
|
||||
private static final float CENTER_POWERED_RENDER_MAX = 16.01f;
|
||||
private static final float CENTER_POWERED_RENDER_MIN = -0.01f;
|
||||
private static final float CENTER_POWERED_RENDER_MAX = 16.01f;
|
||||
|
||||
private final IBakedModel baseModel;
|
||||
private final IBakedModel baseModel;
|
||||
|
||||
private final Block linkBlock;
|
||||
private final Block linkBlock;
|
||||
|
||||
private final TextureAtlasSprite linkTexture;
|
||||
private final TextureAtlasSprite ringTexture;
|
||||
private final TextureAtlasSprite glassCableTexture;
|
||||
private final TextureAtlasSprite coveredCableTexture;
|
||||
private final TextureAtlasSprite lightTexture;
|
||||
private final TextureAtlasSprite lightCornerTexture;
|
||||
private final TextureAtlasSprite linkTexture;
|
||||
private final TextureAtlasSprite ringTexture;
|
||||
private final TextureAtlasSprite glassCableTexture;
|
||||
private final TextureAtlasSprite coveredCableTexture;
|
||||
private final TextureAtlasSprite lightTexture;
|
||||
private final TextureAtlasSprite lightCornerTexture;
|
||||
|
||||
public QnbFormedBakedModel( IBakedModel baseModel, Function<Material, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
this.baseModel = baseModel;
|
||||
this.linkTexture = bakedTextureGetter.apply( TEXTURE_LINK );
|
||||
this.ringTexture = bakedTextureGetter.apply( TEXTURE_RING );
|
||||
this.glassCableTexture = bakedTextureGetter.apply( TEXTURE_CABLE_GLASS );
|
||||
this.coveredCableTexture = bakedTextureGetter.apply( TEXTURE_COVERED_CABLE );
|
||||
this.lightTexture = bakedTextureGetter.apply( TEXTURE_RING_LIGHT );
|
||||
this.lightCornerTexture = bakedTextureGetter.apply( TEXTURE_RING_LIGHT_CORNER );
|
||||
this.linkBlock = AEApi.instance().definitions().blocks().quantumLink().maybeBlock().orElse( null );
|
||||
}
|
||||
public QnbFormedBakedModel(IBakedModel baseModel, Function<Material, TextureAtlasSprite> bakedTextureGetter) {
|
||||
this.baseModel = baseModel;
|
||||
this.linkTexture = bakedTextureGetter.apply(TEXTURE_LINK);
|
||||
this.ringTexture = bakedTextureGetter.apply(TEXTURE_RING);
|
||||
this.glassCableTexture = bakedTextureGetter.apply(TEXTURE_CABLE_GLASS);
|
||||
this.coveredCableTexture = bakedTextureGetter.apply(TEXTURE_COVERED_CABLE);
|
||||
this.lightTexture = bakedTextureGetter.apply(TEXTURE_RING_LIGHT);
|
||||
this.lightCornerTexture = bakedTextureGetter.apply(TEXTURE_RING_LIGHT_CORNER);
|
||||
this.linkBlock = AEApi.instance().definitions().blocks().quantumLink().maybeBlock().orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData modelData)
|
||||
{
|
||||
QnbFormedState formedState = modelData.getData(TileQuantumBridge.FORMED_STATE);
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand,
|
||||
IModelData modelData) {
|
||||
QnbFormedState formedState = modelData.getData(TileQuantumBridge.FORMED_STATE);
|
||||
|
||||
if( formedState == null )
|
||||
{
|
||||
return this.baseModel.getQuads( state, side, rand );
|
||||
}
|
||||
if (formedState == null) {
|
||||
return this.baseModel.getQuads(state, side, rand);
|
||||
}
|
||||
|
||||
if (side != null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (side != null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return this.getQuads( formedState, state );
|
||||
}
|
||||
return this.getQuads(formedState, state);
|
||||
}
|
||||
|
||||
private List<BakedQuad> getQuads( QnbFormedState formedState, BlockState state )
|
||||
{
|
||||
CubeBuilder builder = new CubeBuilder( );
|
||||
private List<BakedQuad> getQuads(QnbFormedState formedState, BlockState state) {
|
||||
CubeBuilder builder = new CubeBuilder();
|
||||
|
||||
if( state.getBlock() == this.linkBlock )
|
||||
{
|
||||
Set<Direction> sides = formedState.getAdjacentQuantumBridges();
|
||||
if (state.getBlock() == this.linkBlock) {
|
||||
Set<Direction> sides = formedState.getAdjacentQuantumBridges();
|
||||
|
||||
this.renderCableAt( builder, 0.11f * 16, this.glassCableTexture, 0.141f * 16, sides );
|
||||
this.renderCableAt(builder, 0.11f * 16, this.glassCableTexture, 0.141f * 16, sides);
|
||||
|
||||
this.renderCableAt( builder, 0.188f * 16, this.coveredCableTexture, 0.1875f * 16, sides );
|
||||
this.renderCableAt(builder, 0.188f * 16, this.coveredCableTexture, 0.1875f * 16, sides);
|
||||
|
||||
builder.setTexture( this.linkTexture );
|
||||
builder.addCube( DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( formedState.isCorner() )
|
||||
{
|
||||
this.renderCableAt( builder, 0.188f * 16, this.coveredCableTexture, 0.05f * 16, formedState.getAdjacentQuantumBridges() );
|
||||
builder.setTexture(this.linkTexture);
|
||||
builder.addCube(DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MAX,
|
||||
DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX);
|
||||
} else {
|
||||
if (formedState.isCorner()) {
|
||||
this.renderCableAt(builder, 0.188f * 16, this.coveredCableTexture, 0.05f * 16,
|
||||
formedState.getAdjacentQuantumBridges());
|
||||
|
||||
builder.setTexture( this.ringTexture );
|
||||
builder.addCube( DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX );
|
||||
builder.setTexture(this.ringTexture);
|
||||
builder.addCube(DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MAX,
|
||||
DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX);
|
||||
|
||||
if( formedState.isPowered() )
|
||||
{
|
||||
builder.setTexture( this.lightCornerTexture );
|
||||
builder.setRenderFullBright( true );
|
||||
for( Direction facing : Direction.values() )
|
||||
{
|
||||
// Offset the face by a slight amount so that it is drawn over the already drawn ring texture
|
||||
// (avoids z-fighting)
|
||||
float xOffset = Math.abs( facing.getXOffset() * 0.01f );
|
||||
float yOffset = Math.abs( facing.getYOffset() * 0.01f );
|
||||
float zOffset = Math.abs( facing.getZOffset() * 0.01f );
|
||||
if (formedState.isPowered()) {
|
||||
builder.setTexture(this.lightCornerTexture);
|
||||
builder.setRenderFullBright(true);
|
||||
for (Direction facing : Direction.values()) {
|
||||
// Offset the face by a slight amount so that it is drawn over the already drawn
|
||||
// ring texture
|
||||
// (avoids z-fighting)
|
||||
float xOffset = Math.abs(facing.getXOffset() * 0.01f);
|
||||
float yOffset = Math.abs(facing.getYOffset() * 0.01f);
|
||||
float zOffset = Math.abs(facing.getZOffset() * 0.01f);
|
||||
|
||||
builder.setDrawFaces( EnumSet.of( facing ) );
|
||||
builder.addCube(
|
||||
DEFAULT_RENDER_MIN - xOffset, DEFAULT_RENDER_MIN - yOffset, DEFAULT_RENDER_MIN - zOffset,
|
||||
DEFAULT_RENDER_MAX + xOffset, DEFAULT_RENDER_MAX + yOffset, DEFAULT_RENDER_MAX + zOffset );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.setTexture( this.ringTexture );
|
||||
builder.setDrawFaces(EnumSet.of(facing));
|
||||
builder.addCube(DEFAULT_RENDER_MIN - xOffset, DEFAULT_RENDER_MIN - yOffset,
|
||||
DEFAULT_RENDER_MIN - zOffset, DEFAULT_RENDER_MAX + xOffset,
|
||||
DEFAULT_RENDER_MAX + yOffset, DEFAULT_RENDER_MAX + zOffset);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
builder.setTexture(this.ringTexture);
|
||||
|
||||
builder.addCube( 0, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, 16, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX );
|
||||
builder.addCube(0, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, 16, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX);
|
||||
|
||||
builder.addCube( DEFAULT_RENDER_MIN, 0, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MAX, 16, DEFAULT_RENDER_MAX );
|
||||
builder.addCube(DEFAULT_RENDER_MIN, 0, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MAX, 16, DEFAULT_RENDER_MAX);
|
||||
|
||||
builder.addCube( DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, 0, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX, 16 );
|
||||
builder.addCube(DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, 0, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX, 16);
|
||||
|
||||
if( formedState.isPowered() )
|
||||
{
|
||||
builder.setTexture( this.lightTexture );
|
||||
builder.setRenderFullBright( true );
|
||||
for( Direction facing : Direction.values() )
|
||||
{
|
||||
// Offset the face by a slight amount so that it is drawn over the already drawn ring texture
|
||||
// (avoids z-fighting)
|
||||
float xOffset = Math.abs( facing.getXOffset() * 0.01f );
|
||||
float yOffset = Math.abs( facing.getYOffset() * 0.01f );
|
||||
float zOffset = Math.abs( facing.getZOffset() * 0.01f );
|
||||
if (formedState.isPowered()) {
|
||||
builder.setTexture(this.lightTexture);
|
||||
builder.setRenderFullBright(true);
|
||||
for (Direction facing : Direction.values()) {
|
||||
// Offset the face by a slight amount so that it is drawn over the already drawn
|
||||
// ring texture
|
||||
// (avoids z-fighting)
|
||||
float xOffset = Math.abs(facing.getXOffset() * 0.01f);
|
||||
float yOffset = Math.abs(facing.getYOffset() * 0.01f);
|
||||
float zOffset = Math.abs(facing.getZOffset() * 0.01f);
|
||||
|
||||
builder.setDrawFaces( EnumSet.of( facing ) );
|
||||
builder.addCube(
|
||||
-xOffset, -yOffset, -zOffset,
|
||||
16 + xOffset, 16 + yOffset, 16 + zOffset );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
builder.setDrawFaces(EnumSet.of(facing));
|
||||
builder.addCube(-xOffset, -yOffset, -zOffset, 16 + xOffset, 16 + yOffset, 16 + zOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return builder.getOutput();
|
||||
}
|
||||
return builder.getOutput();
|
||||
}
|
||||
|
||||
private void renderCableAt( CubeBuilder builder, float thickness, TextureAtlasSprite texture, float pull, Set<Direction> connections )
|
||||
{
|
||||
builder.setTexture( texture );
|
||||
private void renderCableAt(CubeBuilder builder, float thickness, TextureAtlasSprite texture, float pull,
|
||||
Set<Direction> connections) {
|
||||
builder.setTexture(texture);
|
||||
|
||||
if( connections.contains( Direction.WEST ) )
|
||||
{
|
||||
builder.addCube( 0, 8 - thickness, 8 - thickness, 8 - thickness - pull, 8 + thickness, 8 + thickness );
|
||||
}
|
||||
if (connections.contains(Direction.WEST)) {
|
||||
builder.addCube(0, 8 - thickness, 8 - thickness, 8 - thickness - pull, 8 + thickness, 8 + thickness);
|
||||
}
|
||||
|
||||
if( connections.contains( Direction.EAST ) )
|
||||
{
|
||||
builder.addCube( 8 + thickness + pull, 8 - thickness, 8 - thickness, 16, 8 + thickness, 8 + thickness );
|
||||
}
|
||||
if (connections.contains(Direction.EAST)) {
|
||||
builder.addCube(8 + thickness + pull, 8 - thickness, 8 - thickness, 16, 8 + thickness, 8 + thickness);
|
||||
}
|
||||
|
||||
if( connections.contains( Direction.NORTH ) )
|
||||
{
|
||||
builder.addCube( 8 - thickness, 8 - thickness, 0, 8 + thickness, 8 + thickness, 8 - thickness - pull );
|
||||
}
|
||||
if (connections.contains(Direction.NORTH)) {
|
||||
builder.addCube(8 - thickness, 8 - thickness, 0, 8 + thickness, 8 + thickness, 8 - thickness - pull);
|
||||
}
|
||||
|
||||
if( connections.contains( Direction.SOUTH ) )
|
||||
{
|
||||
builder.addCube( 8 - thickness, 8 - thickness, 8 + thickness + pull, 8 + thickness, 8 + thickness, 16 );
|
||||
}
|
||||
if (connections.contains(Direction.SOUTH)) {
|
||||
builder.addCube(8 - thickness, 8 - thickness, 8 + thickness + pull, 8 + thickness, 8 + thickness, 16);
|
||||
}
|
||||
|
||||
if( connections.contains( Direction.DOWN ) )
|
||||
{
|
||||
builder.addCube( 8 - thickness, 0, 8 - thickness, 8 + thickness, 8 - thickness - pull, 8 + thickness );
|
||||
}
|
||||
if (connections.contains(Direction.DOWN)) {
|
||||
builder.addCube(8 - thickness, 0, 8 - thickness, 8 + thickness, 8 - thickness - pull, 8 + thickness);
|
||||
}
|
||||
|
||||
if( connections.contains( Direction.UP ) )
|
||||
{
|
||||
builder.addCube( 8 - thickness, 8 + thickness + pull, 8 - thickness, 8 + thickness, 16, 8 + thickness );
|
||||
}
|
||||
}
|
||||
if (connections.contains(Direction.UP)) {
|
||||
builder.addCube(8 - thickness, 8 + thickness + pull, 8 - thickness, 8 + thickness, 16, 8 + thickness);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
{
|
||||
return this.baseModel.isAmbientOcclusion();
|
||||
}
|
||||
@Override
|
||||
public boolean isAmbientOcclusion() {
|
||||
return this.baseModel.isAmbientOcclusion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isGui3d() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_230044_c_() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean func_230044_c_() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isBuiltInRenderer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
return this.baseModel.getParticleTexture();
|
||||
}
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture() {
|
||||
return this.baseModel.getParticleTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return this.baseModel.getOverrides();
|
||||
}
|
||||
@Override
|
||||
public ItemOverrideList getOverrides() {
|
||||
return this.baseModel.getOverrides();
|
||||
}
|
||||
|
||||
public static List<Material> getRequiredTextures()
|
||||
{
|
||||
return ImmutableList.of(
|
||||
TEXTURE_LINK, TEXTURE_RING, TEXTURE_CABLE_GLASS, TEXTURE_COVERED_CABLE, TEXTURE_RING_LIGHT, TEXTURE_RING_LIGHT_CORNER );
|
||||
}
|
||||
public static List<Material> getRequiredTextures() {
|
||||
return ImmutableList.of(TEXTURE_LINK, TEXTURE_RING, TEXTURE_CABLE_GLASS, TEXTURE_COVERED_CABLE,
|
||||
TEXTURE_RING_LIGHT, TEXTURE_RING_LIGHT_CORNER);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,34 +1,36 @@
|
||||
|
||||
package appeng.block.qnb;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModelConfiguration;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public class QnbFormedModel implements IModelGeometry<QnbFormedModel> {
|
||||
|
||||
public class QnbFormedModel implements IModelGeometry<QnbFormedModel>
|
||||
{
|
||||
private static final ResourceLocation MODEL_RING = new ResourceLocation(AppEng.MOD_ID, "block/qnb/ring");
|
||||
|
||||
private static final ResourceLocation MODEL_RING = new ResourceLocation( AppEng.MOD_ID, "block/qnb/ring" );
|
||||
@Override
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery,
|
||||
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
|
||||
ItemOverrideList overrides, ResourceLocation modelLocation) {
|
||||
IBakedModel ringModel = bakery.getBakedModel(MODEL_RING, modelTransform, spriteGetter);
|
||||
return new QnbFormedBakedModel(ringModel, spriteGetter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) {
|
||||
IBakedModel ringModel = bakery.getBakedModel(MODEL_RING, modelTransform, spriteGetter);
|
||||
return new QnbFormedBakedModel( ringModel, spriteGetter );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return QnbFormedBakedModel.getRequiredTextures();
|
||||
}
|
||||
@Override
|
||||
public Collection<Material> getTextures(IModelConfiguration owner,
|
||||
Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return QnbFormedBakedModel.getRequiredTextures();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,41 +1,34 @@
|
||||
|
||||
package appeng.block.qnb;
|
||||
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
public class QnbFormedState {
|
||||
|
||||
public class QnbFormedState
|
||||
{
|
||||
private final Set<Direction> adjacentQuantumBridges;
|
||||
|
||||
private final Set<Direction> adjacentQuantumBridges;
|
||||
private final boolean corner;
|
||||
|
||||
private final boolean corner;
|
||||
private final boolean powered;
|
||||
|
||||
private final boolean powered;
|
||||
public QnbFormedState(Set<Direction> adjacentQuantumBridges, boolean corner, boolean powered) {
|
||||
this.adjacentQuantumBridges = adjacentQuantumBridges;
|
||||
this.corner = corner;
|
||||
this.powered = powered;
|
||||
}
|
||||
|
||||
public QnbFormedState( Set<Direction> adjacentQuantumBridges, boolean corner, boolean powered )
|
||||
{
|
||||
this.adjacentQuantumBridges = adjacentQuantumBridges;
|
||||
this.corner = corner;
|
||||
this.powered = powered;
|
||||
}
|
||||
public Set<Direction> getAdjacentQuantumBridges() {
|
||||
return this.adjacentQuantumBridges;
|
||||
}
|
||||
|
||||
public Set<Direction> getAdjacentQuantumBridges()
|
||||
{
|
||||
return this.adjacentQuantumBridges;
|
||||
}
|
||||
public boolean isCorner() {
|
||||
return this.corner;
|
||||
}
|
||||
|
||||
public boolean isCorner()
|
||||
{
|
||||
return this.corner;
|
||||
}
|
||||
|
||||
public boolean isPowered()
|
||||
{
|
||||
return this.powered;
|
||||
}
|
||||
public boolean isPowered() {
|
||||
return this.powered;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
package appeng.block.qnb;
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -10,17 +9,15 @@ import appeng.bootstrap.BlockRenderingCustomizer;
|
||||
import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
|
||||
public class QuantumBridgeRendering extends BlockRenderingCustomizer {
|
||||
|
||||
public class QuantumBridgeRendering extends BlockRenderingCustomizer
|
||||
{
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||
{
|
||||
rendering.renderType(RenderType.getCutout());
|
||||
// FIXME rendering.builtInModel( "models/block/qnb/qnb_formed", new QnbFormedModel() );
|
||||
// Disable auto rotation
|
||||
rendering.modelCustomizer( ( location, model ) -> model );
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||
rendering.renderType(RenderType.getCutout());
|
||||
// FIXME rendering.builtInModel( "models/block/qnb/qnb_formed", new
|
||||
// QnbFormedModel() );
|
||||
// Disable auto rotation
|
||||
rendering.modelCustomizer((location, model) -> model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,13 +18,12 @@
|
||||
|
||||
package appeng.block.spatial;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.material.MaterialColor;
|
||||
import net.minecraft.block.material.PushReaction;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -46,66 +45,64 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import appeng.block.AEBaseBlock;
|
||||
|
||||
/**
|
||||
* This block is used to fill empty space in spatial dimensions
|
||||
* and delinates the border of a spatial dimensions's usable space.
|
||||
* This block is used to fill empty space in spatial dimensions and delinates
|
||||
* the border of a spatial dimensions's usable space.
|
||||
*/
|
||||
public class BlockMatrixFrame extends AEBaseBlock
|
||||
{
|
||||
public class BlockMatrixFrame extends AEBaseBlock {
|
||||
|
||||
private static final Material MATERIAL = new Material(MaterialColor.AIR, false, true, true, false, false, false, false, PushReaction.PUSH_ONLY);
|
||||
private static final Material MATERIAL = new Material(MaterialColor.AIR, false, true, true, false, false, false,
|
||||
false, PushReaction.PUSH_ONLY);
|
||||
|
||||
public BlockMatrixFrame()
|
||||
{
|
||||
super( Properties.create(MATERIAL).hardnessAndResistance(-1.0F, 6000000.0F).notSolid().noDrops() );
|
||||
}
|
||||
public BlockMatrixFrame() {
|
||||
super(Properties.create(MATERIAL).hardnessAndResistance(-1.0F, 6000000.0F).notSolid().noDrops());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.INVISIBLE;
|
||||
}
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.INVISIBLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> itemStacks)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> itemStacks) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
return VoxelShapes.fullCube();
|
||||
}
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos,
|
||||
ISelectionContext context) {
|
||||
return VoxelShapes.fullCube();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
// This also prevents any blocks from being placed on this block!
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
// This also prevents any blocks from being placed on this block!
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExplosionDestroy( final World world, final BlockPos pos, final Explosion explosion )
|
||||
{
|
||||
// Don't explode.
|
||||
}
|
||||
@Override
|
||||
public void onExplosionDestroy(final World world, final BlockPos pos, final Explosion explosion) {
|
||||
// Don't explode.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAmbientOcclusionLightValue(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 1.0f;
|
||||
}
|
||||
@Override
|
||||
public float getAmbientOcclusionLightValue(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEntityDestroy( final BlockState state, final IBlockReader world, final BlockPos pos, final Entity entity )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canEntityDestroy(final BlockState state, final IBlockReader world, final BlockPos pos,
|
||||
final Entity entity) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,16 +18,11 @@
|
||||
|
||||
package appeng.block.spatial;
|
||||
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerSpatialIOPort;
|
||||
import appeng.fluids.container.ContainerFluidLevelEmitter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
@@ -38,46 +33,43 @@ import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerSpatialIOPort;
|
||||
import appeng.fluids.container.ContainerFluidLevelEmitter;
|
||||
import appeng.tile.spatial.TileSpatialIOPort;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockSpatialIOPort extends AEBaseTileBlock<TileSpatialIOPort> {
|
||||
|
||||
public class BlockSpatialIOPort extends AEBaseTileBlock<TileSpatialIOPort>
|
||||
{
|
||||
public BlockSpatialIOPort() {
|
||||
super(defaultProps(Material.IRON));
|
||||
}
|
||||
|
||||
public BlockSpatialIOPort()
|
||||
{
|
||||
super( defaultProps(Material.IRON) );
|
||||
}
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
final TileSpatialIOPort te = this.getTileEntity(world, pos);
|
||||
if (te != null) {
|
||||
te.updateRedstoneState();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving )
|
||||
{
|
||||
final TileSpatialIOPort te = this.getTileEntity( world, pos );
|
||||
if( te != null )
|
||||
{
|
||||
te.updateRedstoneState();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
if (p.isCrouching()) {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
|
||||
{
|
||||
if( p.isCrouching() )
|
||||
{
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
final TileSpatialIOPort tg = this.getTileEntity( w, pos );
|
||||
if( tg != null )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerSpatialIOPort.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
final TileSpatialIOPort tg = this.getTileEntity(w, pos);
|
||||
if (tg != null) {
|
||||
if (Platform.isServer()) {
|
||||
ContainerOpener.openContainer(ContainerSpatialIOPort.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,45 +18,38 @@
|
||||
|
||||
package appeng.block.spatial;
|
||||
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.tile.spatial.TileSpatialPylon;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.tile.spatial.TileSpatialPylon;
|
||||
|
||||
public class BlockSpatialPylon extends AEBaseTileBlock<TileSpatialPylon>
|
||||
{
|
||||
public class BlockSpatialPylon extends AEBaseTileBlock<TileSpatialPylon> {
|
||||
|
||||
public BlockSpatialPylon() {
|
||||
super(defaultProps(AEGlassMaterial.INSTANCE));
|
||||
}
|
||||
|
||||
public BlockSpatialPylon()
|
||||
{
|
||||
super( defaultProps(AEGlassMaterial.INSTANCE) );
|
||||
}
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
final TileSpatialPylon tsp = this.getTileEntity(world, pos);
|
||||
if (tsp != null) {
|
||||
tsp.neighborChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving )
|
||||
{
|
||||
final TileSpatialPylon tsp = this.getTileEntity( world, pos );
|
||||
if( tsp != null )
|
||||
{
|
||||
tsp.neighborChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue( final BlockState state, final IBlockReader w, final BlockPos pos )
|
||||
{
|
||||
final TileSpatialPylon tsp = this.getTileEntity( w, pos );
|
||||
if( tsp != null )
|
||||
{
|
||||
return tsp.getLightValue();
|
||||
}
|
||||
return super.getLightValue( state, w, pos );
|
||||
}
|
||||
@Override
|
||||
public int getLightValue(final BlockState state, final IBlockReader w, final BlockPos pos) {
|
||||
final TileSpatialPylon tsp = this.getTileEntity(w, pos);
|
||||
if (tsp != null) {
|
||||
return tsp.getLightValue();
|
||||
}
|
||||
return super.getLightValue(state, w, pos);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,15 +18,8 @@
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerChest;
|
||||
import appeng.container.implementations.ContainerQNB;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.tile.storage.TileChest;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -42,66 +35,67 @@ import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerChest;
|
||||
import appeng.container.implementations.ContainerQNB;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.tile.storage.TileChest;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockChest extends AEBaseTileBlock<TileChest> {
|
||||
|
||||
public class BlockChest extends AEBaseTileBlock<TileChest>
|
||||
{
|
||||
private final static EnumProperty<DriveSlotState> SLOT_STATE = EnumProperty.create("slot_state",
|
||||
DriveSlotState.class);
|
||||
|
||||
private final static EnumProperty<DriveSlotState> SLOT_STATE = EnumProperty.create( "slot_state", DriveSlotState.class );
|
||||
public BlockChest() {
|
||||
super(defaultProps(Material.IRON));
|
||||
this.setDefaultState(this.getDefaultState().with(SLOT_STATE, DriveSlotState.EMPTY));
|
||||
}
|
||||
|
||||
public BlockChest()
|
||||
{
|
||||
super( defaultProps(Material.IRON) );
|
||||
this.setDefaultState( this.getDefaultState().with( SLOT_STATE, DriveSlotState.EMPTY ) );
|
||||
}
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(SLOT_STATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(SLOT_STATE);
|
||||
}
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileChest te) {
|
||||
DriveSlotState slotState = DriveSlotState.EMPTY;
|
||||
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileChest te) {
|
||||
DriveSlotState slotState = DriveSlotState.EMPTY;
|
||||
if (te.getCellCount() >= 1) {
|
||||
slotState = DriveSlotState.fromCellStatus(te.getCellStatus(0));
|
||||
}
|
||||
// Power-state has to be checked separately
|
||||
if (!te.isPowered() && slotState != DriveSlotState.EMPTY) {
|
||||
slotState = DriveSlotState.OFFLINE;
|
||||
}
|
||||
|
||||
if( te.getCellCount() >= 1 )
|
||||
{
|
||||
slotState = DriveSlotState.fromCellStatus( te.getCellStatus( 0 ) );
|
||||
}
|
||||
// Power-state has to be checked separately
|
||||
if( !te.isPowered() && slotState != DriveSlotState.EMPTY )
|
||||
{
|
||||
slotState = DriveSlotState.OFFLINE;
|
||||
}
|
||||
return currentState.with(SLOT_STATE, slotState);
|
||||
}
|
||||
|
||||
return currentState.with( SLOT_STATE, slotState );
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
final TileChest tg = this.getTileEntity(w, pos);
|
||||
if (tg != null && !p.isCrouching()) {
|
||||
if (w.isRemote()) {
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
|
||||
{
|
||||
final TileChest tg = this.getTileEntity( w, pos );
|
||||
if( tg != null && !p.isCrouching() )
|
||||
{
|
||||
if( w.isRemote() )
|
||||
{
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
if (hit.getFace() == tg.getUp()) {
|
||||
if (!tg.openGui(p)) {
|
||||
p.sendMessage(PlayerMessages.ChestCannotReadStorageCell.get());
|
||||
}
|
||||
} else {
|
||||
ContainerOpener.openContainer(ContainerChest.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
|
||||
if (hit.getFace() == tg.getUp()) {
|
||||
if( !tg.openGui( p ) )
|
||||
{
|
||||
p.sendMessage( PlayerMessages.ChestCannotReadStorageCell.get() );
|
||||
}
|
||||
} else {
|
||||
ContainerOpener.openContainer(ContainerChest.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,8 @@
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import appeng.container.implementations.ContainerQuartzKnife;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -35,34 +29,34 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import appeng.container.implementations.ContainerQuartzKnife;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockDrive extends AEBaseTileBlock<TileDrive> {
|
||||
|
||||
public class BlockDrive extends AEBaseTileBlock<TileDrive>
|
||||
{
|
||||
public BlockDrive() {
|
||||
super(defaultProps(Material.IRON));
|
||||
}
|
||||
|
||||
public BlockDrive()
|
||||
{
|
||||
super( defaultProps(Material.IRON) );
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
if (p.isCrouching()) {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
|
||||
{
|
||||
if( p.isCrouching() )
|
||||
{
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
final TileDrive tg = this.getTileEntity( w, pos );
|
||||
if( tg != null )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerDrive.TYPE, p, ContainerLocator.forTileEntity(tg));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
final TileDrive tg = this.getTileEntity(w, pos);
|
||||
if (tg != null) {
|
||||
if (Platform.isServer()) {
|
||||
ContainerOpener.openContainer(ContainerDrive.TYPE, p, ContainerLocator.forTileEntity(tg));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,8 @@
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerIOPort;
|
||||
import appeng.fluids.container.ContainerFluidInterface;
|
||||
import appeng.tile.storage.TileIOPort;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -37,44 +31,44 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerIOPort;
|
||||
import appeng.fluids.container.ContainerFluidInterface;
|
||||
import appeng.tile.storage.TileIOPort;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockIOPort extends AEBaseTileBlock<TileIOPort> {
|
||||
|
||||
public class BlockIOPort extends AEBaseTileBlock<TileIOPort>
|
||||
{
|
||||
public BlockIOPort() {
|
||||
super(defaultProps(Material.IRON));
|
||||
}
|
||||
|
||||
public BlockIOPort()
|
||||
{
|
||||
super( defaultProps(Material.IRON) );
|
||||
}
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
final TileIOPort te = this.getTileEntity(world, pos);
|
||||
if (te != null) {
|
||||
te.updateRedstoneState();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving )
|
||||
{
|
||||
final TileIOPort te = this.getTileEntity( world, pos );
|
||||
if( te != null )
|
||||
{
|
||||
te.updateRedstoneState();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
if (p.isCrouching()) {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
|
||||
{
|
||||
if( p.isCrouching() )
|
||||
{
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
final TileIOPort tg = this.getTileEntity( w, pos );
|
||||
if( tg != null )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerIOPort.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
final TileIOPort tg = this.getTileEntity(w, pos);
|
||||
if (tg != null) {
|
||||
if (Platform.isServer()) {
|
||||
ContainerOpener.openContainer(ContainerIOPort.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,13 +18,8 @@
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerSkyChest;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -42,85 +37,89 @@ import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerSkyChest;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockSkyChest extends AEBaseTileBlock<TileSkyChest> {
|
||||
|
||||
public class BlockSkyChest extends AEBaseTileBlock<TileSkyChest>
|
||||
{
|
||||
private static final double AABB_OFFSET_BOTTOM = 0.00;
|
||||
private static final double AABB_OFFSET_SIDES = 0.06;
|
||||
private static final double AABB_OFFSET_TOP = 0.125;
|
||||
|
||||
private static final double AABB_OFFSET_BOTTOM = 0.00;
|
||||
private static final double AABB_OFFSET_SIDES = 0.06;
|
||||
private static final double AABB_OFFSET_TOP = 0.125;
|
||||
public enum SkyChestType {
|
||||
STONE, BLOCK
|
||||
};
|
||||
|
||||
public enum SkyChestType
|
||||
{
|
||||
STONE, BLOCK
|
||||
};
|
||||
public final SkyChestType type;
|
||||
|
||||
public final SkyChestType type;
|
||||
public BlockSkyChest(final SkyChestType type, Properties props) {
|
||||
super(props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public BlockSkyChest( final SkyChestType type, Properties props )
|
||||
{
|
||||
super( props );
|
||||
this.type = type;
|
||||
}
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.ENTITYBLOCK_ANIMATED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.ENTITYBLOCK_ANIMATED;
|
||||
}
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
if (Platform.isServer()) {
|
||||
TileSkyChest tile = getTileEntity(w, pos);
|
||||
if (tile == null) {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
TileSkyChest tile = getTileEntity(w, pos);
|
||||
if (tile == null) {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
ContainerOpener.openContainer(ContainerSkyChest.TYPE, player, ContainerLocator.forTileEntity(tile));
|
||||
}
|
||||
|
||||
ContainerOpener.openContainer(ContainerSkyChest.TYPE, player, ContainerLocator.forTileEntity(tile));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
// TODO Cache this! It can't be that hard!
|
||||
AxisAlignedBB aabb = computeAABB(worldIn, pos);
|
||||
return VoxelShapes.create(aabb);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
// TODO Cache this! It can't be that hard!
|
||||
AxisAlignedBB aabb = computeAABB(worldIn, pos);
|
||||
return VoxelShapes.create(aabb);
|
||||
}
|
||||
private AxisAlignedBB computeAABB(final IBlockReader w, final BlockPos pos) {
|
||||
final TileSkyChest sk = this.getTileEntity(w, pos);
|
||||
Direction o = Direction.UP;
|
||||
|
||||
private AxisAlignedBB computeAABB(final IBlockReader w, final BlockPos pos )
|
||||
{
|
||||
final TileSkyChest sk = this.getTileEntity( w, pos );
|
||||
Direction o = Direction.UP;
|
||||
if (sk != null) {
|
||||
o = sk.getUp();
|
||||
}
|
||||
|
||||
if( sk != null )
|
||||
{
|
||||
o = sk.getUp();
|
||||
}
|
||||
final double offsetX = o.getXOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
|
||||
final double offsetY = o.getYOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
|
||||
final double offsetZ = o.getZOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
|
||||
|
||||
final double offsetX = o.getXOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
|
||||
final double offsetY = o.getYOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
|
||||
final double offsetZ = o.getZOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
|
||||
// for x/z top and bottom is swapped
|
||||
final double minX = Math.max(0.0,
|
||||
offsetX + (o.getXOffset() < 0 ? AABB_OFFSET_BOTTOM : (o.getXOffset() * AABB_OFFSET_TOP)));
|
||||
final double minY = Math.max(0.0,
|
||||
offsetY + (o.getYOffset() < 0 ? AABB_OFFSET_TOP : (o.getYOffset() * AABB_OFFSET_BOTTOM)));
|
||||
final double minZ = Math.max(0.0,
|
||||
offsetZ + (o.getZOffset() < 0 ? AABB_OFFSET_BOTTOM : (o.getZOffset() * AABB_OFFSET_TOP)));
|
||||
|
||||
// for x/z top and bottom is swapped
|
||||
final double minX = Math.max( 0.0, offsetX + ( o.getXOffset() < 0 ? AABB_OFFSET_BOTTOM : ( o.getXOffset() * AABB_OFFSET_TOP ) ) );
|
||||
final double minY = Math.max( 0.0, offsetY + ( o.getYOffset() < 0 ? AABB_OFFSET_TOP : ( o.getYOffset() * AABB_OFFSET_BOTTOM ) ) );
|
||||
final double minZ = Math.max( 0.0, offsetZ + ( o.getZOffset() < 0 ? AABB_OFFSET_BOTTOM : ( o.getZOffset() * AABB_OFFSET_TOP ) ) );
|
||||
final double maxX = Math.min(1.0,
|
||||
1.0 - offsetX - (o.getXOffset() < 0 ? AABB_OFFSET_TOP : (o.getXOffset() * AABB_OFFSET_BOTTOM)));
|
||||
final double maxY = Math.min(1.0,
|
||||
1.0 - offsetY - (o.getYOffset() < 0 ? AABB_OFFSET_BOTTOM : (o.getYOffset() * AABB_OFFSET_TOP)));
|
||||
final double maxZ = Math.min(1.0,
|
||||
1.0 - offsetZ - (o.getZOffset() < 0 ? AABB_OFFSET_TOP : (o.getZOffset() * AABB_OFFSET_BOTTOM)));
|
||||
|
||||
final double maxX = Math.min( 1.0, 1.0 - offsetX - ( o.getXOffset() < 0 ? AABB_OFFSET_TOP : ( o.getXOffset() * AABB_OFFSET_BOTTOM ) ) );
|
||||
final double maxY = Math.min( 1.0, 1.0 - offsetY - ( o.getYOffset() < 0 ? AABB_OFFSET_BOTTOM : ( o.getYOffset() * AABB_OFFSET_TOP ) ) );
|
||||
final double maxZ = Math.min( 1.0, 1.0 - offsetZ - ( o.getZOffset() < 0 ? AABB_OFFSET_TOP : ( o.getZOffset() * AABB_OFFSET_BOTTOM ) ) );
|
||||
|
||||
return new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ );
|
||||
}
|
||||
return new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -30,19 +29,16 @@ import appeng.bootstrap.IItemRendering;
|
||||
import appeng.client.render.ColorableTileBlockColor;
|
||||
import appeng.client.render.StaticItemColor;
|
||||
|
||||
public class ChestRendering extends BlockRenderingCustomizer {
|
||||
|
||||
public class ChestRendering extends BlockRenderingCustomizer
|
||||
{
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||
rendering.renderType(RenderType.getCutout());
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||
{
|
||||
rendering.renderType(RenderType.getCutout());
|
||||
|
||||
// I checked, the ME chest doesn't keep its color in item form
|
||||
itemRendering.color( new StaticItemColor( AEColor.TRANSPARENT ) );
|
||||
rendering.blockColor( new ColorableTileBlockColor() );
|
||||
}
|
||||
// I checked, the ME chest doesn't keep its color in item form
|
||||
itemRendering.color(new StaticItemColor(AEColor.TRANSPARENT));
|
||||
rendering.blockColor(new ColorableTileBlockColor());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,18 +18,15 @@
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
||||
import appeng.bootstrap.BlockRenderingCustomizer;
|
||||
import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
||||
|
||||
public class DriveRendering extends BlockRenderingCustomizer
|
||||
{
|
||||
@Override
|
||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||
{
|
||||
rendering.renderType(RenderType.getCutout());
|
||||
}
|
||||
public class DriveRendering extends BlockRenderingCustomizer {
|
||||
@Override
|
||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||
rendering.renderType(RenderType.getCutout());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,33 +18,28 @@
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
|
||||
/**
|
||||
* Describes the type of cell present in a slot.
|
||||
*/
|
||||
public enum DriveSlotCellType implements IStringSerializable
|
||||
{
|
||||
public enum DriveSlotCellType implements IStringSerializable {
|
||||
|
||||
EMPTY("empty"),
|
||||
EMPTY("empty"),
|
||||
|
||||
ITEM("item"),
|
||||
ITEM("item"),
|
||||
|
||||
FLUID("fluid");
|
||||
FLUID("fluid");
|
||||
|
||||
private final String name;
|
||||
private final String name;
|
||||
|
||||
DriveSlotCellType(String name )
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
DriveSlotCellType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,58 +18,52 @@
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
|
||||
/**
|
||||
* Describes the different states a single slot of a BlockDrive can be in in terms of rendering.
|
||||
* Describes the different states a single slot of a BlockDrive can be in in
|
||||
* terms of rendering.
|
||||
*/
|
||||
public enum DriveSlotState implements IStringSerializable
|
||||
{
|
||||
public enum DriveSlotState implements IStringSerializable {
|
||||
|
||||
// No cell in slot
|
||||
EMPTY( "empty" ),
|
||||
// No cell in slot
|
||||
EMPTY("empty"),
|
||||
|
||||
// Cell in slot, but unpowered
|
||||
OFFLINE( "offline" ),
|
||||
// Cell in slot, but unpowered
|
||||
OFFLINE("offline"),
|
||||
|
||||
// Online and free space
|
||||
ONLINE( "online" ),
|
||||
// Online and free space
|
||||
ONLINE("online"),
|
||||
|
||||
// Types full, space left
|
||||
TYPES_FULL( "types_full" ),
|
||||
// Types full, space left
|
||||
TYPES_FULL("types_full"),
|
||||
|
||||
// Completely full
|
||||
FULL( "full" );
|
||||
// Completely full
|
||||
FULL("full");
|
||||
|
||||
private final String name;
|
||||
private final String name;
|
||||
|
||||
DriveSlotState( String name )
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
DriveSlotState(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public static DriveSlotState fromCellStatus( int cellStatus )
|
||||
{
|
||||
switch( cellStatus )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return DriveSlotState.EMPTY;
|
||||
case 1:
|
||||
return DriveSlotState.ONLINE;
|
||||
case 2:
|
||||
return DriveSlotState.TYPES_FULL;
|
||||
case 3:
|
||||
return DriveSlotState.FULL;
|
||||
}
|
||||
}
|
||||
public static DriveSlotState fromCellStatus(int cellStatus) {
|
||||
switch (cellStatus) {
|
||||
default:
|
||||
case 0:
|
||||
return DriveSlotState.EMPTY;
|
||||
case 1:
|
||||
return DriveSlotState.ONLINE;
|
||||
case 2:
|
||||
return DriveSlotState.TYPES_FULL;
|
||||
case 3:
|
||||
return DriveSlotState.FULL;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,90 +18,76 @@
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
|
||||
/**
|
||||
* Contains the full information about what the state of the slots in a BlockDrive is.
|
||||
* Contains the full information about what the state of the slots in a
|
||||
* BlockDrive is.
|
||||
*/
|
||||
public class DriveSlotsState
|
||||
{
|
||||
public class DriveSlotsState {
|
||||
|
||||
private final Item[] cells;
|
||||
private final Item[] cells;
|
||||
|
||||
private final DriveSlotState[] states;
|
||||
private final DriveSlotState[] states;
|
||||
|
||||
public DriveSlotsState(Item[] cells, DriveSlotState[] states) {
|
||||
Preconditions.checkArgument(cells.length == states.length);
|
||||
this.cells = cells;
|
||||
this.states = states;
|
||||
}
|
||||
public DriveSlotsState(Item[] cells, DriveSlotState[] states) {
|
||||
Preconditions.checkArgument(cells.length == states.length);
|
||||
this.cells = cells;
|
||||
this.states = states;
|
||||
}
|
||||
|
||||
public DriveSlotState getState(int index )
|
||||
{
|
||||
if( index >= this.states.length )
|
||||
{
|
||||
return DriveSlotState.EMPTY;
|
||||
}
|
||||
return this.states[index];
|
||||
}
|
||||
public DriveSlotState getState(int index) {
|
||||
if (index >= this.states.length) {
|
||||
return DriveSlotState.EMPTY;
|
||||
}
|
||||
return this.states[index];
|
||||
}
|
||||
|
||||
public Item getCell(int index )
|
||||
{
|
||||
if( index >= this.cells.length )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return this.cells[index];
|
||||
}
|
||||
public Item getCell(int index) {
|
||||
if (index >= this.cells.length) {
|
||||
return null;
|
||||
}
|
||||
return this.cells[index];
|
||||
}
|
||||
|
||||
public int getSlotCount()
|
||||
{
|
||||
return this.cells.length;
|
||||
}
|
||||
public int getSlotCount() {
|
||||
return this.cells.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an array that describes the state of each slot in this drive or chest.
|
||||
*/
|
||||
public static DriveSlotsState fromChestOrDrive( IChestOrDrive chestOrDrive )
|
||||
{
|
||||
DriveSlotState[] states = new DriveSlotState[chestOrDrive.getCellCount()];
|
||||
Item[] cells = new Item[chestOrDrive.getCellCount()];
|
||||
for( int i = 0; i < chestOrDrive.getCellCount(); i++ )
|
||||
{
|
||||
cells[i] = chestOrDrive.getCellItem(i);
|
||||
/**
|
||||
* Retrieve an array that describes the state of each slot in this drive or
|
||||
* chest.
|
||||
*/
|
||||
public static DriveSlotsState fromChestOrDrive(IChestOrDrive chestOrDrive) {
|
||||
DriveSlotState[] states = new DriveSlotState[chestOrDrive.getCellCount()];
|
||||
Item[] cells = new Item[chestOrDrive.getCellCount()];
|
||||
for (int i = 0; i < chestOrDrive.getCellCount(); i++) {
|
||||
cells[i] = chestOrDrive.getCellItem(i);
|
||||
|
||||
if( !chestOrDrive.isPowered() )
|
||||
{
|
||||
if( chestOrDrive.getCellStatus( i ) != 0 )
|
||||
{
|
||||
states[i] = DriveSlotState.OFFLINE;
|
||||
}
|
||||
else
|
||||
{
|
||||
states[i] = DriveSlotState.EMPTY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
states[i] = DriveSlotState.fromCellStatus( chestOrDrive.getCellStatus( i ) );
|
||||
}
|
||||
}
|
||||
return new DriveSlotsState( cells, states );
|
||||
}
|
||||
if (!chestOrDrive.isPowered()) {
|
||||
if (chestOrDrive.getCellStatus(i) != 0) {
|
||||
states[i] = DriveSlotState.OFFLINE;
|
||||
} else {
|
||||
states[i] = DriveSlotState.EMPTY;
|
||||
}
|
||||
} else {
|
||||
states[i] = DriveSlotState.fromCellStatus(chestOrDrive.getCellStatus(i));
|
||||
}
|
||||
}
|
||||
return new DriveSlotsState(cells, states);
|
||||
}
|
||||
|
||||
public static DriveSlotsState createEmpty( int slotCount )
|
||||
{
|
||||
DriveSlotState[] states = new DriveSlotState[slotCount];
|
||||
Item[] cells = new Item[slotCount];
|
||||
for( int i = 0; i < slotCount; i++ )
|
||||
{
|
||||
states[i] = DriveSlotState.EMPTY;
|
||||
}
|
||||
return new DriveSlotsState( cells, states );
|
||||
}
|
||||
public static DriveSlotsState createEmpty(int slotCount) {
|
||||
DriveSlotState[] states = new DriveSlotState[slotCount];
|
||||
Item[] cells = new Item[slotCount];
|
||||
for (int i = 0; i < slotCount; i++) {
|
||||
states[i] = DriveSlotState.EMPTY;
|
||||
}
|
||||
return new DriveSlotsState(cells, states);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user