use of logisticspipes.interfaces.IRotationProvider in project LogisticsPipes by RS485.
the class LogisticsBlockGenericPipe method getActualState.
@Nonnull
@Override
public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess worldIn, BlockPos pos) {
checkForRenderChanges(worldIn, pos);
state = super.getActualState(state, worldIn, pos);
CoreUnroutedPipe pipe = LogisticsBlockGenericPipe.getPipe(worldIn, pos);
if (LogisticsBlockGenericPipe.isValid(pipe)) {
if (pipe instanceof IRotationProvider) {
state = state.withProperty(rotationProperty, ((IRotationProvider) pipe).getRotation());
}
for (EnumFacing side : EnumFacing.VALUES) {
state = state.withProperty(connectionPropertys.get(side), pipe.container.renderState.pipeConnectionMatrix.isConnected(side));
}
if (pipe instanceof PipeBlockRequestTable) {
state = state.withProperty(modelTypeProperty, PipeRenderModel.REQUEST_TABLE);
}
}
return state;
}
use of logisticspipes.interfaces.IRotationProvider in project LogisticsPipes by RS485.
the class LogisticsSolidBlock method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, @Nonnull ItemStack stack) {
super.onBlockPlacedBy(world, pos, state, placer, stack);
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof LogisticsCraftingTableTileEntity) {
((LogisticsCraftingTableTileEntity) tile).placedBy(placer);
}
if (tile instanceof IRotationProvider) {
((IRotationProvider) tile).setFacing(placer.getHorizontalFacing().getOpposite());
}
}
use of logisticspipes.interfaces.IRotationProvider in project LogisticsPipes by RS485.
the class LogisticsSolidBlock method getIcon.
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess access, int x, int y, int z, int side) {
int meta = access.getBlockMetadata(x, y, z);
TileEntity tile = access.getTileEntity(x, y, z);
if (tile instanceof IRotationProvider) {
return getRotatedTexture(meta, side, ((IRotationProvider) tile).getRotation(), ((IRotationProvider) tile).getFrontTexture());
} else {
return getRotatedTexture(meta, side, 3, 0);
}
}
use of logisticspipes.interfaces.IRotationProvider in project LogisticsPipes by RS485.
the class LogisticsSolidBlock method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(World world, int posX, int posY, int posZ, EntityLivingBase entity, ItemStack itemStack) {
super.onBlockPlacedBy(world, posX, posY, posZ, entity, itemStack);
TileEntity tile = world.getTileEntity(posX, posY, posZ);
if (tile instanceof LogisticsCraftingTableTileEntity) {
((LogisticsCraftingTableTileEntity) tile).placedBy(entity);
}
if (tile instanceof IRotationProvider) {
double x = tile.xCoord + 0.5 - entity.posX;
double z = tile.zCoord + 0.5 - entity.posZ;
double w = Math.atan2(x, z);
double halfPI = Math.PI / 2;
double halfhalfPI = halfPI / 2;
w -= halfhalfPI;
if (w < 0) {
w += 2 * Math.PI;
}
if (0 < w && w <= halfPI) {
((IRotationProvider) tile).setRotation(1);
} else if (halfPI < w && w <= 2 * halfPI) {
((IRotationProvider) tile).setRotation(2);
} else if (2 * halfPI < w && w <= 3 * halfPI) {
((IRotationProvider) tile).setRotation(0);
} else if (3 * halfPI < w && w <= 4 * halfPI) {
((IRotationProvider) tile).setRotation(3);
}
}
}
use of logisticspipes.interfaces.IRotationProvider in project LogisticsPipes by RS485.
the class Rotation method processPacket.
@Override
public void processPacket(EntityPlayer player) {
IRotationProvider tile = this.getTileOrPipe(player.world, IRotationProvider.class);
if (tile != null) {
tile.setRotation(getInteger());
player.world.notifyNeighborsRespectDebug(new BlockPos(getPosX(), getPosY(), getPosZ()), player.world.getBlockState(new BlockPos(getPosX(), getPosY(), getPosZ())).getBlock(), true);
}
}
Aggregations